[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f8af241192b 10/12: Treat previous/next-line specially in erc-fill
From: |
F. Jason Park |
Subject: |
master f8af241192b 10/12: Treat previous/next-line specially in erc-fill-wrap |
Date: |
Fri, 13 Oct 2023 10:49:37 -0400 (EDT) |
branch: master
commit f8af241192bc6ecff694f1c98002c353a06df4b0
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Treat previous/next-line specially in erc-fill-wrap
* lisp/erc/erc-fill.el (erc-fill-wrap-visual-keys): Mention option
`erc-fill-wrap-force-screen-line-movement' in doc string.
(erc-fill-wrap-force-screen-line-movement): New option to suppress
logical-line movement with `previous-line' and `next-line' when
`erc-fill-wrap-mode' is enabled.
(erc-fill--wrap-move): Accept trailing args.
(erc-fill--wrap-previous-line, erc-fill--wrap-next-line): Use
`erc-fill--wrap-move', like all the other `fill-wrap' commands.
(Bug#60936)
---
lisp/erc/erc-fill.el | 50 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/lisp/erc/erc-fill.el b/lisp/erc/erc-fill.el
index 4ec58fcb96f..3f5c8377868 100644
--- a/lisp/erc/erc-fill.el
+++ b/lisp/erc/erc-fill.el
@@ -238,11 +238,23 @@ A value of t tells ERC to use movement commands defined by
`visual-line-mode' everywhere in an ERC buffer along with visual
editing commands in the input area. A value of nil means to
never do so. A value of `non-input' tells ERC to act like the
-value is nil in the input area and t elsewhere. This option only
-plays a role when `erc-fill-wrap-mode' is enabled."
+value is nil in the input area and t elsewhere. See related
+option `erc-fill-wrap-force-screen-line-movement' for behavior
+involving `next-line' and `previous-line'."
:package-version '(ERC . "5.6") ; FIXME sync on release
:type '(choice (const nil) (const t) (const non-input)))
+(defcustom erc-fill-wrap-force-screen-line-movement '(non-input)
+ "Exceptions for vertical movement by logical line.
+Including a symbol known to `erc-fill-wrap-visual-keys' in this
+set tells `next-line' and `previous-line' to move vertically by
+screen line even if the current `erc-fill-wrap-visual-keys' value
+would normally do otherwise. For example, setting this to
+\\='(nil non-input) disables logical-line movement regardless of
+the value of `erc-fill-wrap-visual-keys'."
+ :package-version '(ERC . "5.6") ; FIXME sync on release
+ :type '(set (const nil) (const non-input)))
+
(defcustom erc-fill-wrap-merge t
"Whether to consolidate messages from the same speaker.
This tells ERC to omit redundant speaker labels for subsequent
@@ -250,13 +262,13 @@ messages less than a day apart."
:package-version '(ERC . "5.6") ; FIXME sync on release
:type 'boolean)
-(defun erc-fill--wrap-move (normal-cmd visual-cmd arg)
- (funcall (pcase erc-fill--wrap-visual-keys
- ('non-input
- (if (>= (point) erc-input-marker) normal-cmd visual-cmd))
- ('t visual-cmd)
- (_ normal-cmd))
- arg))
+(defun erc-fill--wrap-move (normal-cmd visual-cmd &rest args)
+ (apply (pcase erc-fill--wrap-visual-keys
+ ('non-input
+ (if (>= (point) erc-input-marker) normal-cmd visual-cmd))
+ ('t visual-cmd)
+ (_ normal-cmd))
+ args))
(defun erc-fill--wrap-kill-line (arg)
"Defer to `kill-line' or `kill-visual-line'."
@@ -287,17 +299,23 @@ Basically mimic what `move-beginning-of-line' does with
invisible text."
(defun erc-fill--wrap-previous-line (&optional arg try-vscroll)
"Move to ARGth previous logical or screen line."
(interactive "^p\np")
- (if erc-fill--wrap-visual-keys
- (with-no-warnings (previous-line arg try-vscroll))
- (prog1 (previous-logical-line arg try-vscroll)
- (erc-fill--wrap-escape-hidden-speaker))))
+ ;; Return value seems undefined but preserve anyway just in case.
+ (prog1
+ (let ((visp (memq erc-fill--wrap-visual-keys
+ erc-fill-wrap-force-screen-line-movement)))
+ (erc-fill--wrap-move (if visp #'previous-line #'previous-logical-line)
+ #'previous-line
+ arg try-vscroll))
+ (erc-fill--wrap-escape-hidden-speaker)))
(defun erc-fill--wrap-next-line (&optional arg try-vscroll)
"Move to ARGth next logical or screen line."
(interactive "^p\np")
- (if erc-fill--wrap-visual-keys
- (with-no-warnings (next-line arg try-vscroll))
- (next-logical-line arg try-vscroll)))
+ (let ((visp (memq erc-fill--wrap-visual-keys
+ erc-fill-wrap-force-screen-line-movement)))
+ (erc-fill--wrap-move (if visp #'next-line #'next-logical-line)
+ #'next-line
+ arg try-vscroll)))
(defun erc-fill--wrap-end-of-line (arg)
"Defer to `move-end-of-line' or `end-of-visual-line'."
- master updated (bd297132016 -> baf778c7caa), F. Jason Park, 2023/10/13
- master 328a985651a 01/12: Skip post-minibuffer restore in erc-scrolltobottom-all, F. Jason Park, 2023/10/13
- master 9120d7a32ea 02/12: Honor nil values in erc--restore-initialize-priors, F. Jason Park, 2023/10/13
- master d46c016fbd0 03/12: Sort and dedupe when loading modules in erc-open, F. Jason Park, 2023/10/13
- master a4bae965e06 07/12: Easily excise list-valued text prop members in ERC, F. Jason Park, 2023/10/13
- master c68dc7786fc 08/12: Manage some text props for ERC insertion-hook members, F. Jason Park, 2023/10/13
- master f8af241192b 10/12: Treat previous/next-line specially in erc-fill-wrap,
F. Jason Park <=
- master 5e2be1e0ba6 09/12: Swap hook positions of erc-fill and erc-match-message, F. Jason Park, 2023/10/13
- master 1950ddebacb 04/12: Allow spoofing process marker in erc-display-line-1, F. Jason Park, 2023/10/13
- master 9c2f99b7d73 05/12: Use erc-display-message instead of erc-make-notice, F. Jason Park, 2023/10/13
- master baf778c7caa 12/12: More defcustom fixes in ERC (Bug#66520), F. Jason Park, 2023/10/13
- master f97fdf5e50e 06/12: Deprecate option erc-remove-parsed-property, F. Jason Park, 2023/10/13
- master 52af0a5fb97 11/12: Add command to refill buffer in erc-fill-wrap-mode, F. Jason Park, 2023/10/13