您希望使用的函数是move-to-window-line
,其定义是:
move-to-window-line is an interactive built-in function in `C source
code'.
It is bound to M-r.
(move-to-window-line arg)
Position point relative to window.
With no argument, position point at center of window.
An argument specifies vertical position within the window;
zero means top of window, negative means relative to bottom of window.
您可以使用 a 来调用它0
以转到页面顶部,并使用 a 来调用它以转到页面-1
底部。这些可以绑定到具有匿名函数或命名函数的键。给出了两者的例子。
匿名函数
(global-set-key [(f4)] (function
(lambda ()
"Go to top of page."
(interactive)
(move-to-window-line 0))))
(global-set-key [(f4)] (function
(lambda ()
"Go to bottom of page."
(interactive)
(move-to-window-line -1))))
命名函数
(defun my-top-of-page ()
"Go to top of page."
(interactive)
(move-to-window-line 0))
(defun my-bottom-of-page ()
"Go to bottom of page."
(interactive)
(move-to-window-line -1))
(global-set-key [(f4)] 'my-top-of-page)
(global-set-key [(shift f4)] 'my-bottom-of-page)