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: Tue, 18 May 2021 23:12:46 +0300 Organization: LINKOV.NET Message-ID: <87y2cc0xeh.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> 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="35680"; 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: 45147@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 18 22:37:10 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 1lj6Sk-0009B5-1O for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 May 2021 22:37:10 +0200 Original-Received: from localhost ([::1]:43362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj6Si-0000nO-RB for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 May 2021 16:37:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj6Ju-00039I-7A for bug-gnu-emacs@gnu.org; Tue, 18 May 2021 16:28:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lj6Jt-0007fo-Vq for bug-gnu-emacs@gnu.org; Tue, 18 May 2021 16:28:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lj6Jt-0000N3-T8 for bug-gnu-emacs@gnu.org; Tue, 18 May 2021 16:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 May 2021 20:28:01 +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.16213696471360 (code B ref 45147); Tue, 18 May 2021 20:28:01 +0000 Original-Received: (at 45147) by debbugs.gnu.org; 18 May 2021 20:27:27 +0000 Original-Received: from localhost ([127.0.0.1]:57400 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj6JL-0000Ls-8J for submit@debbugs.gnu.org; Tue, 18 May 2021 16:27:27 -0400 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:58793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lj6JJ-0000Lc-QD for 45147@debbugs.gnu.org; Tue, 18 May 2021 16:27:26 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 4E8D6C0005; Tue, 18 May 2021 20:27:17 +0000 (UTC) In-Reply-To: <87cztplaya.fsf@gnus.org> (Lars Ingebrigtsen's message of "Mon, 17 May 2021 15:57:33 +0200") 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:206838 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit > 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): --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=describe-bindings-after-hook.patch 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 + "\\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. --=-=-=--