[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16333: 24.3.50; Info manuals: link defined terms to their glossary e
From: |
Drew Adams |
Subject: |
bug#16333: 24.3.50; Info manuals: link defined terms to their glossary entries |
Date: |
Thu, 29 Oct 2020 10:51:59 -0700 (PDT) |
> > It turns out that the text need not exactly start with
> > "mouse-2".
>
> Yes.
>
> > Dunno where that text transformation is implemented
> > (in C?) - I didn't find it in the Lisp.
>
> It's in mouse-fixup-help-message.
Ah, very good. Thanks. I grepped and searched a fair
amount, but I missed that.
But I think that shows (what I think I've seen - see
my correction to what I wrote that you replied to)
that the text _does_ need to start with "mouse-2":
(string-match-p "\\`mouse-2" msg)
BTW, that doc string is not great. It should mention
`help-echo', I think. Grep `mouse-fixup-help-message'
finds no uses of it in Lisp. So it's not clear, but
I'm guessing that it ends up being used indirectly(?)
only(?) by `help-echo'.
___
In any case, could this behavior (if not that function)
please be pointed out in the Elisp manual? Users
writing help-echo text should be aware of the behavior.
___
Here's a suggestion, to make this less rigid/fragile:
Substitute for "mouse-2" everywhere in the help text,
as follows.
(defun mouse-fixup-help-message (msg)
"Fix help message MSG for `mouse-1-click-follows-link'."
(let (mp pos)
(when (and mouse-1-click-follows-link
(stringp msg)
(string-match-p "mouse-2" msg)
(setq mp (mouse-pixel-position))
(consp (setq pos (cdr mp)))
(car pos) (>= (car pos) 0)
(cdr pos) (>= (cdr pos) 0)
(setq pos (posn-at-x-y (car pos) (cdr pos) (car mp)))
(windowp (posn-window pos)))
(with-current-buffer (window-buffer (posn-window pos))
(when (mouse-on-link-p pos)
(setq msg (replace-regexp-in-string
"mouse-2"
(concat
(cond ((eq mouse-1-click-follows-link 'double)
"double-")
((and (integerp mouse-1-click-follows-link)
(< mouse-1-click-follows-link 0))
"Long ")
(t ""))
"mouse-1")
msg))))))
msg)
___
Or if you think it's more appropriate for some reason,
then substitute only the first occurrence of "mouse-2".
Of if you think we should let users specify exactly
which occurrences of "mouse-2" to substitute, then
define a formatting escape for that (e.g. "%m"), so
only "mouse-2" occurrences preceded by that escape get
substituted. E.g., "xxx%mmouse-2" would substitute
the "mouse-2", but "xxxmouse-2" would not.
bug#16333: 24.3.50; Info manuals: link defined terms to their glossary entries, Stefan Kangas, 2020/10/29