GNU bug report logs -
#45147
Org-like cycling in outline-minor-mode
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Wed, 9 Dec 2020 19:23:01 UTC
Severity: wishlist
Tags: fixed, patch
Fixed in version 28.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #39 received at 45147 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>> +(defcustom describe-bindings-after-hook '(describe-bindings-outline)
>> + "Hook run at the end of `describe-bindings'."
>> + :type 'hook
>> + :options '(describe-bindings-outline)
>> + :group 'help
>> + :version "28.1")
>
> What's the rationale for populating the hook by default? That's not
> what we normally do: hooks are for Lisp programs to use, not for the
> core functionality to invoke itself.
This was an attempt of generalization.
>> +(defun describe-bindings-outline ()
>> + "Hook to enable outlines in the output buffer of `describe-bindings'."
>
> First, this is not a hook.
>
> And second, if we want a feature whereby the buffer describing
> bindings could be put in Outline mode, why not offer a simple option
> for users to customize, not a hook for users to tweak? Once again,
> having user options that accept only function values is
> user-unfriendly.
Function values are user-friendly when their defcustom provides
human-readable tags.
But in this case it's fine to have a simple option like in this patch:
[describe-bindings-outline.patch (text/x-diff, inline)]
diff --git a/lisp/help.el b/lisp/help.el
index babaf4adc7..2409636b48 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -561,6 +561,12 @@ help--key-description-fontified
'font-lock-face 'help-key-binding
'face 'help-key-binding))
+(defcustom describe-bindings-outline t
+ "Non-nil enables outlines in the output buffer of `describe-bindings'."
+ :type 'boolean
+ :group 'help
+ :version "28.1")
+
(defun describe-bindings (&optional prefix buffer)
"Display a buffer showing a list of all defined keys, and their definitions.
The keys are displayed in order of precedence.
@@ -578,7 +584,26 @@ describe-bindings
;; Be aware that `describe-buffer-bindings' puts its output into
;; the current buffer.
(with-current-buffer (help-buffer)
- (describe-buffer-bindings buffer prefix))))
+ (describe-buffer-bindings buffer prefix)
+
+ (when describe-bindings-outline
+ (setq-local outline-regexp ".*:$")
+ (setq-local outline-heading-end-regexp ":\n")
+ (setq-local outline-level (lambda () 1))
+ (setq-local outline-minor-mode-cycle t
+ outline-minor-mode-highlight t)
+ (outline-minor-mode 1)
+ (save-excursion
+ (let ((inhibit-read-only t))
+ (goto-char (point-min))
+ (insert (substitute-command-keys
+ (concat "\\<outline-mode-cycle-map>Type "
+ "\\[outline-cycle] or \\[outline-cycle-buffer] "
+ "on headings to cycle their visibility.\n\n")))
+ ;; Hide the longest body
+ (when (and (re-search-forward "Key translations" nil t)
+ (fboundp 'outline-cycle))
+ (outline-cycle))))))))
(defun describe-bindings-internal (&optional menus prefix)
"Show a list of all defined keys, and their definitions.
This bug report was last modified 4 years and 83 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.