[gnu.emacs.bug] Looking for an insert at column function

lrs@AI.MIT.EDU (Lynn Slater) (06/20/89)

On insertion at a specific column:
The fcns
  (move-to-dolumn nn)
  (insert ...)
Will insert at the specific column, provided it exists.

I have another fcn that will make sure that the column exists.

(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-wisiwig)
  )


(defun point-wisiwig ()
  "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))
        ))))	

===============================================================
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
===============================================================