[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master a5e49ff 64/90: Make counsel-M-x respect ivy-format-functio
From: |
Oleh Krehel |
Subject: |
[elpa] master a5e49ff 64/90: Make counsel-M-x respect ivy-format-function |
Date: |
Tue, 30 Jun 2015 07:29:01 +0000 |
branch: master
commit a5e49ff5f72bc1687a02c2078ee737433af77487
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Make counsel-M-x respect ivy-format-function
* counsel.el (counsel--format-function-M-x): Remove defun.
(counsel--M-x-transformer): New defun.
(counsel-M-x): Temporarily bind `ivy-format-function' to apply
`counsel--M-x-transformer' beforehand.
* ivy.el (ivy-format-function-arrow): Update style.
Fixes #150
---
counsel.el | 36 +++++++++++++++++++-----------------
ivy.el | 4 ++--
2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/counsel.el b/counsel.el
index af2acb7..3c9fa1f 100644
--- a/counsel.el
+++ b/counsel.el
@@ -487,19 +487,15 @@ When NO-ASYNC is non-nil, do it synchronously."
(ivy--insert-minibuffer
(ivy--format ivy--all-candidates)))))))))
-(defun counsel--format-function-M-x (cands)
- "Join CANDS, a list of command names, with newlines.
-If a command is bound, add it's binding after it."
- (with-selected-window (ivy-state-window ivy-last)
- (mapconcat (lambda (x)
- (let ((binding (substitute-command-keys (format "\\[%s]" x))))
- (setq binding (replace-regexp-in-string "C-x 6" "<f2>"
binding))
- (if (string-match "^M-x" binding)
- x
- (format "%s (%s)" x
- (propertize binding 'face
'font-lock-keyword-face)))))
- cands
- "\n")))
+(defun counsel--M-x-transformer (cmd)
+ "Add a binding to CMD if it's bound in the current window.
+CMD is a command name."
+ (let ((binding (substitute-command-keys (format "\\[%s]" cmd))))
+ (setq binding (replace-regexp-in-string "C-x 6" "<f2>" binding))
+ (if (string-match "^M-x" binding)
+ cmd
+ (format "%s (%s)" cmd
+ (propertize binding 'face 'font-lock-keyword-face)))))
;;;###autoload
(defun counsel-M-x (&optional initial-input)
@@ -509,10 +505,16 @@ Optional INITIAL-INPUT is the initial input in the
minibuffer."
(unless initial-input
(setq initial-input (cdr (assoc this-command
ivy-initial-inputs-alist))))
- (let ((ivy-format-function #'counsel--format-function-M-x)
- (cands obarray)
- (pred 'commandp)
- (sort t))
+ (let* ((store ivy-format-function)
+ (ivy-format-function
+ (lambda (cands)
+ (funcall
+ store
+ (with-selected-window (ivy-state-window ivy-last)
+ (mapcar #'counsel--M-x-transformer cands)))))
+ (cands obarray)
+ (pred 'commandp)
+ (sort t))
(when (or (featurep 'smex)
(package-installed-p 'smex))
(require 'smex)
diff --git a/ivy.el b/ivy.el
index bf399c1..b105690 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1275,8 +1275,8 @@ This string will be inserted into the minibuffer.")
(mapconcat
(lambda (s)
(concat (if (eq (cl-incf i) ivy--index)
- "==> "
- " ")
+ "> "
+ " ")
s))
cands "\n")))
- [elpa] master 4cdb80c 54/90: ivy-hydra.el (defhydra): Wrap in eval-when-compile, (continued)
- [elpa] master 4cdb80c 54/90: ivy-hydra.el (defhydra): Wrap in eval-when-compile, Oleh Krehel, 2015/06/30
- [elpa] master 1dbdcdc 55/90: counsel.el (counsel-M-x): Fixup, Oleh Krehel, 2015/06/30
- [elpa] master bcc5f45 56/90: counsel.el (counsel-M-x): Fixup smex interaction, Oleh Krehel, 2015/06/30
- [elpa] master e238286 57/90: "M-n", "M-p", "M-i" should switch directories when needed, Oleh Krehel, 2015/06/30
- [elpa] master 3f41ce6 58/90: Put the file instead of partial input on history, Oleh Krehel, 2015/06/30
- [elpa] master 5e3c635 59/90: Add a set of commands for resizing minibuffer height, Oleh Krehel, 2015/06/30
- [elpa] master 7b91a39 60/90: ivy.el (ivy-kill-line): Add and bind to "C-k", Oleh Krehel, 2015/06/30
- [elpa] master dcf0f64 61/90: Add "^" as initial input to "C-h f" and "C-h v", Oleh Krehel, 2015/06/30
- [elpa] master 1ef7e18 62/90: "M-i" should not switch directories, Oleh Krehel, 2015/06/30
- [elpa] master 46695ac 63/90: Fix non-file completions ability to enter tramp completion, Oleh Krehel, 2015/06/30
- [elpa] master a5e49ff 64/90: Make counsel-M-x respect ivy-format-function,
Oleh Krehel <=
- [elpa] master 5fcdfb4 65/90: Add better positioning to counsel-git-grep finalizer, Oleh Krehel, 2015/06/30
- [elpa] master 581d8c0 66/90: Don't cut off "/ssh:foo" input, Oleh Krehel, 2015/06/30
- [elpa] master 513a77e 67/90: ivy.el (ivy-alt-done): Find file if given a full tramp path, Oleh Krehel, 2015/06/30
- [elpa] master 972036c 68/90: ivy.el (ivy-alt-done): Enable recursive minibuffers, Oleh Krehel, 2015/06/30
- [elpa] master d9c4427 69/90: Improve performance for "^" initial input, Oleh Krehel, 2015/06/30
- [elpa] master 2c8ad2a 70/90: Add support for Windows drive letters, Oleh Krehel, 2015/06/30
- [elpa] master d466ade 71/90: Match drive letter at start of current directory, Oleh Krehel, 2015/06/30
- [elpa] master cdb2b1a 72/90: Fix the case where file name can contain ~, Oleh Krehel, 2015/06/30
- [elpa] master 7f97ded 74/90: ivy-hydra.el (hydra-ivy): Bind "C-g", Oleh Krehel, 2015/06/30
- [elpa] master 5c09439 75/90: Re-scale the text height to default in the minibuffer, Oleh Krehel, 2015/06/30