# HG changeset patch # User Richard M. Stallman # Date 1008475000 0 # Node ID f38a270798ca6fef525a7dc4d88ed2c4fe35d7dd # Parent 6612a220ef841be8245de148a41d004a0502f0af (isearch-start-hscroll): New variable. (isearch-mode): Set isearch-start-hscroll. (isearch-update): Restore original hscrolling if possible. diff -r 6612a220ef84 -r f38a270798ca lisp/isearch.el --- a/lisp/isearch.el Sun Dec 16 03:53:15 2001 +0000 +++ b/lisp/isearch.el Sun Dec 16 03:56:40 2001 +0000 @@ -366,6 +366,7 @@ (defvar isearch-wrapped nil) ; Searching restarted from the top (bottom). (defvar isearch-barrier 0) (defvar isearch-just-started nil) +(defvar isearch-start-hscroll 0) ; hscroll when starting the search. ; case-fold-search while searching. ; either nil, t, or 'yes. 'yes means the same as t except that mixed @@ -557,6 +558,7 @@ isearch-other-end nil isearch-small-window nil isearch-just-started t + isearch-start-hscroll (window-hscroll) isearch-opoint (point) search-ring-yank-pointer nil @@ -636,8 +638,13 @@ (window-hscroll)) (set-window-hscroll (selected-window) 0)) (other-window 1)) - (goto-char found-point))) - (if isearch-other-end + (goto-char found-point)) + ;; Keep same hscrolling as at the start of the search when possible + (let ((current-scroll (window-hscroll))) + (set-window-hscroll (selected-window) isearch-start-hscroll) + (unless (pos-visible-in-window-p) + (set-window-hscroll (selected-window) current-scroll)))) + (if isearch-other-end (if (< isearch-other-end (point)) ; isearch-forward? (isearch-highlight isearch-other-end (point)) (isearch-highlight (point) isearch-other-end))