From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#45147: Org-like cycling in outline-minor-mode Date: Wed, 19 May 2021 19:14:47 +0300 Organization: LINKOV.NET Message-ID: <87y2cayfmw.fsf@mail.linkov.net> References: <874kkuyhfx.fsf@mail.linkov.net> <87wnuoaw60.fsf@mail.linkov.net> <87zgwullsb.fsf@gnus.org> <87im3i7efm.fsf@mail.linkov.net> <87cztplaya.fsf@gnus.org> <87y2cc0xeh.fsf@mail.linkov.net> <8335uirkjm.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27607"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: larsi@gnus.org, 45147@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 19 18:54:23 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ljPSg-000741-K1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 18:54:22 +0200 Original-Received: from localhost ([::1]:57054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljPSf-0001sU-I4 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 12:54:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljP78-0006IM-0C for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 12:32:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljP74-00063k-Hw for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 12:32:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ljP74-0000Cj-Da for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 12:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 May 2021 16:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45147 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45147-submit@debbugs.gnu.org id=B45147.1621441920774 (code B ref 45147); Wed, 19 May 2021 16:32:02 +0000 Original-Received: (at 45147) by debbugs.gnu.org; 19 May 2021 16:32:00 +0000 Original-Received: from localhost ([127.0.0.1]:60566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljP71-0000CP-UJ for submit@debbugs.gnu.org; Wed, 19 May 2021 12:32:00 -0400 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:42621) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljP6z-0000Bu-2M for 45147@debbugs.gnu.org; Wed, 19 May 2021 12:31:57 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 6B8B824000E; Wed, 19 May 2021 16:31:50 +0000 (UTC) In-Reply-To: <8335uirkjm.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 19 May 2021 15:10:37 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:206902 Archived-At: --=-=-= Content-Type: text/plain >> +(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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=describe-bindings-outline.patch 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 "\\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. --=-=-=--