【发布时间】:2012-01-24 19:55:33
【问题描述】:
是否可以在 Emacs 中滚动缓冲区的整个可见部分,但保留原点。示例:点位于窗口底部,我想看到一些文本从窗口顶部滚动而没有移动点。
编辑:我想C-l C-l 可以满足我的需求。
【问题讨论】:
-
C-l清屏 -
在终端中,是的,但不是在 Emacs 中。
标签: emacs
是否可以在 Emacs 中滚动缓冲区的整个可见部分,但保留原点。示例:点位于窗口底部,我想看到一些文本从窗口顶部滚动而没有移动点。
编辑:我想C-l C-l 可以满足我的需求。
【问题讨论】:
C- l 清屏
标签: emacs
试试这些。根据您的喜好更改 M-n 和 M-p 键绑定
;;; scrollers
(global-set-key "\M-n" "\C-u1\C-v")
(global-set-key "\M-p" "\C-u1\M-v")
【讨论】:
(global-set-key "\M-n" (lambda () (interactive) (scroll-up 4)) ) 和 (global-set-key "\M-p" (lambda () (interactive) (scroll-down 4)) )。
;;;_*======================================================================
;;;_* 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)
【讨论】:
(previous-line n) 替换为(forward-line (* -1 n)) 并将(next-line n) 替换为(forward-line n)
previous-line 和 next-line,否则它会跳两行
M-p 和 M-n 通常保留给其他东西,我将它们绑定到 C-S-y 和 C-S-e 因为它们与 Vim 的 CTRL_e 和 CTRL_y 大致相同.
这可能有用。根据滚动页面上的EmacsWiki;
变量
scroll-preserve-screen-position可能对某些人有用。 当您向下滚动并再次向上滚动时,点应该以相同的方式结束 你开始的位置。该值可以由内置切换 在M-x scroll-lock-mode模式下。
【讨论】:
我认为这样更好:
(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)
参考: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)
【讨论】:
根据 Bilal 的回答:
(global-set-key [(meta down)] (lambda () (interactive) (scroll-down 1)))
(global-set-key [(meta up)] (lambda () (interactive) (scroll-up 1)))
【讨论】: