[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 40f7804 07/12: Allow define-minor-mode to take an :interactive ke
From: |
Lars Ingebrigtsen |
Subject: |
master 40f7804 07/12: Allow define-minor-mode to take an :interactive keyword |
Date: |
Sun, 14 Feb 2021 08:15:03 -0500 (EST) |
branch: master
commit 40f7804ecb299a7f7c3accd19d27e2898d3b8374
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Allow define-minor-mode to take an :interactive keyword
* lisp/emacs-lisp/easy-mmode.el (define-minor-mode): Allow
specifying the :interactive state and the modes.
---
etc/NEWS | 8 +++++++-
lisp/emacs-lisp/easy-mmode.el | 22 +++++++++++++++++-----
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 9c3396d..22c320b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2294,7 +2294,13 @@ 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.
+** 'define-minor-mode' now takes an :interactive argument.
+This can be used for specifying which modes this minor mode is meant
+for, or to make the new minor mode non-interactive. The default value
+is t.
+
++++
+** 'define-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.
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index bfffbe4..08ac818 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -172,6 +172,10 @@ BODY contains code to execute each time the mode is
enabled or disabled.
:lighter SPEC Same as the LIGHTER argument.
:keymap MAP Same as the KEYMAP argument.
:require SYM Same as in `defcustom'.
+:interactive VAL Whether this mode should be a command or not. The default
+ is to make it one; use nil to avoid that. If VAL is a list,
+ it's interpreted as a list of major modes this minor mode
+ is useful in.
:variable PLACE The location to use instead of the variable MODE to
store
the state of the mode. This can be simply a different
named variable, or a generalized variable.
@@ -226,6 +230,7 @@ For example, you could write
(hook (intern (concat mode-name "-hook")))
(hook-on (intern (concat mode-name "-on-hook")))
(hook-off (intern (concat mode-name "-off-hook")))
+ (interactive t)
keyw keymap-sym tmp)
;; Check keys.
@@ -245,6 +250,7 @@ For example, you could write
(:type (setq type (list :type (pop body))))
(:require (setq require (pop body)))
(:keymap (setq keymap (pop body)))
+ (:interactive (setq interactive (pop body)))
(:variable (setq variable (pop body))
(if (not (and (setq tmp (cdr-safe variable))
(or (symbolp tmp)
@@ -303,11 +309,17 @@ or call the function `%s'."))))
;; The actual function.
(defun ,modefun (&optional arg ,@extra-args)
,(easy-mmode--mode-docstring doc pretty-name keymap-sym)
- ;; Use `toggle' rather than (if ,mode 0 1) so that using
- ;; repeat-command still does the toggling correctly.
- (interactive (list (if current-prefix-arg
- (prefix-numeric-value current-prefix-arg)
- 'toggle)))
+ ,(when interactive
+ ;; Use `toggle' rather than (if ,mode 0 1) so that using
+ ;; repeat-command still does the toggling correctly.
+ (if (consp interactive)
+ `(command ,interactive
+ (list (if current-prefix-arg
+ (prefix-numeric-value current-prefix-arg)
+ 'toggle)))
+ '(interactive (list (if current-prefix-arg
+ (prefix-numeric-value current-prefix-arg)
+ 'toggle)))))
(let ((,last-message (current-message)))
(,@setter
(cond ((eq arg 'toggle)
- master updated (8d517da -> c022199), Lars Ingebrigtsen, 2021/02/14
- master 9291e73 02/12: Add new 'declare' forms for command completion predicates, Lars Ingebrigtsen, 2021/02/14
- master 8cdb616 05/12: Revert the bit about command_modes in previous patch set, Lars Ingebrigtsen, 2021/02/14
- master 40f7804 07/12: Allow define-minor-mode to take an :interactive keyword,
Lars Ingebrigtsen <=
- master 2bfcd93 03/12: Mark easy-menu-do-define menus as "not interesting", Lars Ingebrigtsen, 2021/02/14
- master c1ef7ad 04/12: Add 'read-extended-command-predicate', Lars Ingebrigtsen, 2021/02/14
- master a4c8b6e 06/12: Fix dumping of buffers after minor_modes was added, Lars Ingebrigtsen, 2021/02/14
- master 58e0c8e 01/12: Extend the syntax of `interactive' to list applicable modes, Lars Ingebrigtsen, 2021/02/14
- master c022199 12/12: Do `interactive' mode markup in all Gnus files, Lars Ingebrigtsen, 2021/02/14
- master ffca272 09/12: Mark up eww.el for correct modes, Lars Ingebrigtsen, 2021/02/14
- master 869cdcf 11/12: Really fix the syntax problem in define-minor-mode, Lars Ingebrigtsen, 2021/02/14
- master 98e3ee2 08/12: Make `C-h m' list unbound commands applicable for the mode, Lars Ingebrigtsen, 2021/02/14
- master 07e6b29 10/12: Fix previous define-minor-mode change, Lars Ingebrigtsen, 2021/02/14