From 0bc458fc81fe82ce16a751095440339713c059ea Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Wed, 28 May 2025 10:16:02 -0700 Subject: [PATCH] ; Remove superfluous POSITION argument from 'visual-wrap--apply-to-line' * lisp/visual-wrap.el (visual-wrap--apply-to-line): Remove POSITION and just use point instead. Update caller. (cherry picked from commit 38c57855ae2b5d4245bce0bb444ee86c35dfcdc5) --- lisp/visual-wrap.el | 46 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el index c8ae6f8f376..24ca8ae7cf4 100644 --- a/lisp/visual-wrap.el +++ b/lisp/visual-wrap.el @@ -143,29 +143,27 @@ members of `visual-wrap--safe-display-specs' (which see)." (t ""))))) -(defun visual-wrap--apply-to-line (position) - "Apply visual-wrapping properties to the logical line starting at POSITION." - (save-excursion - (goto-char position) - (when-let ((first-line-prefix (fill-match-adaptive-prefix)) - (next-line-prefix (visual-wrap--content-prefix - first-line-prefix position))) - (when (numberp next-line-prefix) - ;; Set a minimum width for the prefix so it lines up correctly - ;; with subsequent lines. Make sure not to do this past the end - ;; of the line though! (`fill-match-adaptive-prefix' could - ;; potentially return a prefix longer than the current line in - ;; the buffer.) - (add-display-text-property - position (min (+ position (length first-line-prefix)) - (pos-eol)) - 'min-width `((,next-line-prefix . width)))) - (setq next-line-prefix (visual-wrap--adjust-prefix next-line-prefix)) - (put-text-property - position (pos-eol) 'wrap-prefix - (if (numberp next-line-prefix) - `(space :align-to (,next-line-prefix . width)) - next-line-prefix))))) +(defun visual-wrap--apply-to-line () + "Apply visual-wrapping properties to the logical line starting at point." + (when-let* ((first-line-prefix (fill-match-adaptive-prefix)) + (next-line-prefix (visual-wrap--content-prefix + first-line-prefix (point)))) + (when (numberp next-line-prefix) + ;; Set a minimum width for the prefix so it lines up correctly + ;; with subsequent lines. Make sure not to do this past the end + ;; of the line though! (`fill-match-adaptive-prefix' could + ;; potentially return a prefix longer than the current line in the + ;; buffer.) + (add-display-text-property + (point) (min (+ (point) (length first-line-prefix)) + (pos-eol)) + 'min-width `((,next-line-prefix . width)))) + (setq next-line-prefix (visual-wrap--adjust-prefix next-line-prefix)) + (put-text-property + (point) (pos-eol) 'wrap-prefix + (if (numberp next-line-prefix) + `(space :align-to (,next-line-prefix . width)) + next-line-prefix)))) (defun visual-wrap--content-prefix (prefix position) "Get the next-line prefix for the specified first-line PREFIX. @@ -254,7 +252,7 @@ by `visual-wrap-extra-indent'." ;; If so, we can apply our visual wrapping properties to this ;; line and continue to the next line. (progn - (visual-wrap--apply-to-line (point)) + (visual-wrap--apply-to-line) (forward-line)) ;; Otherwise, skip ahead until the end of any unsafe display ;; properties. NOTE: We do this out of an abundance of caution to -- 2.39.5