简体   繁体   English

Emacs:滚动缓冲区未指向

[英]Emacs: scroll buffer not point

Is it possible to scroll the entire visible portion of the buffer in Emacs, but leave point where it is.是否可以滚动 Emacs 中缓冲区的整个可见部分,但将点留在原处。 Example: point is towards the bottom of the window and I want to see some text which has scrolled off the top of the window without moving point.示例:点指向 window 的底部,我想看到一些文本在没有移动点的情况下从 window 的顶部滚动。

Edit: I suppose Cl Cl sort of does what I wanted.编辑:我想Cl Cl有点像我想要的那样。

try these. 尝试这些。 Change Mn and Mp key bindings according to your taste 根据您的口味改变MnMp键绑定

;;; scrollers
(global-set-key "\M-n" "\C-u1\C-v")
(global-set-key "\M-p" "\C-u1\M-v")

This might be of use. 这可能是有用的。 According to the EmacsWiki page on Scrolling; 根据滚动的EmacsWiki页面;

The variable scroll-preserve-screen-position may be useful to some. 可变scroll-preserve-screen-position可能对某些人有用。 When you scroll down, and up again, point should end up at the same position you started out with. 当您向下滚动并向上滚动时,点应该在您开始时的相同位置结束。 The value can be toggled by the built in mode Mx scroll-lock-mode . 可以通过内置模式Mx scroll-lock-mode切换该值。

;;;_*======================================================================
;;;_* 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)

I think this is better: 我认为这更好:

(defun gcm-scroll-down ()
      (interactive)
      (scroll-up 1))
    (defun gcm-scroll-up ()
      (interactive)
      (scroll-down 1))
    (global-set-key [(control down)] 'gcm-scroll-down)
    (global-set-key [(control up)]   'gcm-scroll-up)

reference : emacs wiki 参考: emacs wiki

;; Preserve the cursor position relative to the screen when scrolling
(setq scroll-preserve-screen-position 'always)

;; Scroll buffer under the point
;; 'scroll-preserve-screen-position' must be set to a non-nil, non-t value for
;; these to work as intended.
(global-set-key (kbd "M-p") #'scroll-down-line)
(global-set-key (kbd "M-n") #'scroll-up-line)

Based on Bilal's answer:根据 Bilal 的回答:

(global-set-key [(meta down)] (lambda () (interactive) (scroll-down 1)))
(global-set-key [(meta up)] (lambda () (interactive) (scroll-up 1)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM