[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/command 502b53e 1/2: Make it possible to have derived modes be n
From: |
Lars Ingebrigtsen |
Subject: |
scratch/command 502b53e 1/2: Make it possible to have derived modes be non-interactive |
Date: |
Thu, 11 Feb 2021 16:23:22 -0500 (EST) |
branch: scratch/command
commit 502b53e78b256900c89a3ed9f6f66e9690cfb4fe
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Make it possible to have derived modes be non-interactive
---
doc/lispref/modes.texi | 5 +++++
lisp/emacs-lisp/derived.el | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index ce7727b..28bb7dc 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -861,6 +861,11 @@ 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 derived mode won't be interactive and can't be
+activated with @kbd{M-x whatver-mode RET}.
+
@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/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