[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 100bd21 001/399: counsel.el (counsel-M-x): Optionally expa
From: |
Oleh Krehel |
Subject: |
[elpa] master 100bd21 001/399: counsel.el (counsel-M-x): Optionally expand aliases |
Date: |
Sat, 20 Jul 2019 14:56:36 -0400 (EDT) |
branch: master
commit 100bd2130b6963bbdcb0bec346abee2d9e2d829e
Author: Andrew Schwartzmeyer <address@hidden>
Commit: Andrew Schwartzmeyer <address@hidden>
counsel.el (counsel-M-x): Optionally expand aliases
Added support via `counsel-M-x-transformer` to show the expansion of an
alias in a manner similar to how keybindings are shown. For example, if
`rb` is aliased to `revert-buffer`, and bound to `C-c r`, `M-x rb` will
show `rb (revert-buffer) (C-c r)`.
Currently the expansion is in the same font as the command, which looks
nice, but it would be easy to add support for a custom face.
The boolean `counsel-alias-expand` was introduced to enable or disable
this functionality, with it defaulting to non-nil.
---
counsel.el | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/counsel.el b/counsel.el
index 97423ec..ee78d9f 100644
--- a/counsel.el
+++ b/counsel.el
@@ -748,22 +748,30 @@ With prefix arg MODE a query for the symbol help mode is
offered."
"Face used by `counsel-M-x' for key bindings."
:group 'ivy-faces)
+(defcustom counsel-alias-expand t
+ "When non-nil, show the expansion of aliases in `counsel-M-x'."
+ :type 'boolean
+ :group 'ivy)
+
(defun counsel-M-x-transformer (cmd)
"Return CMD annotated with its active key binding, if any."
- (let ((key (where-is-internal (intern cmd) nil t)))
- (if (not key)
- cmd
- ;; Prefer `<f2>' over `C-x 6' where applicable
- (let ((i (cl-search [?\C-x ?6] key)))
- (when i
- (let ((dup (vconcat (substring key 0 i) [f2] (substring key (+ i
2))))
- (map (current-global-map)))
- (when (equal (lookup-key map key)
- (lookup-key map dup))
- (setq key dup)))))
- (setq key (key-description key))
- (put-text-property 0 (length key) 'face 'counsel-key-binding key)
- (format "%s (%s)" cmd key))))
+ (let ((alias (symbol-function (intern cmd)))
+ (key (where-is-internal (intern cmd) nil t)))
+ (concat cmd
+ (when (and (symbolp alias) counsel-alias-expand)
+ (format " (%s)" alias))
+ (when key
+ ;; Prefer `<f2>' over `C-x 6' where applicable
+ (let ((i (cl-search [?\C-x ?6] key)))
+ (when i
+ (let ((dup (vconcat (substring key 0 i) [f2] (substring key
(+ i 2))))
+ (map (current-global-map)))
+ (when (equal (lookup-key map key)
+ (lookup-key map dup))
+ (setq key dup)))))
+ (setq key (key-description key))
+ (put-text-property 0 (length key) 'face 'counsel-key-binding key)
+ (format " (%s)" key)))))
(defvar amx-initialized)
(defvar amx-cache)
- [elpa] master updated (64d03d9 -> 33689c1), Oleh Krehel, 2019/07/20
- [elpa] master b4492a3 002/399: counsel.el (counsel-git-checkout-action): Quote branch names, Oleh Krehel, 2019/07/20
- [elpa] master 100bd21 001/399: counsel.el (counsel-M-x): Optionally expand aliases,
Oleh Krehel <=
- [elpa] master 08dd58b 003/399: ivy.el (ivy--regex-fuzzy): Don't allow newlines in wildcards, Oleh Krehel, 2019/07/20
- [elpa] master 70ad031 004/399: doc/Changelog.org: Update path to CSS, Oleh Krehel, 2019/07/20
- [elpa] master 596461e 005/399: counsel.el (counsel-grep-use-swiper-p): New defcustom, Oleh Krehel, 2019/07/20
- [elpa] master 6017cc8 006/399: ivy.el (ivy-read): Keep only one action for one key, Oleh Krehel, 2019/07/20
- [elpa] master dc250bd 008/399: counsel.el (counsel-unicode-char): Don't sort every time, Oleh Krehel, 2019/07/20
- [elpa] master b000b0a 007/399: ivy.el (ivy--recompute-index): Speed up, Oleh Krehel, 2019/07/20
- [elpa] master c2eb4b5 009/399: ivy.el (ivy--kill-buffer-action): Integrate with ivy-switch-buffer-kill, Oleh Krehel, 2019/07/20
- [elpa] master f631d75 013/399: swiper.el (swiper-font-lock-exclude): Add xref--xref-buffer-mode, Oleh Krehel, 2019/07/20
- [elpa] master 3773c26 015/399: swiper.el (swiper--current-window-start): Add docstring, Oleh Krehel, 2019/07/20
- [elpa] master da85d1e 016/399: ivy.el: Require TRAMP earlier, Oleh Krehel, 2019/07/20