Subject: Re: bug#16333: 24.3.50; Info manuals: link defined terms to their glossary entries

From: Eli Zaretskii <[email-masked]>
Date: Sat, 31 Oct 2020 09:03:52 +0200

> Date: Fri, 30 Oct 2020 14:14:54 -0700 (PDT)
> From: Drew Adams <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> > 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.
> 
> 
> Actually, the following is much better.  It lets code
> use different patterns in different contexts, by binding
> the variable.
> 
> Should I submit this as a separate bug report, or can it
> be considered in the context of this one?

Please be sure to grep all our Lisp sources and make sure this change
won't replace stuff in places we don't want.  Please don't push this
before this check is complete, thanks.