From e2258effbf7f9cd008844f27c87e3809eea076dd Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 26 Feb 2025 20:11:20 +0100 Subject: [PATCH] Simplify 'completion-preview-active-mode' command tagging * lisp/completion-preview.el (completion-preview-insert) (completion-preview-insert-word) (completion-preview-insert-sexp) (completion-preview-complete) (completion-preview-prev-candidate) (completion-preview-next-candidate): Use 'interactive' to associate command with 'completion-preview-active-mode' instead of using a bespoke 'completion-predicate' property. (completion-preview-active-p): Declare obsolete. --- lisp/completion-preview.el | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el index cc8ef996a22..246c1dfc2b2 100644 --- a/lisp/completion-preview.el +++ b/lisp/completion-preview.el @@ -661,7 +661,7 @@ point, otherwise hide it." (defun completion-preview-insert () "Insert the completion candidate that the preview is showing." - (interactive) + (interactive nil completion-preview-active-mode) (completion-preview--barf-if-no-preview) (let* ((pre (completion-preview--get 'completion-preview-base)) (end (completion-preview--get 'completion-preview-end)) @@ -741,14 +741,14 @@ Beyond moving point, FUN should not modify the current buffer." "Insert the first N words of the current completion preview candidate. Interactively, N is the numeric prefix argument, and it defaults to 1." - (interactive "^p") + (interactive "^p" completion-preview-active-mode) (completion-preview-partial-insert #'forward-word n)) (defun completion-preview-insert-sexp (&optional n) "Insert the first N s-expressions of the current completion preview candidate. Interactively, N is the numeric prefix argument, and it defaults to 1." - (interactive "^p") + (interactive "^p" completion-preview-active-mode) (completion-preview-partial-insert #'forward-sexp n 'interactive)) (defun completion-preview-complete () @@ -759,7 +759,7 @@ common prefix to insert, it displays the list of matching completion candidates unless `completion-auto-help' is nil. If you repeat this command again when the completions list is visible, it scrolls the completions list." - (interactive) + (interactive nil completion-preview-active-mode) (completion-preview--barf-if-no-preview) (let* ((beg (completion-preview--get 'completion-preview-beg)) (end (completion-preview--get 'completion-preview-end)) @@ -821,7 +821,7 @@ completions list." If N is negative, cycle -N candidates forward. Interactively, N is the prefix argument and defaults to 1." - (interactive "p") + (interactive "p" completion-preview-active-mode) (completion-preview-next-candidate (- n))) (defun completion-preview-next-candidate (n) @@ -829,7 +829,7 @@ prefix argument and defaults to 1." If N is negative, cycle -N candidates backward. Interactively, N is the prefix argument and defaults to 1." - (interactive "p") + (interactive "p" completion-preview-active-mode) (when completion-preview-active-mode (let* ((beg (completion-preview--get 'completion-preview-beg)) (end (completion-preview--get 'completion-preview-end)) @@ -871,16 +871,10 @@ prefix argument and defaults to 1." The first argument, SYMBOL, is ignored. You can use this function as the `completion-predicate' property of commands that you define that should only be available when the completion preview is active." + (declare + (obsolete "check for `completion-preview-active-mode' instead." "31.1")) (buffer-local-value 'completion-preview-active-mode buffer)) -(dolist (cmd '(completion-preview-insert - completion-preview-insert-word - completion-preview-insert-sexp - completion-preview-complete - completion-preview-prev-candidate - completion-preview-next-candidate)) - (put cmd 'completion-predicate #'completion-preview-active-p)) - ;;;###autoload (define-minor-mode completion-preview-mode "Show in-buffer completion suggestions in a preview as you type. -- 2.39.5