[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3dcb07d 237/272: Allow to customize the action hint format
From: |
Oleh Krehel |
Subject: |
[elpa] master 3dcb07d 237/272: Allow to customize the action hint formatter |
Date: |
Mon, 25 Apr 2016 10:13:27 +0000 |
branch: master
commit 3dcb07d56857937434c9ca1fdb521ccdeac80506
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Allow to customize the action hint formatter
* ivy.el (ivy-read-action-format-function): New defvar.
(ivy-read-action-format-default): New defun, extracted from
`ivy-read-action'.
(ivy-read-action'): Update.
Fixes #469
---
ivy.el | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/ivy.el b/ivy.el
index 296f873..d5ce2b4 100644
--- a/ivy.el
+++ b/ivy.el
@@ -466,6 +466,28 @@ When non-nil, it should contain at least one %d.")
(insert ivy-text)
(ivy--exhibit))))
+(defvar ivy-read-action-format-function 'ivy-read-action-format-default
+ "Function used to transform the actions list into a docstring.")
+
+(defun ivy-read-action-format-default (actions)
+ "Create a docstring from ACTIONS.
+
+ACTIONS is a list. Each list item is a list of 3 items:
+key (a string), cmd and doc (a string)."
+ (format "%s\n%s\n"
+ (if (eq this-command 'ivy-read-action)
+ "Select action: "
+ ivy--current)
+ (mapconcat
+ (lambda (x)
+ (format "%s: %s"
+ (propertize
+ (car x)
+ 'face 'ivy-action)
+ (nth 2 x)))
+ actions
+ "\n")))
+
(defun ivy-read-action ()
"Change the action to one of the available ones.
@@ -475,20 +497,7 @@ selection, non-nil otherwise."
(let ((actions (ivy-state-action ivy-last)))
(if (null (ivy--actionp actions))
t
- (let* ((hint (concat (if (eq this-command 'ivy-read-action)
- "Select action: "
- ivy--current)
- "\n"
- (mapconcat
- (lambda (x)
- (format "%s: %s"
- (propertize
- (car x)
- 'face 'ivy-action)
- (nth 2 x)))
- (cdr actions)
- "\n")
- "\n"))
+ (let* ((hint (funcall ivy-read-action-format-function (cdr actions)))
(resize-mini-windows 'grow-only)
(key (string (read-key hint)))
(action-idx (cl-position-if
- [elpa] master 8c4f595 233/272: Fix remapping commit c9b6e0, (continued)
- [elpa] master 8c4f595 233/272: Fix remapping commit c9b6e0, Oleh Krehel, 2016/04/25
- [elpa] master 6fae6e0 259/272: counsel.el (counsel-grep-or-swiper): Use swiper when narrowed, Oleh Krehel, 2016/04/25
- [elpa] master 1b4e819 218/272: ivy.el (ivy-next-history-element): Simplify, Oleh Krehel, 2016/04/25
- [elpa] master b5a9dc5 255/272: ivy.el (ivy--reset-state): file-directory-p needs a string, Oleh Krehel, 2016/04/25
- [elpa] master 6fc36b5 210/272: option to add newline after ivy-read prompt, Oleh Krehel, 2016/04/25
- [elpa] master 9899547 235/272: ivy.el (ivy-action): New face, Oleh Krehel, 2016/04/25
- [elpa] master 63b96a1 250/272: Fix counsel-grep-last-line bug, Oleh Krehel, 2016/04/25
- [elpa] master a891df3 264/272: swiper.el (swiper--multi-candidates): Add check, Oleh Krehel, 2016/04/25
- [elpa] master 5ce2623 223/272: counsel.el (counsel-git): Add "j" action, Oleh Krehel, 2016/04/25
- [elpa] master ee27e27 161/272: ivy.el (ivy-occur-revert-buffer): Move code to swiper-occur, Oleh Krehel, 2016/04/25
- [elpa] master 3dcb07d 237/272: Allow to customize the action hint formatter,
Oleh Krehel <=
- [elpa] master 39a458e 272/272: Merge commit 'db005182ad0fd05c07e8e5c085abe6c750e6c578' from ivy, Oleh Krehel, 2016/04/25