使用したい関数は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.
0
ページの上部に移動するには a を、ページの下部に移動するには 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)