branch: master
commit e9c274a221ee00aabf72db05c6c7a9d140ec202c
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Allow to customize ivy-display-function per caller
* ivy.el (ivy-display-functions-alist): New defvar.
(ivy-read): Use `ivy-display-functions-alist' to set
`ivy-display-function'.
(ivy-completion-in-region): Don't hardcode `ivy-display-function'.
Fixes #788
---
ivy.el | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/ivy.el b/ivy.el
index bd2d5f8..1c8bd40 100644
--- a/ivy.el
+++ b/ivy.el
@@ -184,6 +184,10 @@ See
https://github.com/abo-abo/swiper/wiki/ivy-display-function."
(const :tag "Popup" ivy-display-function-popup)
(const :tag "Overlay" ivy-display-function-overlay)))
+(defvar ivy-display-functions-alist
+ '((ivy-completion-in-region . ivy-display-function-overlay))
+ "An alist for customizing `ivy-display-function'.")
+
(defvar ivy--actions-list nil
"A list of extra actions per command.")
@@ -1422,7 +1426,9 @@ customizations apply to the current completion session."
(transformer-fn
(plist-get ivy--display-transformers-list
(or caller (and (functionp collection)
- collection)))))
+ collection))))
+ (ivy-display-function (unless (window-minibuffer-p)
+ (cdr (assoc caller
ivy-display-functions-alist)))))
(setq ivy-last
(make-ivy-state
:prompt prompt
@@ -1787,8 +1793,6 @@ The previous string is between `ivy-completion-beg' and
`ivy-completion-end'."
(completion-ignore-case case-fold-search)
(comps
(completion-all-completions str collection predicate (- end start)))
- (ivy-display-function (unless (window-minibuffer-p)
- #'ivy-display-function-overlay))
(ivy--prompts-list (if (window-minibuffer-p)
ivy--prompts-list
'(ivy-completion-in-region (lambda nil)))))
@@ -1819,7 +1823,6 @@ The previous string is between `ivy-completion-beg' and
`ivy-completion-end'."
(mapcar #'substring-no-properties comps)
:predicate predicate
:action #'ivy-completion-in-region-action
- :unwind #'ivy-overlay-cleanup
:require-match t
:caller 'ivy-completion-in-region)
t)))))))