aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorSpencer Baugh2024-09-10 14:18:39 -0400
committerDmitry Gutov2024-09-27 04:27:55 +0300
commite776903b31cf2b2d21d91cbc7d6b7dbc1e9d442f (patch)
treec0752ebde2259d01c64ad3f04c5de191335c4e50 /lisp
parentda1416fc6998718d1e36e32961b4415045949632 (diff)
downloademacs-e776903b31cf2b2d21d91cbc7d6b7dbc1e9d442f.tar.gz
emacs-e776903b31cf2b2d21d91cbc7d6b7dbc1e9d442f.zip
Move to start of current header in diff-{file,hunk}-prev
If point was after a file or hunk header, the diff-file-prev and diff-hunk-prev commands would move to the start of that header. But if point was *within* the header, they would not move, and would report "No previous file" or "No previous hunk". This differs from the behavior of most other movement commands, e.g. backward-sexp or backward-sentence. This commit fixes diff-file-prev and diff-hunk-prev, as well as other easy-mmode-define-navigation BASE-prev commands. Now these commands move to the start of the containing "thing" just like other movement commands. * lisp/emacs-lisp/easy-mmode.el (easy-mmode--prev): Move to start of current match first. (bug#73172) * etc/NEWS: Document the behavior change.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/easy-mmode.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index d3dcab899d6..7a94d832273 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -772,6 +772,17 @@ ENDFUN and NARROWFUN are treated like in `easy-mmode-define-navigation'."
772 (unless count (setq count 1)) 772 (unless count (setq count 1))
773 (if (< count 0) (easy-mmode--next re name (- count) endfun narrowfun) 773 (if (< count 0) (easy-mmode--next re name (- count) endfun narrowfun)
774 (let ((re-narrow (and narrowfun (prog1 (buffer-narrowed-p) (widen))))) 774 (let ((re-narrow (and narrowfun (prog1 (buffer-narrowed-p) (widen)))))
775 ;; If point is inside a match for RE, move to its beginning like
776 ;; `backward-sexp' and other movement commands.
777 (when (and (not (zerop count))
778 (save-excursion
779 ;; Make sure we're out of the current match if any.
780 (goto-char (if (re-search-backward re nil t 1)
781 (match-end 0) (point-min)))
782 (re-search-forward re nil t 1))
783 (< (match-beginning 0) (point) (match-end 0)))
784 (goto-char (match-beginning 0))
785 (setq count (1- count)))
775 (unless (re-search-backward re nil t count) 786 (unless (re-search-backward re nil t count)
776 (user-error "No previous %s" name)) 787 (user-error "No previous %s" name))
777 (when re-narrow (funcall narrowfun))))) 788 (when re-narrow (funcall narrowfun)))))