mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
New option 'completion-preview-inhibit-functions' (bug#80370)
* lisp/completion-preview.el (completion-preview-inhibit-functions): New option. (completion-preview--post-command): Respect it. * etc/NEWS: Announce it.
This commit is contained in:
parent
ed9d341026
commit
47b48346a3
2 changed files with 23 additions and 1 deletions
6
etc/NEWS
6
etc/NEWS
|
|
@ -295,6 +295,12 @@ that your popup interface uses for a more integrated experience.
|
|||
('completion-preview-sort-function' was already present in Emacs 30.1,
|
||||
but as a plain Lisp variable, not a user option.)
|
||||
|
||||
---
|
||||
*** New user option 'completion-preview-inhibit-functions'.
|
||||
This option provides fine-grained control over Completion Preview mode
|
||||
activation. You can use it to specify arbitrary conditions in which to
|
||||
inhibit the mode's operation.
|
||||
|
||||
---
|
||||
*** New mode 'minibuffer-nonselected-mode'.
|
||||
This mode, enabled by default, directs the attention to the active
|
||||
|
|
|
|||
|
|
@ -98,6 +98,14 @@
|
|||
;; when you pause typing for a short duration rather than after every
|
||||
;; key. Try setting it to 0.2 seconds and see how that works for you.
|
||||
;;
|
||||
;; The user option `completion-preview-inhibit-functions' lets you
|
||||
;; specify additional arbitrary conditions for inhibiting the preview.
|
||||
;; For example, if you'd like to inhibit Completion Preview mode during
|
||||
;; keyboard macro execution, you could use something like this:
|
||||
;;
|
||||
;; (add-hook 'completion-preview-inhibit-functions
|
||||
;; (lambda () executing-kbd-macro))
|
||||
;;
|
||||
;; By default, Completion Preview mode automatically adapts the
|
||||
;; background color of the preview overlay to match the background color
|
||||
;; of the buffer text it's completing. If you prefer a distinct
|
||||
|
|
@ -606,6 +614,13 @@ point, otherwise hide it."
|
|||
(selected-window) (current-buffer)))
|
||||
(completion-preview--try-update)))
|
||||
|
||||
(defcustom completion-preview-inhibit-functions nil
|
||||
"Abnormal hook for inhibiting Completion Preview mode operation.
|
||||
Completion Preview mode calls the functions on this hook without
|
||||
arguments during `post-command-hook'. If any of these functions returns
|
||||
non-nil, it inhibits the preview display."
|
||||
:type 'hook)
|
||||
|
||||
(defun completion-preview--post-command ()
|
||||
"Create, update or delete completion preview post last command."
|
||||
(let ((internal-p (or completion-preview--inhibit-update-p
|
||||
|
|
@ -623,7 +638,8 @@ point, otherwise hide it."
|
|||
)
|
||||
((and (completion-preview-require-certain-commands)
|
||||
(completion-preview-require-minimum-symbol-length)
|
||||
(not buffer-read-only))
|
||||
(not buffer-read-only)
|
||||
(not (run-hook-with-args-until-success 'completion-preview-inhibit-functions)))
|
||||
;; All conditions met. Show or update the preview.
|
||||
(completion-preview--show))
|
||||
(completion-preview-active-mode
|
||||
|
|
|
|||
Loading…
Reference in a new issue