]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify 'completion-preview-active-mode' command tagging
authorEshel Yaron <me@eshelyaron.com>
Wed, 26 Feb 2025 19:11:20 +0000 (20:11 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 26 Feb 2025 19:11:20 +0000 (20:11 +0100)
* 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

index cc8ef996a2216accd8b663fdf079e89ea4624413..246c1dfc2b26ecfdf5258fb2919377314020fbfb 100644 (file)
@@ -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.