[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 30fe8703e60 10/15: Allow ERC's module toggles access to the prefi
From: |
F. Jason Park |
Subject: |
master 30fe8703e60 10/15: Allow ERC's module toggles access to the prefix arg |
Date: |
Thu, 13 Jul 2023 21:50:42 -0400 (EDT) |
branch: master
commit 30fe8703e60d0b756c19f52a6758889600b7b396
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Allow ERC's module toggles access to the prefix arg
* lisp/erc/erc-common.el (erc--module-toggle-prefix-arg): Add internal
variable for preserving the `arg' passed to a module's minor-mode
toggle, which was previously discarded. Doing this lets modules that
are more interactive in nature overload their mode toggles with
alternate behaviors.
(define-erc-module): Bind `erc--module-toggle-prefix-arg' to the `arg'
parameter, which is normally defined inside a `define-minor-mode' body
form.
* test/lisp/erc/erc-tests.el (define-erc-module--global,
define-erc-module--local): Expect activation body to be wrapped by a
let form binding `erc--module-toggle-prefix-arg'. (Bug#63595)
---
lisp/erc/erc-common.el | 14 +++++++++++---
test/lisp/erc/erc-tests.el | 14 ++++++++------
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el
index 7bd549abfc1..08c11d518a8 100644
--- a/lisp/erc/erc-common.el
+++ b/lisp/erc/erc-common.el
@@ -289,6 +289,15 @@ instead of a `set' state, which precludes any actual
saving."
(intern (file-name-base file))))
(v v)))
+(defvar erc--module-toggle-prefix-arg nil
+ "The interpreted prefix arg of the minor-mode toggle.
+Non-nil inside an ERC module's activation (or deactivation)
+command, such as `erc-spelling-enable', when it's been called
+indirectly via the module's minor-mode toggle, i.e.,
+`erc-spelling-mode'. Nil otherwise. Its value is either the
+symbol `toggle' or an integer produced by `prefix-numeric-value'.
+See Info node `(elisp) Defining Minor Modes' for more.")
+
(defmacro define-erc-module (name alias doc enable-body disable-body
&optional local-p)
"Define a new minor mode using ERC conventions.
@@ -337,9 +346,8 @@ if ARG is omitted or nil.
:group (erc--find-group ',name ,(and alias (list 'quote alias)))
,@(unless local-p `(:require ',(erc--find-feature name alias)))
,@(unless local-p `(:type ,(erc--prepare-custom-module-type name)))
- (if ,mode
- (,enable)
- (,disable)))
+ (let ((erc--module-toggle-prefix-arg arg))
+ (if ,mode (,enable) (,disable))))
,(erc--assemble-toggle local-p name enable mode t enable-body)
,(erc--assemble-toggle local-p name disable mode nil disable-body)
,@(and-let* ((alias)
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 3f36e7c94f6..cc69641fb0b 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -2204,9 +2204,10 @@ Some docstring."
:group (erc--find-group 'mname 'malias)
:require 'nil
:type "mname"
- (if erc-mname-mode
- (erc-mname-enable)
- (erc-mname-disable)))
+ (let ((erc--module-toggle-prefix-arg arg))
+ (if erc-mname-mode
+ (erc-mname-enable)
+ (erc-mname-disable))))
(defun erc-mname-enable ()
"Enable ERC mname mode."
@@ -2259,9 +2260,10 @@ ARG is omitted or nil.
Some docstring."
:global nil
:group (erc--find-group 'mname nil)
- (if erc-mname-mode
- (erc-mname-enable)
- (erc-mname-disable)))
+ (let ((erc--module-toggle-prefix-arg arg))
+ (if erc-mname-mode
+ (erc-mname-enable)
+ (erc-mname-disable))))
(defun erc-mname-enable (&optional ,arg-en)
"Enable ERC mname mode.
- master b95bb644ec2 01/15: Fix command-line parsing regression in erc-cmd-DCC, (continued)
- master b95bb644ec2 01/15: Fix command-line parsing regression in erc-cmd-DCC, F. Jason Park, 2023/07/13
- master 4d6ed774fef 03/15: Respect existing invisibility props in erc-stamp, F. Jason Park, 2023/07/13
- master e51e43b7046 09/15: Fix buffer-mismatch bug in erc-scroll-to-bottom, F. Jason Park, 2023/07/13
- master d45770e8d03 06/15: Optionally combine faces in erc-display-message, F. Jason Park, 2023/07/13
- master 08515350faf 13/15: Add mini modules bufbar and nickbar to ERC, F. Jason Park, 2023/07/13
- master 2716dd13ced 15/15: Decouple keep-place-indicator from global ERC module, F. Jason Park, 2023/07/13
- master 3c70e85d362 11/15: Add preset styles to erc-status-sidebar, F. Jason Park, 2023/07/13
- master b354b3a53bf 07/15: Allow custom display-buffer actions in ERC, F. Jason Park, 2023/07/13
- master 4f3d036957a 04/15: Simplify erc-button-add-nickname-buttons, F. Jason Park, 2023/07/13
- master 9bdc5c62049 08/15: Add module for colorizing nicknames to ERC, F. Jason Park, 2023/07/13
- master 30fe8703e60 10/15: Allow ERC's module toggles access to the prefix arg,
F. Jason Park <=
- master 80e5e9ddc8d 14/15: Improve walkthrough and sample config in ERC manual, F. Jason Park, 2023/07/13
- master 6a96b862680 05/15: Add text props for CTCP messages and speakers in ERC, F. Jason Park, 2023/07/13
- master ded35c2da4d 12/15: Add erc-status-sidebar integration to erc-speedbar, F. Jason Park, 2023/07/13