Emacs: scroll buffer not point

后端 未结 5 1065
心在旅途
心在旅途 2020-12-28 16:53

Is it possible to scroll the entire visible portion of the buffer in Emacs, but leave point where it is. Example: point is towards the bottom of the window and I want to see

5条回答
  •  执念已碎
    2020-12-28 17:39

    ;;;_*======================================================================
    ;;;_* define a function to scroll with the cursor in place, moving the
    ;;;_* page instead
    ;; Navigation Functions
    (defun scroll-down-in-place (n)
      (interactive "p")
      (previous-line n)
      (unless (eq (window-start) (point-min))
        (scroll-down n)))
    
    (defun scroll-up-in-place (n)
      (interactive "p")
      (next-line n)
      (unless (eq (window-end) (point-max))
        (scroll-up n)))
    
    (global-set-key "\M-n" 'scroll-up-in-place)
    (global-set-key "\M-p" 'scroll-down-in-place)
    

提交回复
热议问题