unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, 45147@debbugs.gnu.org
Subject: bug#45147: Org-like cycling in outline-minor-mode
Date: Wed, 19 May 2021 19:14:47 +0300	[thread overview]
Message-ID: <87y2cayfmw.fsf@mail.linkov.net> (raw)
In-Reply-To: <8335uirkjm.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 19 May 2021 15:10:37 +0300")

[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]

>> +(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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: describe-bindings-outline.patch --]
[-- Type: text/x-diff, Size: 1896 bytes --]

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.

  reply	other threads:[~2021-05-19 16:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 19:15 bug#45147: Org-like cycling in outline-minor-mode Juri Linkov
2020-12-09 20:03 ` Juri Linkov
2020-12-14 20:35   ` Juri Linkov
2020-12-16 20:28     ` Juri Linkov
2021-03-03 19:12 ` Juri Linkov
2021-05-16 15:51   ` Lars Ingebrigtsen
2021-05-16 17:53     ` Juri Linkov
2021-05-17 13:57       ` Lars Ingebrigtsen
2021-05-18 20:12         ` Juri Linkov
2021-05-19 12:10           ` Eli Zaretskii
2021-05-19 16:14             ` Juri Linkov [this message]
2021-05-19 17:28               ` Eli Zaretskii
2021-05-20 18:37                 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2cayfmw.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=45147@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).