GNU bug report logs - #45147
Org-like cycling in outline-minor-mode

Previous Next

Package: emacs;

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 #33 received at 45147 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 45147 <at> debbugs.gnu.org
Subject: Re: bug#45147: Org-like cycling in outline-minor-mode
Date: Tue, 18 May 2021 23:12:46 +0300
[Message part 1 (text/plain, inline)]
> I think you could push it anyway...  but I think enabling outline mode
> (by default) in describe-bindings would be controversial, so I think
> there should be a user option for that behaviour.

This patch adds a new user option ‘describe-bindings-after-hook’
(and also removes ‘describe-bindings-internal’ obsolete since 24.4):

[describe-bindings-after-hook.patch (text/x-diff, inline)]
diff --git a/lisp/help.el b/lisp/help.el
index babaf4adc7..7caf080dca 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -561,6 +561,13 @@ help--key-description-fontified
               'font-lock-face 'help-key-binding
               'face 'help-key-binding))
 
+(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")
+
 (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,23 +585,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)
+      (run-hooks 'describe-bindings-after-hook))))
 
-(defun describe-bindings-internal (&optional menus prefix)
-  "Show a list of all defined keys, and their definitions.
-We put that list in a buffer, and display the buffer.
-
-The optional argument MENUS, if non-nil, says to mention menu bindings.
-\(Ordinarily these are omitted from the output.)
-The optional argument PREFIX, if non-nil, should be a key sequence;
-then we display only bindings that start with that prefix."
-  (declare (obsolete describe-buffer-bindings "24.4"))
-  (let ((buf (current-buffer)))
-    (with-help-window (help-buffer)
-      ;; Be aware that `describe-buffer-bindings' puts its output into
-      ;; the current buffer.
-      (with-current-buffer (help-buffer)
-	(describe-buffer-bindings buf prefix menus)))))
+(defun describe-bindings-outline ()
+  "Hook to enable outlines in the output buffer of `describe-bindings'."
+  (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
+               "\\<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 where-is (definition &optional insert)
   "Print message listing key sequences that invoke the command DEFINITION.

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.