[gnu.emacs] automatic horizontal scrolling

stef@lebourget (Stephane Payrard - Sun France Consulting) (08/17/89)

        Hi


I feel that an interesting feature is missing in gnuemacs: automatic
horizontal scrolling when the line is truncated and the point move
past the truncation. I feel boring to be obliged to explicitly scroll
the window in such a case. More, it is not homogenous with the general
behavior of emacs: when you move the point in a not currrently visible
part of a line, emacs scrolls vertically to show the line with the
point. I should expect such a similar behavior when the point is moved
horizontally outside the current view.
 It would be useful with very horizontally large form.

A subsidiary (and optional) feature should be to scroll simultaneously
each (or some) view (ie window) on the same buffer. With such a feature one
could have a view with the title of a tabular form with the fields in a
same form's row correctly aligned.

An example of a display with two views with an identical horizontal shift.


column10  |  column 11 |
--**-Emacs: tabular_file            (Text)----Top-----
apple     |  pie       |
orange    |  cake      |
--**-Emacs: tabular_file            (Text)----Bot-----


Is there a good reason not to implement this stuff?
May be it  is already implemented in a way or another.
Any comment or suggestion appreciated


        stef
        
        Stephane Payrard
        Sun Microsystems France


PS: i am new and self-teached to news (and gnews), so excuse me (and
correct me) if I don't use them correctly or if this discussion has
already been raised.

lrs@indetech.uucp (Lynn Slater) (08/24/89)

> I feel that an interesting feature is missing in gnuemacs: automatic
> horizontal scrolling 

I have some of this in an enhanced picture mode. point-wysiwyg directly
addresses your wish. This and other core functions are included below.

(defun move-to-column-force (column)
  "Move to column COLUMN in current line.
Differs from move-to-column in that it creates or modifies whitespace
if necessary to attain exactly the specified column.

This version (non-standard) insures that the column is visible,
scrolling if needed."
  (move-to-column column)
  (let ((col (current-column)))
    (if (< col column)
        (indent-to column)
      (if (and (/= col column)
               (= (preceding-char) ?\t))
          (let (indent-tabs-mode)
            (delete-char -1)
            (indent-to col)
            (move-to-column column)))))
  (point-wysiwyg)
  )

(defun point-wysiwyg ()
  "scrolls the window horozontally to make point visible"
  (let*  ((min (window-hscroll))
          (max (- (+ min (window-width)) 2))
          (here (current-column))
          (delta (/ (window-width) 2))
          )
    (if (< here min)
        (scroll-right (max 0 (+ (- min here) delta)))
      (if (>= here  max)
          (scroll-left (- (- here min) delta))
        ))))
  
(defun window-wysiwyg-point ()
  "Makes point become the visible point
   Moves point, not the scroll.
   Current version good only for picture mode"
  (interactive)
  (let*  ((min (window-hscroll))
          (max (+ min (window-width)))
          (here (current-column))
          (delta (/ (window-width) 2))
          )
    (if (< here min)
        (move-to-column min)
      (if (>= here  max)
          (move-to-column (- max 3))
        ))))


Now, you just have to get point-wysiwyg called from all commands that move
point. :->  I have done this for a variant of picture mode.  There is
probably a general way to associate this with the truncate line variable so
that if lines are not truncated, point-wysiwig is called by the lower level
code, but I have not explored this.

===============================================================
Lynn Slater -- {sun, ames, pacbell}!indetech!lrs or lrs@indetech.uucp
42075 Lawrence Place, Fremont Ca 94538
Office (415) 438-2048; Home (415) 796-4149; Fax (415) 438-2034
===============================================================
-- 
===============================================================
Lynn Slater -- {sun, ames, pacbell}!indetech!lrs or lrs@indetech.uucp
42075 Lawrence Place, Fremont Ca 94538
Office (415) 438-2048; Home (415) 796-4149; Fax (415) 438-2034