From 6b3e1452cf7b597ae5fa861534cd33e447ba9565 Mon Sep 17 00:00:00 2001 From: Eivind Fonn Date: Tue, 31 May 2016 13:46:45 +0200 Subject: [PATCH] core: misc. goodies for describe-package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use completing-read when called interactively - Check for string locations in addition to built-in etc. - Don’t double-princ on/off for toggles - Bind to SPC hdP --- core/core-configuration-layer.el | 21 ++++++++++--------- doc/DOCUMENTATION.org | 3 ++- .../spacemacs-base/keybindings.el | 1 + 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/core-configuration-layer.el b/core/core-configuration-layer.el index 84f2a81e4..e97e4fda2 100644 --- a/core/core-configuration-layer.el +++ b/core/core-configuration-layer.el @@ -463,7 +463,11 @@ If TOGGLEP is non nil then `:toggle' parameter is ignored." (defun configuration-layer/describe-package (pkg-symbol &optional layer-list pkg-list) "Describe a package in the context of the configuration layer system." - (interactive) + (interactive (list (intern + (completing-read + "Package: " + (mapcar (lambda (pkg) (symbol-name (oref pkg :name))) + configuration-layer--packages))))) (let* ((pkg (object-assoc pkg-symbol :name (or pkg-list configuration-layer--packages))) (owner (oref pkg :owner))) @@ -505,17 +509,13 @@ If TOGGLEP is non nil then `:toggle' parameter is ignored." (if (oref pkg :protected) (princ "\nThis package is protected and cannot be excluded.\n") (when (oref pkg :excluded) - (princ "\nThis packages is excluded and cannot be installed.\n"))) + (princ "\nThis package is excluded and cannot be installed.\n"))) ;; toggle (unless (or (oref pkg :excluded) (eq t (oref pkg :toggle))) (princ "\nA toggle is defined for this package, it is currently ") - (princ (if (cfgl-package-enabledp pkg) - (princ "`on' ") - (princ "`off' "))) - (princ "because the following expression evaluates to ") - (if (cfgl-package-enabledp pkg) - (princ "t:\n") - (princ "nil:\n")) + (princ (if (cfgl-package-enabledp pkg) "on" "off")) + (princ " because the following expression evaluates to ") + (princ (if (cfgl-package-enabledp pkg) "t:\n" "nil:\n")) (princ (oref pkg :toggle)) (princ "\n")) (unless (oref pkg :excluded) @@ -523,7 +523,8 @@ If TOGGLEP is non nil then `:toggle' parameter is ignored." (if (not (configuration-layer/package-usedp pkg-symbol)) (princ "\nYou are not using this package.\n") (princ "\nYou are using this package") - (if (memq (oref pkg :location) '(built-in local site)) + (if (or (memq (oref pkg :location) '(built-in local site)) + (stringp (oref pkg :location))) (princ ".\n") (if (not (package-installed-p pkg-symbol)) (princ " but it is not yet installed.\n") diff --git a/doc/DOCUMENTATION.org b/doc/DOCUMENTATION.org index cf7292f11..58618e998 100644 --- a/doc/DOCUMENTATION.org +++ b/doc/DOCUMENTATION.org @@ -1505,7 +1505,8 @@ thusly: | ~SPC h d K~ | describe a keymap | | ~SPC h d l~ | copy last pressed keys that you can paste in gitter chat | | ~SPC h d m~ | describe current modes | -| ~SPC h d p~ | describe a package | +| ~SPC h d p~ | describe a package (Emacs built-in function) | +| ~SPC h d P~ | describe a package (Spacemacs layer information) | | ~SPC h d s~ | copy system information that you can paste in gitter chat | | ~SPC h d t~ | describe a theme | | ~SPC h d v~ | describe a variable | diff --git a/layers/+distribution/spacemacs-base/keybindings.el b/layers/+distribution/spacemacs-base/keybindings.el index 152fe9770..acabf4aec 100644 --- a/layers/+distribution/spacemacs-base/keybindings.el +++ b/layers/+distribution/spacemacs-base/keybindings.el @@ -169,6 +169,7 @@ "hdk" 'describe-key "hdl" 'spacemacs/describe-last-keys "hdp" 'describe-package + "hdP" 'configuration-layer/describe-package "hds" 'spacemacs/describe-system-info "hdt" 'describe-theme "hdv" 'describe-variable