emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/command 636d2a7 1/5: Experiment with a mode-base `declare'


From: Lars Ingebrigtsen
Subject: scratch/command 636d2a7 1/5: Experiment with a mode-base `declare'
Date: Sat, 13 Feb 2021 17:13:37 -0500 (EST)

branch: scratch/command
commit 636d2a71dd8d8f4730c7b2def10b93a14d026e0f
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Experiment with a mode-base `declare'
---
 doc/lispref/functions.texi  | 3 +++
 lisp/emacs-lisp/byte-run.el | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 9929739..1e3da8e 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -2316,6 +2316,9 @@ completions in @kbd{M-x}.  @var{completion-predicate} is 
called with
 two parameters: The first parameter is the symbol, and the second is
 the current buffer.
 
+@item (modes @var{modes})
+Specify that this command is meant to be applicable for @var{modes}
+only.
 @end table
 
 @end defmac
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 2d34c98..bc7159c 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -148,6 +148,12 @@ The return value of this function is not used."
       (list 'function-put (list 'quote f)
             ''completion-predicate val)))
 
+(defalias 'byte-run--set-modes
+  #'(lambda (f _args val)
+      (list 'function-put (list 'quote f)
+            ''completion-predicate `(lambda (_ b)
+                                      (completion-with-modes-p ,var b)))))
+
 ;; Add any new entries to info node `(elisp)Declare Form'.
 (defvar defun-declarations-alist
   (list
@@ -165,7 +171,8 @@ If `error-free', drop calls even if 
`byte-compile-delete-errors' is nil.")
    (list 'compiler-macro #'byte-run--set-compiler-macro)
    (list 'doc-string #'byte-run--set-doc-string)
    (list 'indent #'byte-run--set-indent)
-   (list 'completion #'byte-run--set-completion))
+   (list 'completion #'byte-run--set-completion)
+   (list 'modes #'byte-run--set-modes))
   "List associating function properties to their macro expansion.
 Each element of the list takes the form (PROP FUN) where FUN is
 a function.  For each (PROP . VALUES) in a function's declaration,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]