bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hscrolling during isearch


From: Per Starback
Subject: hscrolling during isearch
Date: Thu, 13 Dec 2001 21:55:28 +0100

GNU Emacs 21.1:

This is not really a bug, but something I think should work
differently.

On a 24x80 tty

        $ emacs-21.1 -q
        M-x toggle-truncate-lines RET
        C-u 9 9 SPC f RET C-u 7 0 SPC f o o C-a C-p

Now everything is set up.  I see that "foo" in the window and I want
to go there with an isearch:

        C-s f o o RET

I get there alright, but because of that "f" the window is hscrolled,
which makes me disoriented for awhile.  Since I saw the foo on the
screen before the search I visualized getting there without any
scrolling.

I suggest isearches revert to the hscroll that is at the start of the
search when possible.  Like this:

2001-12-13  Per Starback  <starback@ling.uu.se>

        * isearch.el (isearch-start-hscroll): New variable.
        (isearch-mode, isearch-update): Use it, to revert to same hscroll
        position as before the isearch, when possible.


*** isearch.el.~1.204~  Thu Dec 13 21:32:05 2001
--- isearch.el  Thu Dec 13 21:34:57 2001
***************
*** 366,371 ****
--- 366,372 ----
  (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,562 ****
--- 558,564 ----
        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
***************
*** 614,649 ****
  
  (defun isearch-update ()
    ;; Called after each command to update the display.  
!   (if (null unread-command-events)
!       (progn
!         (if (not (input-pending-p))
!             (isearch-message))
!         (if (and isearch-slow-terminal-mode
!                  (not (or isearch-small-window 
!                           (pos-visible-in-window-p))))
!             (let ((found-point (point)))
!               (setq isearch-small-window t)
!               (move-to-window-line 0)
!               (let ((window-min-height 1))
!                 (split-window nil (if (< search-slow-window-lines 0)
!                                       (1+ (- search-slow-window-lines))
!                                     (- (window-height)
!                                        (1+ search-slow-window-lines)))))
!               (if (< search-slow-window-lines 0)
!                   (progn (vertical-motion (- 1 search-slow-window-lines))
!                          (set-window-start (next-window) (point))
!                          (set-window-hscroll (next-window)
!                                              (window-hscroll))
!                          (set-window-hscroll (selected-window) 0))
!                 (other-window 1))
!               (goto-char found-point)))
!         (if isearch-other-end
!             (if (< isearch-other-end (point)) ; isearch-forward?
!                 (isearch-highlight isearch-other-end (point))
!               (isearch-highlight (point) isearch-other-end))
!           (isearch-dehighlight nil))
!         ))
!   (setq ;; quit-flag nil  not for isearch-mode
     isearch-adjusted nil
     isearch-yank-flag nil)
    (isearch-lazy-highlight-new-loop)
--- 616,654 ----
  
  (defun isearch-update ()
    ;; Called after each command to update the display.  
!   (unless unread-command-events
!     (unless (input-pending-p)
!       (isearch-message))
!     (if (and isearch-slow-terminal-mode
!            (not (or isearch-small-window 
!                     (pos-visible-in-window-p))))
!       (let ((found-point (point)))
!         (setq isearch-small-window t)
!         (move-to-window-line 0)
!         (let ((window-min-height 1))
!           (split-window nil (if (< search-slow-window-lines 0)
!                                 (1+ (- search-slow-window-lines))
!                               (- (window-height)
!                                  (1+ search-slow-window-lines)))))
!         (if (< search-slow-window-lines 0)
!             (progn (vertical-motion (- 1 search-slow-window-lines))
!                    (set-window-start (next-window) (point))
!                    (set-window-hscroll (next-window)
!                                        (window-hscroll))
!                    (set-window-hscroll (selected-window) 0))
!           (other-window 1))
!         (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))
!       (isearch-dehighlight nil)))
!   (setq       ;; quit-flag nil  not for isearch-mode
     isearch-adjusted nil
     isearch-yank-flag nil)
    (isearch-lazy-highlight-new-loop)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]