From: Lars Ingebrigtsen Date: Sun, 31 Oct 2021 17:59:49 +0000 (+0100) Subject: Add 'n'/'p' key bindings in *Help* buffers X-Git-Tag: emacs-29.0.90~3671^2~325 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=38751a8585bf320983b78e0b654c1ffc9addbd2f;p=emacs.git Add 'n'/'p' key bindings in *Help* buffers * lisp/help-mode.el (help-goto-previous-page): New command and key binding. (help-goto-previous-page): Ditto. --- diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index d1329d561c1..4a6d20e0599 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi @@ -459,6 +459,14 @@ Move point back to the previous hyperlink (@code{backward-button}). @item mouse-1 @itemx mouse-2 Follow a hyperlink that you click on. +@item n +@itemx p +Some help pages (like the list of key bindings you get with @kbd{C-h +b}) are divided into pages (by the @samp{^L} character). The @kbd{n} +(@code{help-goto-next-page}) command will take you to the start of the +next page, and the @kbd{p} (@code{help-goto-previous-page}) command +will take you to the start of the previous page, or (if point isn't at +the start of the current page) to the start of the current page. @item C-c C-c Show all documentation about the symbol at point (@code{help-follow-symbol}). diff --git a/etc/NEWS b/etc/NEWS index 546f8d11392..e7360d267dc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -53,6 +53,10 @@ time. Jumping to source from "*Help*" buffer moves the point when the source buffer is already open. Now, the old point is pushed to mark ring. ++++ +*** New key bindings in *Help* buffers: 'n' and 'p'. +These will take you (respectively) to the next and previous "page". + ** Fonts --- diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 53acbf97e7d..83e783bdd73 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -35,6 +35,8 @@ (let ((map (make-sparse-keymap))) (set-keymap-parent map (make-composed-keymap button-buffer-map special-mode-map)) + (define-key map "n" 'help-goto-next-page) + (define-key map "p" 'help-goto-previous-page) (define-key map "l" 'help-go-back) (define-key map "r" 'help-go-forward) (define-key map "\C-c\C-b" 'help-go-back) @@ -806,6 +808,26 @@ See `help-make-xrefs'." (help-xref-go-forward (current-buffer)) (user-error "No next help buffer"))) +(defun help-goto-next-page () + "Go to the next page (if any) in the current buffer. +The help buffers are divided into \"pages\" by the ^L character." + (interactive) + (push-mark) + (forward-page) + (unless (eobp) + (forward-line 1))) + +(defun help-goto-previous-page () + "Go to the previous page (if any) in the current buffer. +(If not at the start of a page, go to the start of the current page.) + +The help buffers are divided into \"pages\" by the ^L character." + (interactive) + (push-mark) + (backward-page (if (looking-back "\f\n" (- (point) 5)) 2 1)) + (unless (bobp) + (forward-line 1))) + (defun help-view-source () "View the source of the current help item." (interactive nil help-mode)