unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Po Lu <luangruo@yahoo.com>
Cc: Lars Ingebrigtsen <larsi@gnus.org>,  emacs-devel@gnu.org
Subject: Re: emacs-28 354c834: Fix `browse-url-interactive-arg' for certain kinds of events
Date: Sun, 21 Nov 2021 09:37:19 -0500	[thread overview]
Message-ID: <jwvzgpxvb4n.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87tug5n9vt.fsf@yahoo.com> (Po Lu's message of "Sun, 21 Nov 2021 17:19:50 +0800")

>>> Shouldn't this be fixed in `mouse-set-point` (or even `event-end` and
>>> `event-start`) instead, and then we should remove the `listp` test since
>>> `mouse-set-point` nowadays should work with any kind of event.
>
>> I think it would be convenient if `mouse-set-point' did nothing if the
>> event given isn't a mouse event -- we have a bunch of commands that are
>> both mousey and non-mousey.

It's been that way already for quite a while.  Try to call it with an
event like `?a`.  This is handled in `event-end`.  It's just that this
special handling did not account for events like `(menu-bar)`.

> Either way, I think we should not change the behavior of
> `mouse-set-point' in the release branch.

I'd agree with that, I'm talking about what goes on `master`.

So, more concretely I propose the patch below for `master`.


        Stefan


diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index f85f5f6149..c33517ea10 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -737,8 +737,7 @@ browse-url-interactive-arg
 This function returns a list (URL NEW-WINDOW-FLAG)
 for use in `interactive'."
   (let ((event (elt (this-command-keys) 0)))
-    (when (mouse-event-p event)
-      (mouse-set-point event)))
+    (mouse-set-point event))
   (list (read-string prompt (or (and transient-mark-mode mark-active
 				     ;; rfc2396 Appendix E.
 				     (replace-regexp-in-string
diff --git a/lisp/subr.el b/lisp/subr.el
index 7ba764880e..4e06aefd06 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1553,22 +1553,22 @@ event-start
 `posn-timestamp': The time the event occurred, in milliseconds.
 
 For more information, see Info node `(elisp)Click Events'."
-  (if (consp event) (nth 1 event)
-    ;; Use `window-point' for the case when the current buffer
-    ;; is temporarily switched to some other buffer (bug#50256)
-    (or (posn-at-point (window-point))
-        (list (selected-window) (window-point) '(0 . 0) 0))))
+  (or (and (consp event) (nth 1 event))
+      ;; Use `window-point' for the case when the current buffer
+      ;; is temporarily switched to some other buffer (bug#50256)
+      (posn-at-point (window-point))
+      (list (selected-window) (window-point) '(0 . 0) 0)))
 
 (defun event-end (event)
   "Return the ending position of EVENT.
 EVENT should be a click, drag, or key press event.
 
 See `event-start' for a description of the value returned."
-  (if (consp event) (nth (if (consp (nth 2 event)) 2 1) event)
-    ;; Use `window-point' for the case when the current buffer
-    ;; is temporarily switched to some other buffer (bug#50256)
-    (or (posn-at-point (window-point))
-        (list (selected-window) (window-point) '(0 . 0) 0))))
+  (or (and (consp event) (nth (if (consp (nth 2 event)) 2 1) event))
+      ;; Use `window-point' for the case when the current buffer
+      ;; is temporarily switched to some other buffer (bug#50256)
+      (posn-at-point (window-point))
+      (list (selected-window) (window-point) '(0 . 0) 0)))
 
 (defsubst event-click-count (event)
   "Return the multi-click count of EVENT, a click or drag event.




  reply	other threads:[~2021-11-21 14:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211120075812.24103.86181@vcs0.savannah.gnu.org>
     [not found] ` <20211120075814.63AB3209FD@vcs0.savannah.gnu.org>
2021-11-20 13:20   ` emacs-28 354c834: Fix `browse-url-interactive-arg' for certain kinds of events Stefan Monnier
2021-11-21  8:29     ` Lars Ingebrigtsen
2021-11-21  9:19       ` Po Lu
2021-11-21 14:37         ` Stefan Monnier [this message]
2021-11-21 17:04           ` Lars Ingebrigtsen
2021-11-22  0:45           ` Po Lu
2021-11-22 19:25             ` Stefan Monnier

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=jwvzgpxvb4n.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=luangruo@yahoo.com \
    /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).