branch: master
commit 7dea040b5280a4cfeb303448e79f0f51cd713fa5
Author: Takaaki ISHIKAWA <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el (ivy-pre-prompt-function): Add
Fixes #2185
---
ivy.el | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/ivy.el b/ivy.el
index 1094946..a0d1c63 100644
--- a/ivy.el
+++ b/ivy.el
@@ -180,6 +180,12 @@ Set this to \"(%d/%d) \" to display both the index and the
count."
(const :tag "Count matches and show current match" "(%d/%d) ")
string))
+(defcustom ivy-pre-prompt-function nil
+ "When non-nil, add strings before the `ivy-read' prompt."
+ :type '(choice
+ (const :tag "Do nothing" nil)
+ (function :tag "Custom function")))
+
(defcustom ivy-add-newline-after-prompt nil
"When non-nil, add a newline after the `ivy-read' prompt."
:type 'boolean)
@@ -2904,6 +2910,8 @@ parts beyond their respective faces `ivy-confirm-face' and
(concat n-str d-str "\n"))
(t
(concat n-str d-str)))))
+ (when ivy-pre-prompt-function
+ (setq n-str (concat (funcall ivy-pre-prompt-function) n-str)))
(when ivy-add-newline-after-prompt
(setq n-str (concat n-str "\n")))
(let ((regex (format "\\([^\n]\\{%d\\}\\)[^\n]" (window-width))))