Function: array-maybe-scroll-horizontally

array-maybe-scroll-horizontally is a byte-compiled function defined in array.el.gz.

Signature

(array-maybe-scroll-horizontally)

Documentation

If necessary, scroll horizontally to keep the cursor in view.

Source Code

;; Defined in /usr/src/emacs/lisp/array.el.gz
(defun array-maybe-scroll-horizontally ()
  "If necessary, scroll horizontally to keep the cursor in view."
  ;; This is only called from array-normalize-cursor so
  ;;  array-buffer-column will always be current.
  (let ((w-hscroll (window-hscroll))
	(w-width (window-width)))
    (cond
     ((and (>= array-buffer-column w-hscroll)
	   (<= array-buffer-column (+ w-hscroll w-width)))
      ;; It's already visible.  Do nothing.
      nil)
     ((> array-buffer-column (+ w-hscroll w-width))
      ;; It's to the right.  Scroll left.
      (scroll-left (- (- array-buffer-column w-hscroll)
		      (/ w-width 2))))
     (t
      ;; It's to the left.  Scroll right.
      (scroll-right (+ (- w-hscroll array-buffer-column)
		       (/ w-width 2)))))))