emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs-28 354c834: Fix `browse-url-interactive-arg' for certain kinds


From: Stefan Monnier
Subject: Re: emacs-28 354c834: Fix `browse-url-interactive-arg' for certain kinds of events
Date: Sun, 21 Nov 2021 09:37:19 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>>> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]