unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Juri Linkov <juri@linkov.net>
Cc: Eli Zaretskii <eliz@gnu.org>, "larsi@gnus.org" <larsi@gnus.org>,
	Drew Adams <drew.adams@oracle.com>,
	"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [External] : Re: Consistent face for keys in *Help* and `substitute-command-keys'
Date: Tue, 9 Mar 2021 01:38:40 -0600	[thread overview]
Message-ID: <CADwFkm=C6Gz3NNZ+_SiXe+TYTPACXW8nSA6V-qQD+cBUTygi=g@mail.gmail.com> (raw)
In-Reply-To: <877dmhwnfu.fsf@mail.linkov.net>

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

Juri Linkov <juri@linkov.net> writes:

> It would be nice to keep the current face 'help-key-binding'
> even after adding links.

Yes, as it happens that is exactly what I'm currently experimenting
with.  See the attached patch if you want to try it out; I think the
effect is quite nice.

But I'm seeing bootstrap problems if I flip the new option here to t, so
we couldn't use it as the default in its current form.

[The problem is that the button type `help-function' is defined in
help-mode.el, but that file is not autoloaded (and help.el is).  There
are several ways to fix it, but I haven't yet had time to think about
which is better.  (For example, we could force the option to nil during
bootstrap.  Or we could just move the button definitions into its own
file or into help.el to make sure they are there during bootstrap.) ]

[-- Attachment #2: 0001-Add-new-option-help-link-key-to-documentation.patch --]
[-- Type: text/x-diff, Size: 3243 bytes --]

From 937e2ed9d7b5a1a43f199c8342ed9ee2aaa7cac8 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Fri, 5 Mar 2021 02:49:07 +0100
Subject: [PATCH] Add new option help-link-key-to-documentation

* lisp/help.el (help-link-key-to-documentation): New option.
(substitute-command-keys): Add link from keys to the command they
are bound to if above new option is non-nil.  (Bug#8951)
* etc/NEWS: Announce the new option.
---
 etc/NEWS          |  7 +++++++
 lisp/help-mode.el |  7 +++++++
 lisp/help.el      | 14 +++++++++++++-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index ce337e7517..4c3f2418a3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -928,6 +928,13 @@ be assumed to be a propertized string.
 Note that the new face will also be used in tooltips.  When using the
 GTK toolkit, this is only true if 'x-gtk-use-system-tooltips' is t.
 
+---
+*** New user option `help-link-key-to-documentation'.
+When this option is non-nil, key bindings displayed in the *Help*
+buffer will be linked to the documentation for the command they are
+bound to.  Note that this does not affect listings of key bindings and
+functions.
+
 ---
 *** 'g' ('revert-buffer') in 'help-mode' no longer requires confirmation.
 
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index c7eaae5feb..7691002f7f 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -321,6 +321,13 @@ 'help-news
     (view-buffer-other-window (find-file-noselect file))
     (goto-char pos))
   'help-echo (purecopy "mouse-2, RET: show corresponding NEWS announcement"))
+
+;;;###autoload
+(defun help-mode--add-function-link (str fun)
+  (make-text-button (copy-sequence str) nil
+                    'type 'help-function
+                    'help-args (list fun)))
+
 \f
 (defvar bookmark-make-record-function)
 
diff --git a/lisp/help.el b/lisp/help.el
index 94073e5730..cc624d5737 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -978,6 +978,14 @@ lookup-minor-mode-from-indicator
     result))
 
 \f
