diff options
| author | F. Jason Park | 2023-05-15 00:16:00 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-07-13 18:45:31 -0700 |
| commit | 30fe8703e60d0b756c19f52a6758889600b7b396 (patch) | |
| tree | 8a7fd1fb2abf09b7145bce1e0108c89033219476 /lisp/erc | |
| parent | e51e43b7046b56c58310854182a1d589ee4c770c (diff) | |
| download | emacs-30fe8703e60d0b756c19f52a6758889600b7b396.tar.gz emacs-30fe8703e60d0b756c19f52a6758889600b7b396.zip | |
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)
Diffstat (limited to 'lisp/erc')
| -rw-r--r-- | lisp/erc/erc-common.el | 14 |
1 files changed, 11 insertions, 3 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." | |||
| 289 | (intern (file-name-base file)))) | 289 | (intern (file-name-base file)))) |
| 290 | (v v))) | 290 | (v v))) |
| 291 | 291 | ||
| 292 | (defvar erc--module-toggle-prefix-arg nil | ||
| 293 | "The interpreted prefix arg of the minor-mode toggle. | ||
| 294 | Non-nil inside an ERC module's activation (or deactivation) | ||
| 295 | command, such as `erc-spelling-enable', when it's been called | ||
| 296 | indirectly via the module's minor-mode toggle, i.e., | ||
| 297 | `erc-spelling-mode'. Nil otherwise. Its value is either the | ||
| 298 | symbol `toggle' or an integer produced by `prefix-numeric-value'. | ||
| 299 | See Info node `(elisp) Defining Minor Modes' for more.") | ||
| 300 | |||
| 292 | (defmacro define-erc-module (name alias doc enable-body disable-body | 301 | (defmacro define-erc-module (name alias doc enable-body disable-body |
| 293 | &optional local-p) | 302 | &optional local-p) |
| 294 | "Define a new minor mode using ERC conventions. | 303 | "Define a new minor mode using ERC conventions. |
| @@ -337,9 +346,8 @@ if ARG is omitted or nil. | |||
| 337 | :group (erc--find-group ',name ,(and alias (list 'quote alias))) | 346 | :group (erc--find-group ',name ,(and alias (list 'quote alias))) |
| 338 | ,@(unless local-p `(:require ',(erc--find-feature name alias))) | 347 | ,@(unless local-p `(:require ',(erc--find-feature name alias))) |
| 339 | ,@(unless local-p `(:type ,(erc--prepare-custom-module-type name))) | 348 | ,@(unless local-p `(:type ,(erc--prepare-custom-module-type name))) |
| 340 | (if ,mode | 349 | (let ((erc--module-toggle-prefix-arg arg)) |
| 341 | (,enable) | 350 | (if ,mode (,enable) (,disable)))) |
| 342 | (,disable))) | ||
| 343 | ,(erc--assemble-toggle local-p name enable mode t enable-body) | 351 | ,(erc--assemble-toggle local-p name enable mode t enable-body) |
| 344 | ,(erc--assemble-toggle local-p name disable mode nil disable-body) | 352 | ,(erc--assemble-toggle local-p name disable mode nil disable-body) |
| 345 | ,@(and-let* ((alias) | 353 | ,@(and-let* ((alias) |