all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 16333@debbugs.gnu.org, stefan@marxist.se
Subject: bug#16333: 24.3.50; Info manuals: link defined terms to their glossary entries
Date: Fri, 30 Oct 2020 14:14:54 -0700 (PDT)	[thread overview]
Message-ID: <3b9fabae-fbe4-4c4a-b11b-8aad73016ace@default> (raw)
In-Reply-To: <1f8767bb-1912-42ea-abba-dd666bea48b0@default>

> 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?

(defvar mouse-fixup-help-replace-regexp
  '("\\(?:\\|[[:space:]]\\)\\(mouse-2\\)" . 1)
  "Regexp to match \"mouse-2\" in MSG.
The value is a cons (REGEXP . N).  Function `mouse-fixup-help-message'
replaces the match of subexpression N, of the text that matches
REGEXP, with \"mouse-1\".")

(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
                      (car mouse-fixup-help-replace-regexp)
                      (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 nil nil (cdr mouse-fixup-help-replace-regexp)))))))
  msg)





  reply	other threads:[~2020-10-30 21:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<bc491f1f-4a8d-4953-a4aa-fd7c0121c1e6@default>
     [not found] ` <<87pnfk1ozm.fsf@marxist.se>
     [not found]   ` <<835zhc4hor.fsf@gnu.org>
2020-01-15 20:30     ` bug#16333: 24.3.50; Info manuals: link defined terms to their glossary entries Drew Adams
     [not found]   ` <<44a24b90-adf8-41f1-8d06-b35f55f1850c@default>
     [not found]     ` <<cbdf8d05-8ce5-4bc5-a04f-44c1e9b380db@default>
     [not found]       ` <<83tuudaz1y.fsf@gnu.org>
2020-10-29 17:51         ` Drew Adams
2020-10-30 21:14           ` Drew Adams [this message]
2020-10-31  7:03             ` Eli Zaretskii
     [not found] <<<bc491f1f-4a8d-4953-a4aa-fd7c0121c1e6@default>
     [not found] ` <<<87pnfk1ozm.fsf@marxist.se>
     [not found]   ` <<<44a24b90-adf8-41f1-8d06-b35f55f1850c@default>
     [not found]     ` <<<cbdf8d05-8ce5-4bc5-a04f-44c1e9b380db@default>
     [not found]       ` <<<83tuudaz1y.fsf@gnu.org>
     [not found]         ` <<1f8767bb-1912-42ea-abba-dd666bea48b0@default>
     [not found]           ` <<3b9fabae-fbe4-4c4a-b11b-8aad73016ace@default>
     [not found]             ` <<83wnz698rr.fsf@gnu.org>
2020-10-31 17:04               ` Drew Adams
2014-01-03 21:50 Drew Adams
2020-01-15 19:47 ` Stefan Kangas
2020-01-15 19:56   ` Eli Zaretskii
2020-01-15 20:22   ` Drew Adams
2020-10-29  6:52     ` Drew Adams
2020-10-29  6:59       ` Drew Adams
2020-10-29 14:26       ` Eli Zaretskii
2020-10-29 14:40       ` Stefan Kangas
2020-10-29 18:13         ` Drew Adams
2021-10-11 14:02           ` Stefan Kangas
2021-10-11 14:05             ` Lars Ingebrigtsen
2021-10-11 14:32               ` Stefan Kangas
2021-10-11 14:34                 ` Lars Ingebrigtsen
2021-10-11 14:55                   ` Stefan Kangas

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3b9fabae-fbe4-4c4a-b11b-8aad73016ace@default \
    --to=drew.adams@oracle.com \
    --cc=16333@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=stefan@marxist.se \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.