+(defcustom help-link-key-to-documentation nil
+  "Non-nil means to link keys to their command in *Help* buffers.
+This affects \\\\=\\[command] substitutions in documentation
+strings done by `substitute-command-keys'.  "
+  :type 'boolean
+  :version "28.1"
+  :group 'help)
+
 (defun substitute-command-keys (string)
   "Substitute key descriptions for command names in STRING.
 Each substring of the form \\\\=[COMMAND] is replaced by either a
@@ -1065,7 +1073,11 @@ substitute-command-keys
                         (delete-char 1))
                     ;; Function is on a key.
                     (delete-char (- end-point (point)))
-                    (insert (help--key-description-fontified key)))))
+                    (let ((key (help--key-description-fontified key)))
+                      (insert (if (and help-link-key-to-documentation
+                                       (functionp fun))
+                                  (help-mode--add-function-link key fun)
+                                key))))))
                ;; 1D. \{foo} is replaced with a summary of the keymap
                ;;            (symbol-value foo).
                ;;     \<foo> just sets the keymap used for \[cmd].
-- 
2.30.1


  reply	other threads:[~2021-03-09  7:38 UTC|newest]

Thread overview: 188+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-21 12:06 Proposal for an improved `help-for-help' Stefan Kangas
2021-02-21 16:46 ` [External] : " Drew Adams
2021-02-21 17:31   ` Stefan Kangas
2021-02-21 18:17     ` Drew Adams
2021-02-21 17:42 ` Lars Ingebrigtsen
2021-02-21 18:18   ` [External] : " Drew Adams
2021-02-21 19:49   ` Stefan Kangas
2021-02-24  1:40   ` Consistent face for keys in *Help* and `substitute-command-keys' Stefan Kangas
2021-02-24  2:24     ` [External] : " Drew Adams
2021-02-24  4:44       ` Stefan Kangas
2021-02-24 22:01         ` Drew Adams
2021-02-25  1:25           ` Stefan Kangas
2021-02-25  6:43             ` Drew Adams
2021-02-25 15:06               ` Eli Zaretskii
2021-02-25 16:22               ` Stefan Kangas
2021-02-24 14:00     ` Basil L. Contovounesios
2021-02-24 16:35       ` Stefan Kangas
2021-02-24 19:09         ` Basil L. Contovounesios
2021-02-25  2:11           ` Stefan Kangas
2021-02-24 14:29     ` Lars Ingebrigtsen
2021-02-24 16:46     ` Eli Zaretskii
2021-02-25  2:26       ` Stefan Kangas
2021-02-25 14:28         ` Eli Zaretskii
2021-02-25 16:45           ` Stefan Kangas
2021-02-25 18:25             ` Eli Zaretskii
2021-02-25 18:48               ` Stefan Kangas
2021-02-25 19:11                 ` Eli Zaretskii
2021-02-25 19:47                   ` Stefan Kangas
2021-02-25 20:32                     ` Eli Zaretskii
2021-03-04  6:24                       ` Stefan Kangas
2021-03-04 14:00                         ` Eli Zaretskii
2021-03-05 16:18                           ` Stefan Kangas
2021-03-05 17:07                             ` [External] : " Drew Adams
2021-03-05 17:58                               ` Stefan Kangas
2021-03-06 16:44                                 ` Drew Adams
2021-03-06 17:04                                   ` Stefan Kangas
2021-03-06 17:39                                     ` Drew Adams
2021-03-05 18:58                             ` Eli Zaretskii
2021-03-05 19:28                               ` Stefan Kangas
2021-03-05 20:15                                 ` Eli Zaretskii
2021-03-05 20:39                                   ` Stefan Kangas
2021-03-05 20:52                                     ` Eli Zaretskii
2021-03-05 21:43                                       ` Stefan Kangas
2021-03-06  7:33                                         ` Eli Zaretskii
2021-03-06 16:25                                           ` Stefan Kangas
2021-03-06 17:32                                             ` Stefan Kangas
2021-03-06 18:28                                               ` Eli Zaretskii
2021-03-07  3:03                                                 ` Stefan Kangas
2021-03-07  6:45                                                   ` Eli Zaretskii
2021-03-07  7:26                                                     ` Stefan Kangas
2021-03-07  7:42                                                       ` Eli Zaretskii
2021-03-08  9:17                                               ` Juri Linkov
2021-03-08 11:10                                                 ` Stefan Kangas
2021-03-08 17:43                                                   ` Juri Linkov
2021-03-10  1:38                                                     ` Stefan Kangas
2021-03-10 17:16                                                       ` Juri Linkov
2021-03-10 19:35                                                         ` Stefan Kangas
2021-03-10 19:50                                                           ` Juri Linkov
2021-03-10 19:59                                                             ` Eli Zaretskii
2021-03-11  0:46                                                               ` Stefan Kangas
2021-03-11  3:09                                                                 ` Stefan Monnier
2021-03-11  6:25                                                                   ` Eli Zaretskii
2021-03-11 13:25                                                                     ` Stefan Monnier
2021-03-11 13:59                                                                       ` Eli Zaretskii
2021-03-13 14:11                                                                   ` Stefan Kangas
2021-03-11  6:05                                                                 ` Eli Zaretskii
2021-03-13 14:27                                                                   ` Stefan Kangas
2021-03-13 15:16                                                                     ` Eli Zaretskii
2021-03-13 15:59                                                                       ` Stefan Kangas
2021-03-11  0:45                                                             ` Stefan Kangas
2021-03-15  9:19                                                               ` Juri Linkov
2021-03-16  2:37                                                                 ` Stefan Kangas
2021-03-16 23:20                                                                 ` Dmitry Gutov
2021-03-08 15:39                                                 ` [External] : " Drew Adams
2021-03-08 16:40                                                   ` Stefan Kangas
2021-03-08 17:43                                                     ` Juri Linkov
2021-03-09  7:38                                                       ` Stefan Kangas [this message]
2021-03-09  9:05                                                         ` Juri Linkov
2021-02-25 19:14                 ` Drew Adams
2021-02-25 19:44             ` martin rudalics
2021-02-24 16:51     ` Eli Zaretskii
2021-02-25  1:56       ` Stefan Kangas
2021-02-25 14:24         ` Eli Zaretskii
2021-02-21 17:45 ` Proposal for an improved `help-for-help' Eli Zaretskii
2021-02-21 18:20   ` [External] : " Drew Adams
2021-02-21 18:48   ` Stefan Kangas
2021-02-21 19:19     ` Eli Zaretskii
2021-02-21 20:04       ` Stefan Kangas
2021-02-21 20:16         ` Eli Zaretskii
2021-02-21 23:27           ` Stefan Kangas
2021-02-22 16:12             ` Eli Zaretskii
2021-03-13 16:26     ` Stefan Kangas
2021-03-14  2:37       ` [External] : " Drew Adams
2021-03-14 23:05       ` Drew Adams
2021-03-14 23:53         ` Stefan Kangas
2021-03-15  1:54           ` Drew Adams
2021-04-07 15:18       ` Stefan Kangas
2021-04-07 16:10         ` Eli Zaretskii
2021-04-07 22:54           ` Howard Melman
2021-04-08  7:15             ` Eli Zaretskii
2021-04-08 12:57               ` Stefan Kangas
2021-04-08 13:35           ` Stefan Kangas
2021-04-08 13:50             ` Eli Zaretskii
2021-04-08 15:27               ` Stefan Kangas
2021-04-08 15:34                 ` Eli Zaretskii
2021-04-08 17:16                   ` Howard Melman
2021-04-08 22:52                   ` Stefan Kangas
2021-04-09  6:23                     ` Eli Zaretskii
2021-04-08 14:08             ` Alan Mackenzie
2021-04-08 14:50               ` Dmitry Gutov
2021-04-08 15:02                 ` Alan Mackenzie
2021-04-08 15:15                   ` Eli Zaretskii
2021-04-08 15:45                     ` Alan Mackenzie
2021-04-08 15:51                       ` Eli Zaretskii
2021-04-08 17:55             ` Howard Melman
2021-04-09 15:42               ` Stefan Kangas
2021-04-08 18:48             ` Gregory Heytings
2021-04-08 23:23               ` Stefan Kangas
2021-04-08 23:35                 ` Gregory Heytings
2021-04-08 23:41                   ` Howard Melman
2021-04-07 16:42         ` [External] : " Drew Adams
2021-04-07 18:33         ` Gregory Heytings
2021-04-07 19:50           ` Gregory Heytings
2021-04-07 22:56           ` Stefan Kangas
2021-04-07 23:26             ` Gregory Heytings
2021-04-08 12:42               ` Stefan Kangas
2021-04-07 19:55         ` Juri Linkov
2021-04-24 13:21         ` Stefan Kangas
2021-04-24 13:27           ` Eli Zaretskii
2021-04-24 16:44           ` Dmitry Gutov
2021-04-24 23:48             ` Stefan Kangas
2021-04-25  7:26               ` Eli Zaretskii
2021-04-25  9:30                 ` Stefan Kangas
2021-04-25 10:25                   ` Eli Zaretskii
2021-04-25 11:49                     ` Stefan Kangas
2021-04-25 12:14                       ` Eli Zaretskii
2021-04-25 16:26                     ` [External] : " Drew Adams
2021-04-25 10:20                 ` Dmitry Gutov
2021-04-25 10:38                   ` Eli Zaretskii
2021-04-25 10:46                     ` Eli Zaretskii
2021-04-25 11:23                     ` Dmitry Gutov
2021-04-25 15:18                       ` Stefan Kangas
2021-04-25 15:28                         ` Dmitry Gutov
2021-04-30 17:39                           ` Stefan Kangas
2021-04-30 20:02                             ` Dmitry Gutov
2021-04-30 20:36                               ` Stefan Monnier
2021-04-30 22:09                                 ` Dmitry Gutov
2021-05-02 10:23                               ` Stefan Kangas
2021-05-02 18:57                                 ` Dmitry Gutov
2021-04-30 17:34                         ` Stefan Kangas
2021-04-25 12:47                   ` Gregory Heytings
2021-04-25 13:05                     ` Eli Zaretskii
2021-04-25 13:09                       ` Eli Zaretskii
2021-04-25 16:22                         ` [External] : " Drew Adams
2021-04-25 16:30                           ` Eli Zaretskii
2021-04-25 13:16                       ` Gregory Heytings
2021-04-25 13:24                         ` Eli Zaretskii
2021-04-25 13:32                           ` Gregory Heytings
2021-04-25 13:44                             ` Eli Zaretskii
2021-04-25 13:58                           ` Dmitry Gutov
2021-04-25 11:12               ` Dmitry Gutov
2021-04-25 15:47               ` DEL vs Backspace (was: Proposal for an improved `help-for-help') Stefan Monnier
2021-04-25 16:49                 ` DEL vs Backspace Lars Ingebrigtsen
2021-04-25 17:25                   ` Stefan Monnier
2021-04-25 17:50                     ` Dmitry Gutov
2021-04-26  0:45                     ` Stefan Kangas
2021-04-26 11:45                       ` Eli Zaretskii
2021-04-26 11:48                         ` Dmitry Gutov
2021-04-26  4:41                   ` Richard Stallman
2021-04-27 20:56               ` Proposal for an improved `help-for-help' Stefan Kangas
2021-04-27 23:15                 ` Dmitry Gutov
2021-04-24 17:18           ` Gregory Heytings
2021-04-24 20:32             ` Juri Linkov
2021-04-25 10:00             ` Stefan Kangas
2021-04-07 17:56       ` Howard Melman
2021-04-07 18:21         ` John Yates
2021-04-07 22:56           ` Stefan Kangas
2021-04-07 22:41         ` Stefan Kangas
2021-04-07 23:15           ` Howard Melman
2021-04-08 12:57             ` Stefan Kangas
2021-02-21 19:27 ` Howard Melman
2021-02-22 15:25   ` Stefan Kangas
2021-02-22 10:01 ` Yuri Khan
2021-02-22 15:25   ` Stefan Kangas
2021-04-25 15:11     ` Stefan Kangas
2021-04-25 15:34       ` Dmitry Gutov
2021-04-25 18:43         ` Stefan Kangas
2021-04-25 14:06   ` Dmitry Gutov

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='CADwFkm=C6Gz3NNZ+_SiXe+TYTPACXW8nSA6V-qQD+cBUTygi=g@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    --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).