diff options
| author | Eli Zaretskii | 2026-02-14 13:39:19 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2026-02-14 13:39:19 +0200 |
| commit | e1bf2a6ff4002d977ef33a60f7e6f4b6cd18db11 (patch) | |
| tree | cee4e77ddd08b3f94e8b4333574a09e35b599397 | |
| parent | 69694381a43c37acbd9e179ecaa66b3db361fcc3 (diff) | |
| parent | 048e9553a8cc966616c01337af07a1f31a3972f1 (diff) | |
| download | emacs-e1bf2a6ff4002d977ef33a60f7e6f4b6cd18db11.tar.gz emacs-e1bf2a6ff4002d977ef33a60f7e6f4b6cd18db11.zip | |
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/completion-preview.el | 29 |
2 files changed, 31 insertions, 4 deletions
| @@ -296,6 +296,12 @@ that your popup interface uses for a more integrated experience. | |||
| 296 | but as a plain Lisp variable, not a user option.) | 296 | but as a plain Lisp variable, not a user option.) |
| 297 | 297 | ||
| 298 | --- | 298 | --- |
| 299 | *** New user option 'completion-preview-inhibit-functions'. | ||
| 300 | This option provides fine-grained control over Completion Preview mode | ||
| 301 | activation. You can use it to specify arbitrary conditions in which to | ||
| 302 | inhibit the mode's operation. | ||
| 303 | |||
| 304 | --- | ||
| 299 | *** New mode 'minibuffer-nonselected-mode'. | 305 | *** New mode 'minibuffer-nonselected-mode'. |
| 300 | This mode, enabled by default, directs the attention to the active | 306 | This mode, enabled by default, directs the attention to the active |
| 301 | minibuffer window using the 'minibuffer-nonselected' face in case | 307 | minibuffer window using the 'minibuffer-nonselected' face in case |
diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index c58f615de81..5a1a6b5ed43 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el | |||
| @@ -98,6 +98,14 @@ | |||
| 98 | ;; when you pause typing for a short duration rather than after every | 98 | ;; when you pause typing for a short duration rather than after every |
| 99 | ;; key. Try setting it to 0.2 seconds and see how that works for you. | 99 | ;; key. Try setting it to 0.2 seconds and see how that works for you. |
| 100 | ;; | 100 | ;; |
| 101 | ;; The user option `completion-preview-inhibit-functions' lets you | ||
| 102 | ;; specify additional arbitrary conditions for inhibiting the preview. | ||
| 103 | ;; For example, if you'd like to inhibit Completion Preview mode during | ||
| 104 | ;; keyboard macro execution, you could use something like this: | ||
| 105 | ;; | ||
| 106 | ;; (add-hook 'completion-preview-inhibit-functions | ||
| 107 | ;; (lambda () executing-kbd-macro)) | ||
| 108 | ;; | ||
| 101 | ;; By default, Completion Preview mode automatically adapts the | 109 | ;; By default, Completion Preview mode automatically adapts the |
| 102 | ;; background color of the preview overlay to match the background color | 110 | ;; background color of the preview overlay to match the background color |
| 103 | ;; of the buffer text it's completing. If you prefer a distinct | 111 | ;; of the buffer text it's completing. If you prefer a distinct |
| @@ -151,8 +159,12 @@ first candidate, and you can cycle between the candidates with | |||
| 151 | completion-preview-complete | 159 | completion-preview-complete |
| 152 | completion-preview-insert-word | 160 | completion-preview-insert-word |
| 153 | completion-preview-insert-sexp) | 161 | completion-preview-insert-sexp) |
| 154 | "List of commands that should trigger completion preview." | 162 | "List of commands that should trigger completion preview. |
| 155 | :type '(repeat (function :tag "Command" :value self-insert-command)) | 163 | This can also be t instead of a list of commands, which says that any |
| 164 | command can trigger completion preview." | ||
| 165 | :type '(choice (repeat :tag "Specific commands" | ||
| 166 | (function :tag "Command" :value self-insert-command)) | ||
| 167 | (const :tag "Any command" t)) | ||
| 156 | :version "30.1") | 168 | :version "30.1") |
| 157 | 169 | ||
| 158 | (defcustom completion-preview-minimum-symbol-length 3 | 170 | (defcustom completion-preview-minimum-symbol-length 3 |
| @@ -326,7 +338,8 @@ Completion Preview mode avoids updating the preview after these commands.") | |||
| 326 | 338 | ||
| 327 | (defsubst completion-preview-require-certain-commands () | 339 | (defsubst completion-preview-require-certain-commands () |
| 328 | "Check if `this-command' is one of `completion-preview-commands'." | 340 | "Check if `this-command' is one of `completion-preview-commands'." |
| 329 | (memq this-command completion-preview-commands)) | 341 | (or (eq completion-preview-commands t) |
| 342 | (memq this-command completion-preview-commands))) | ||
| 330 | 343 | ||
| 331 | (defun completion-preview-require-minimum-symbol-length () | 344 | (defun completion-preview-require-minimum-symbol-length () |
| 332 | "Check if the length of symbol at point is at least above a certain threshold. | 345 | "Check if the length of symbol at point is at least above a certain threshold. |
| @@ -606,6 +619,13 @@ point, otherwise hide it." | |||
| 606 | (selected-window) (current-buffer))) | 619 | (selected-window) (current-buffer))) |
| 607 | (completion-preview--try-update))) | 620 | (completion-preview--try-update))) |
| 608 | 621 | ||
| 622 | (defcustom completion-preview-inhibit-functions nil | ||
| 623 | "Abnormal hook for inhibiting Completion Preview mode operation. | ||
| 624 | Completion Preview mode calls the functions on this hook without | ||
| 625 | arguments during `post-command-hook'. If any of these functions returns | ||
| 626 | non-nil, it inhibits the preview display." | ||
| 627 | :type 'hook) | ||
| 628 | |||
| 609 | (defun completion-preview--post-command () | 629 | (defun completion-preview--post-command () |
| 610 | "Create, update or delete completion preview post last command." | 630 | "Create, update or delete completion preview post last command." |
| 611 | (let ((internal-p (or completion-preview--inhibit-update-p | 631 | (let ((internal-p (or completion-preview--inhibit-update-p |
| @@ -623,7 +643,8 @@ point, otherwise hide it." | |||
| 623 | ) | 643 | ) |
| 624 | ((and (completion-preview-require-certain-commands) | 644 | ((and (completion-preview-require-certain-commands) |
| 625 | (completion-preview-require-minimum-symbol-length) | 645 | (completion-preview-require-minimum-symbol-length) |
| 626 | (not buffer-read-only)) | 646 | (not buffer-read-only) |
| 647 | (not (run-hook-with-args-until-success 'completion-preview-inhibit-functions))) | ||
| 627 | ;; All conditions met. Show or update the preview. | 648 | ;; All conditions met. Show or update the preview. |
| 628 | (completion-preview--show)) | 649 | (completion-preview--show)) |
| 629 | (completion-preview-active-mode | 650 | (completion-preview-active-mode |