unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "H. Dieter Wilhelm" <dieter@duenenhof-wilhelm.de>
Cc: Juri Linkov <juri@jurta.org>, Eli Zaretskii <eliz@gnu.org>,
	"60587@debbugs.gnu.org" <60587@debbugs.gnu.org>,
	Drew Adams <drew.adams@oracle.com>
Subject: bug#60587: Patch for adding links to symbols' help documentation
Date: Wed, 15 Feb 2023 22:08:01 -0500	[thread overview]
Message-ID: <jwvmt5e1fm0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <86leky609i.fsf@duenenhof-wilhelm.de> (H. Dieter Wilhelm's message of "Wed, 15 Feb 2023 23:18:17 +0100")

H. Dieter Wilhelm [2023-02-15 23:18:17] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> +(define-minor-mode info-links-to-help-mode
>>> +  "The mode creates buttons on symbols linking to their documentation string.
>>> +It shows their documentation in a *Help* buffers (in another
>>> +window) when typing <RET> or clicking `mouse-2' on the buttons.
>>> +These can be followed, as the regular Info manual references,
>>> +with \\[Info-next-reference] and \\[Info-prev-reference].
>>> +
>>> +For details about which symbols are considered and the linking
>>> +process itself please see the function `info-make-links-to-help'."
>>> +  :init-value nil
>>> +  :lighter " Hlp"
>>> +  :group 'info
>>> +  :version "30.1"
>>> +  (if info-links-to-help-mode
>>> +      (progn
>>> +        (if (eq major-mode 'Info-mode)
>>> +            ;; we need this under Info-mode because of the narrowed
>>> +            ;; Info file
>>> +            (add-hook 'Info-selection-hook 'info-make-links-to-help))
>>> +        (info-make-links-to-help))      ;for the current buffer
>>
>> The above `define-minor-mode` still defines a buffer-local minor mode
>
> I thought a minor mode is necessary when 'info-make-links-to-help' is
> supposed to work for arbitrary major modes and buffers besides Info.

I don't understand your remark.  I'm pointing out that the way you use
`define-minor-mode` above makes it buffer-local (if you want it to be
global, which is probably simpler you need to say `:global t`).

>> whereas the above `add-hook` is still global and hence affects all
>> buffers.
> I'm not sure I understand, it affects only Info buffers globally (eq
> major-mode 'Info-mode).

But it affects all Info-mode buffers whereas the
`info-links-to-help-mode` variable will only be set buffer-locally in
the current-buffer.  So you'll have Info-mode buffers where
`info-make-links-to-help` has been added to `Info-selection-hook` even
though its `info-links-to-help-mode` var is nil and you can have others
with the reverse.

> Do you think it is better to use a global minor mode for all Info
> buffers and a separate buffer local mode for other buffers (and major
> modes)?

If I were you, I'd just use a single global minor mode that affects all
Info-mode buffers (and only Info-mode buffers).  It should be rather rare
for a user to want to enable this in some buffers but not all.

We can easily add another global minor mode (using the same underlying
code) for the NEWS files if we want.

>> Better add a call to `info-links-to-help-mode` directly inside
>> `Info-mode`.
> (Please tell me why are you quoting with two grave accents and not with
> apostrophes?)

I try to follow the Markdown convention.

> Do you think setting
>
> (defcustom Info-mode-hook '(turn-on-font-lock info-links-to-help-mode)
>   "Hook run when activating Info Mode."
>   :type 'hook
>   :version "29.1")
>
> is a possible alternative to call it into 'Info-mode'?

I think I was confused because.  IIUC what you're trying to do is to
default this new minor mode to "enabled".  In that case I think your
code is somewhat OK though you should protect the `add-hook` with a test
for the value of the minor-mode to make sure you only run it when the
mode is enabled (which again only makes sense if the mode is global).


        Stefan






  reply	other threads:[~2023-02-16  3:08 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 23:47 bug#60587: 30.0.50; Info pages are lacking links from symbol names to the symbol's help documentation H. Dieter Wilhelm
2023-01-06 19:03 ` bug#60587: Patch for adding links to symbols' " H. Dieter Wilhelm
2023-01-07  7:38   ` Eli Zaretskii
2023-01-08 20:06     ` H. Dieter Wilhelm
2023-01-09 12:46       ` Eli Zaretskii
2023-01-09 14:25         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-09 20:01         ` H. Dieter Wilhelm
2023-01-13 23:33     ` H. Dieter Wilhelm
2023-01-14  7:12       ` Eli Zaretskii
2023-01-15 12:48         ` H. Dieter Wilhelm
2023-01-17 21:53     ` H. Dieter Wilhelm
2023-01-18 13:20       ` Eli Zaretskii
2023-01-20 21:09         ` H. Dieter Wilhelm
2023-01-20 21:59           ` Drew Adams
2023-01-20 23:32           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-22 13:00             ` H. Dieter Wilhelm
2023-01-21  8:21           ` Eli Zaretskii
2023-01-21 20:27             ` H. Dieter Wilhelm
2023-01-22  6:00               ` Eli Zaretskii
2023-01-22 22:09                 ` Drew Adams
2023-01-23 12:14                   ` Eli Zaretskii
2023-01-23 16:16                     ` Drew Adams
2023-01-25 21:29             ` H. Dieter Wilhelm
2023-01-25 22:24               ` Drew Adams
2023-01-26 10:29                 ` Ihor Radchenko
2023-01-26 15:06                   ` Drew Adams
2023-01-26 15:12                     ` Ihor Radchenko
2023-01-26 15:23                       ` Drew Adams
2023-01-27 21:35                 ` H. Dieter Wilhelm
2023-01-27 22:12                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-27 23:09                     ` Drew Adams
2023-01-27 23:13                   ` Drew Adams
2023-01-28  8:11                     ` Eli Zaretskii
2023-01-28 17:30                       ` Drew Adams
2023-02-01 22:09                     ` H. Dieter Wilhelm
2023-02-02  2:30                       ` Drew Adams
2023-02-05  0:48                     ` H. Dieter Wilhelm
2023-02-05  3:54                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05 13:54                         ` H. Dieter Wilhelm
2023-02-06 21:04                           ` H. Dieter Wilhelm
2023-02-12 11:04                         ` H. Dieter Wilhelm
2023-02-14 20:56                           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-15 22:18                             ` H. Dieter Wilhelm
2023-02-16  3:08                               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-02-20 23:53                                 ` H. Dieter Wilhelm
2023-02-21  2:12                                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-01 21:45                                     ` H. Dieter Wilhelm
2023-03-11  8:32                                       ` Eli Zaretskii
2023-03-11  9:16                                         ` H. Dieter Wilhelm
2023-02-15  5:17                           ` Richard Stallman
2023-02-15  9:53                             ` Gregory Heytings
2023-02-15 13:42                               ` Gregory Heytings
2023-01-26 10:37               ` Eli Zaretskii
2023-01-27  7:45                 ` Juri Linkov
2023-01-27  8:11                   ` Eli Zaretskii
2023-01-27 22:21                 ` H. Dieter Wilhelm
2023-01-28  7:51                   ` Eli Zaretskii
2023-02-01 21:26                 ` H. Dieter Wilhelm

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=jwvmt5e1fm0.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=60587@debbugs.gnu.org \
    --cc=dieter@duenenhof-wilhelm.de \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=juri@jurta.org \
    --cc=monnier@iro.umontreal.ca \
    /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).