emacs-diffs
[Top][All Lists]
Advanced

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

master 43ecde8 1/2: Introduce an :interactive keyword for `defined-deriv


From: Lars Ingebrigtsen
Subject: master 43ecde8 1/2: Introduce an :interactive keyword for `defined-derived-mode'
Date: Sun, 14 Feb 2021 06:58:27 -0500 (EST)

branch: master
commit 43ecde85786ccbf4c07d535f08fd74c82a0af31b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Introduce an :interactive keyword for `defined-derived-mode'
    
    * doc/lispref/modes.texi (Derived Modes): Document it.
    * lisp/emacs-lisp/derived.el (define-derived-mode): Introduce a
    new :interactive keyword.
---
 doc/lispref/modes.texi     | 7 +++++++
 etc/NEWS                   | 6 ++++++
 lisp/emacs-lisp/derived.el | 7 ++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 3a4828c..7b8ab4c 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -861,6 +861,13 @@ abbrev table as @var{parent}, or 
@code{fundamental-mode-abbrev-table}
 if @var{parent} is @code{nil}.  (Again, a @code{nil} value is
 @emph{not} equivalent to not specifying this keyword.)
 
+@item :interactive
+Modes are interactive commands by default.  If you specify a
+@code{nil} value, the mode defined here won't be interactive.  This is
+useful for modes that are never meant to be activated by users
+manually, but are only supposed to be used in some specially-formatted
+buffer.
+
 @item :group
 If this is specified, the value should be the customization group for
 this mode.  (Not all major modes have one.)  The command
diff --git a/etc/NEWS b/etc/NEWS
index 7e224b4..08e1e94 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2271,6 +2271,12 @@ back in Emacs 23.1.  The affected functions are: 
'make-obsolete',
 This permanently buffer-local variable holds a list of currently
 enabled minor modes in the current buffer (as a list of symbols).
 
++++
+** 'defined-derived-mode' now takes an :interactive argument.
+This can be used to control whether the defined mode is a command
+or not, and is useful when defining commands that aren't meant to be
+used by users directly.
+
 ** The 'values' variable is now obsolete.
 
 ---
diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el
index 54528b2..43d6dfd 100644
--- a/lisp/emacs-lisp/derived.el
+++ b/lisp/emacs-lisp/derived.el
@@ -141,6 +141,9 @@ KEYWORD-ARGS:
            :after-hook FORM
                    A single lisp form which is evaluated after the mode
                    hooks have been run.  It should not be quoted.
+           :interactive BOOLEAN
+                   Whether the derived mode should be `interactive' or not.
+                   The default is t.
 
 BODY:      forms to execute just before running the
            hooks for the new mode.  Do not use `interactive' here.
@@ -194,6 +197,7 @@ See Info node `(elisp)Derived Modes' for more details.
        (declare-syntax t)
        (hook (derived-mode-hook-name child))
        (group nil)
+        (interactive t)
         (after-hook nil))
 
     ;; Process the keyword args.
@@ -203,6 +207,7 @@ See Info node `(elisp)Derived Modes' for more details.
        (:abbrev-table (setq abbrev (pop body)) (setq declare-abbrev nil))
        (:syntax-table (setq syntax (pop body)) (setq declare-syntax nil))
         (:after-hook (setq after-hook (pop body)))
+        (:interactive (setq interactive (pop body)))
        (_ (pop body))))
 
     (setq docstring (derived-mode-make-docstring
@@ -246,7 +251,7 @@ No problems result if this variable is not bound.
 
        (defun ,child ()
         ,docstring
-        (interactive)
+        ,(and interactive '(interactive))
                                        ; Run the parent.
         (delay-mode-hooks
 



reply via email to

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