[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 0c3a069ae00 30/37: Convert erc-fill minor mode into a proper modu
From: |
F. Jason Park |
Subject: |
master 0c3a069ae00 30/37: Convert erc-fill minor mode into a proper module |
Date: |
Sat, 8 Apr 2023 17:31:33 -0400 (EDT) |
branch: master
commit 0c3a069ae0051148f2f35f542ce4ef573e5f5468
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Convert erc-fill minor mode into a proper module
* lisp/erc/erc-fill.el (erc-fill-mode, erc-fill-enable,
erc-fill-disable): Use API to create these.
(erc-fill-static): Save restriction instead of caller's match
data. (Bug#60936.)
---
lisp/erc/erc-fill.el | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/lisp/erc/erc-fill.el b/lisp/erc/erc-fill.el
index e10b7d790f6..caf401bf222 100644
--- a/lisp/erc/erc-fill.el
+++ b/lisp/erc/erc-fill.el
@@ -38,30 +38,18 @@
:group 'erc)
;;;###autoload(autoload 'erc-fill-mode "erc-fill" nil t)
-(define-minor-mode erc-fill-mode
- "Toggle ERC fill mode.
-With a prefix argument ARG, enable ERC fill mode if ARG is
-positive, and disable it otherwise. If called from Lisp, enable
-the mode if ARG is omitted or nil.
-
+(define-erc-module fill nil
+ "Manage filling in ERC buffers.
ERC fill mode is a global minor mode. When enabled, messages in
the channel buffers are filled."
- :global t
- (if erc-fill-mode
- (erc-fill-enable)
- (erc-fill-disable)))
-
-(defun erc-fill-enable ()
- "Setup hooks for `erc-fill-mode'."
- (interactive)
- (add-hook 'erc-insert-modify-hook #'erc-fill)
- (add-hook 'erc-send-modify-hook #'erc-fill))
-
-(defun erc-fill-disable ()
- "Cleanup hooks, disable `erc-fill-mode'."
- (interactive)
- (remove-hook 'erc-insert-modify-hook #'erc-fill)
- (remove-hook 'erc-send-modify-hook #'erc-fill))
+ ;; FIXME ensure a consistent ordering relative to hook members from
+ ;; other modules. Ideally, this module's processing should happen
+ ;; after "morphological" modifications to a message's text but
+ ;; before superficial decorations.
+ ((add-hook 'erc-insert-modify-hook #'erc-fill)
+ (add-hook 'erc-send-modify-hook #'erc-fill))
+ ((remove-hook 'erc-insert-modify-hook #'erc-fill)
+ (remove-hook 'erc-send-modify-hook #'erc-fill)))
(defcustom erc-fill-prefix nil
"Values used as `fill-prefix' for `erc-fill-variable'.
@@ -130,7 +118,7 @@ You can put this on `erc-insert-modify-hook' and/or
`erc-send-modify-hook'."
(defun erc-fill-static ()
"Fills a text such that messages start at column `erc-fill-static-center'."
- (save-match-data
+ (save-restriction
(goto-char (point-min))
(looking-at "^\\(\\S-+\\)")
(let ((nick (match-string 1)))
- master d5435a0d822 25/37: Refactor marker initialization in erc-open, (continued)
- master d5435a0d822 25/37: Refactor marker initialization in erc-open, F. Jason Park, 2023/04/08
- master 5011554529b 12/37: Don't require erc-goodies in erc.el, F. Jason Park, 2023/04/08
- master 0e4c07dc744 36/37: Allow erc-reuse-frames to favor connections, F. Jason Park, 2023/04/08
- master 89815631f24 10/37: Copy over upstream Compat macros to erc-compat, F. Jason Park, 2023/04/08
- master 9aa2806fdc3 13/37: Modify erc-mode-map in module definitions, F. Jason Park, 2023/04/08
- master 8793874616f 26/37: Adjust some old text properties in ERC buffers, F. Jason Park, 2023/04/08
- master 3d81ecf0a95 11/37: Leverage loaddefs for migrating ERC modules, F. Jason Park, 2023/04/08
- master 9f6a9cef97b 29/37: Put display properties to better use in erc-stamp, F. Jason Park, 2023/04/08
- master e3c4a648d16 31/37: Add variant for erc-match invisibility spec, F. Jason Park, 2023/04/08
- master c104e90888a 35/37: Make auth-source erc-services tests more readable, F. Jason Park, 2023/04/08
- master 0c3a069ae00 30/37: Convert erc-fill minor mode into a proper module,
F. Jason Park <=
- master 2d3ae5d5e68 03/37: Add subcommand erc-cmd-HELP handler to erc-dcc, F. Jason Park, 2023/04/08