From: F. Jason Park Date: Mon, 9 Oct 2023 09:29:44 +0000 (-0700) Subject: Treat previous/next-line specially in erc-fill-wrap X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f8af241192bc6ecff694f1c98002c353a06df4b0;p=emacs.git 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) --- 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'."