]> git.eshelyaron.com Git - emacs.git/commitdiff
Let 'browse-url-interactive-arg' return more values for NEW-WINDOW-FLAG
authorJim Porter <jporterbugs@gmail.com>
Fri, 8 Mar 2024 05:55:45 +0000 (21:55 -0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 11 Mar 2024 09:27:44 +0000 (10:27 +0100)
Previously it always returned t or nil for NEW-WINDOW-FLAG, but now it
can return the actual prefix arg when appropriate.  This lets functions
for 'browse-url-browser-function' consult it and do more things than
just open a new window or not (for example, you could use "C--" as the
prefix arg to do something special in a custom function).

* lisp/net/browse-url.el (browse-url-interactive-arg): Use 'xor' to
adjust the value of 'current-prefix-arg'.
(browse-url): Update docstring.

(cherry picked from commit 46afc91c9f7e6ee6a7917537c83052e0877fa4f2)

lisp/net/browse-url.el

index ddc5772434372485ed1bd00aaaabab7af7c2b46d..f22aa19f5e379d51434b3af82e6dc16ea443c199 100644 (file)
@@ -704,8 +704,10 @@ it defaults to the current region, else to the URL at or before
 point.  If invoked with a mouse button, it moves point to the
 position clicked before acting.
 
-This function returns a list (URL NEW-WINDOW-FLAG)
-for use in `interactive'."
+This function returns a list (URL NEW-WINDOW-FLAG) for use in
+`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))
   (list (read-string prompt (or (and transient-mark-mode mark-active
@@ -715,8 +717,7 @@ for use in `interactive'."
                                      (buffer-substring-no-properties
                                       (region-beginning) (region-end))))
                                (browse-url-url-at-point)))
-       (not (eq (null browse-url-new-window-flag)
-                (null current-prefix-arg)))))
+       (xor browse-url-new-window-flag current-prefix-arg)))
 
 ;; called-interactive-p needs to be called at a function's top-level, hence
 ;; this macro.  We use that rather than interactive-p because
@@ -879,8 +880,8 @@ The variables `browse-url-browser-function',
 `browse-url-handlers', and `browse-url-default-handlers'
 determine which browser function to use.
 
-This command prompts for a URL, defaulting to the URL at or
-before point.
+Interactively, this command prompts for a URL, defaulting to the
+URL at or before point.
 
 The additional ARGS are passed to the browser function.  See the
 doc strings of the actual functions, starting with
@@ -888,7 +889,9 @@ doc strings of the actual functions, starting with
 significance of ARGS (most of the functions ignore it).
 
 If ARGS are omitted, the default is to pass
-`browse-url-new-window-flag' as ARGS."
+`browse-url-new-window-flag' as ARGS.  Interactively, pass the
+prefix arg as ARGS; if `browse-url-new-window-flag' is non-nil,
+invert the prefix arg instead."
   (interactive (browse-url-interactive-arg "URL: "))
   (unless (called-interactively-p 'interactive)
     (setq args (or args (list browse-url-new-window-flag))))