branch: master
commit efa751ba2a5dd197766ca93b6ca2942dc451e756
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-M-x): Piggyback on smex for sorting
* counsel.el (counsel-M-x): When smex is present, use it for sorting the
candidates. Also use `counsel-describe-map', so that "C-." and "C-,"
work for commands.
Re #136
---
counsel.el | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/counsel.el b/counsel.el
index 097dbdc..a510325 100644
--- a/counsel.el
+++ b/counsel.el
@@ -490,15 +490,27 @@ If a command is bound, add it's binding after it."
(defun counsel-M-x ()
"Ivy version of `execute-extended-command'."
(interactive)
- (let ((ivy-format-function #'counsel--format-function-M-x))
- (ivy-read "M-x " obarray
- :predicate 'commandp
+ (let ((ivy-format-function #'counsel--format-function-M-x)
+ (cands obarray)
+ (pred 'commandp)
+ (sort t))
+ (when (or (featurep 'smex)
+ (package-installed-p 'smex))
+ (require 'smex)
+ (smex-detect-new-commands)
+ (smex-update)
+ (setq cands smex-ido-cache)
+ (setq pred nil)
+ (setq sort nil))
+ (ivy-read "M-x " cands
+ :predicate pred
:require-match t
:history 'extended-command-history
:action
(lambda (cmd)
(execute-extended-command current-prefix-arg cmd))
- :sort t)))
+ :sort sort
+ :keymap counsel-describe-map)))
(provide 'counsel)