Subject: bug#78026: 31.0.50; browse-url-interactive-arg does not handle nil (this-command-keys)

From: StrawberryTea <[email-masked]>
Date: Sun, 04 May 2025 20:28:01 -0400

Stefan Monnier <[email-masked]> writes:
Hello. I am back! So what is happening is that in some cases
(this-command-keys) will be the empty string and that causes the error.
For example,
(run-at-time 0.01 nil
             (lambda () (message "this-command-keys: %s %s %s"
                                 (this-command-keys)
                                 (length (this-command-keys))
                                 (stringp (this-command-keys)))))
The original embark bug involved calling browse-url through embark-act
on a minibuffer candidate and though I can reproduce the original issue
I have not come up with a minimal example. This patch Stefan made does
fix the issue though.
> Eli Zaretskii [2025-05-03 11:46:12] wrote:
>
>>> From: Stefan Monnier <[email-masked]>
>>> Cc: StrawberryTea <[email-masked]>,  [email-masked]
>>> Date: Sun, 27 Apr 2025 09:54:26 -0400
>>> 
>>> >> Hello. So when fixing https://github.com/oantolin/embark/pull/750, I
>>> >> realized that browse-url-interactive-arg does not handle
>>> >> (this-command-keys) being the empty vector and that causes
>>> >> browse-url-interactive-arg to emit an error when called programmatically
>>> >> in embark.el. We should make it so that if (this-command-keys) returns
>>> >> an empty vector, then mouse-set-point is not called.
>>> 
>>> You mean like in the patch below?
>>
>> ENOPATCH
>
> Hmm... I remember hesitating between a few different options, but
> I think I meant to send this one:
>
>     diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
>     index 3b2d3983002..96b4baaa615 100644
>     --- a/lisp/net/browse-url.el
>     +++ b/lisp/net/browse-url.el
>     @@ -713,8 +713,7 @@ browse-url-interactive-arg
>      `interactive'.  NEW-WINDOW-FLAG is the prefix arg; if
>      `browse-url-new-window-flag' is non-nil, invert the prefix arg
>      instead."
>     -  (let ((event (elt (this-command-keys) 0)))
>     -    (mouse-set-point event))
>     +  (mouse-set-point last-nonmenu-event)
>        (list (read-string prompt (or (and transient-mark-mode mark-active
>                                          ;; rfc2396 Appendix E.
>                                          (replace-regexp-in-string
>
> - Stefan