aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Porter2024-03-07 21:55:45 -0800
committerJim Porter2024-03-10 14:05:09 -0700
commit46afc91c9f7e6ee6a7917537c83052e0877fa4f2 (patch)
treeef9cc8ec38efe69fbf82357d610affeef4bff755
parentc17ecd2dcd27b73d673df51ce66f4b188afff6db (diff)
downloademacs-46afc91c9f7e6ee6a7917537c83052e0877fa4f2.tar.gz
emacs-46afc91c9f7e6ee6a7917537c83052e0877fa4f2.zip
Let 'browse-url-interactive-arg' return more values for NEW-WINDOW-FLAG
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.
-rw-r--r--lisp/net/browse-url.el17
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index ddc57724343..f22aa19f5e3 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -704,8 +704,10 @@ it defaults to the current region, else to the URL at or before
704point. If invoked with a mouse button, it moves point to the 704point. If invoked with a mouse button, it moves point to the
705position clicked before acting. 705position clicked before acting.
706 706
707This function returns a list (URL NEW-WINDOW-FLAG) 707This function returns a list (URL NEW-WINDOW-FLAG) for use in
708for use in `interactive'." 708`interactive'. NEW-WINDOW-FLAG is the prefix arg; if
709`browse-url-new-window-flag' is non-nil, invert the prefix arg
710instead."
709 (let ((event (elt (this-command-keys) 0))) 711 (let ((event (elt (this-command-keys) 0)))
710 (mouse-set-point event)) 712 (mouse-set-point event))
711 (list (read-string prompt (or (and transient-mark-mode mark-active 713 (list (read-string prompt (or (and transient-mark-mode mark-active
@@ -715,8 +717,7 @@ for use in `interactive'."
715 (buffer-substring-no-properties 717 (buffer-substring-no-properties
716 (region-beginning) (region-end)))) 718 (region-beginning) (region-end))))
717 (browse-url-url-at-point))) 719 (browse-url-url-at-point)))
718 (not (eq (null browse-url-new-window-flag) 720 (xor browse-url-new-window-flag current-prefix-arg)))
719 (null current-prefix-arg)))))
720 721
721;; called-interactive-p needs to be called at a function's top-level, hence 722;; called-interactive-p needs to be called at a function's top-level, hence
722;; this macro. We use that rather than interactive-p because 723;; this macro. We use that rather than interactive-p because
@@ -879,8 +880,8 @@ The variables `browse-url-browser-function',
879`browse-url-handlers', and `browse-url-default-handlers' 880`browse-url-handlers', and `browse-url-default-handlers'
880determine which browser function to use. 881determine which browser function to use.
881 882
882This command prompts for a URL, defaulting to the URL at or 883Interactively, this command prompts for a URL, defaulting to the
883before point. 884URL at or before point.
884 885
885The additional ARGS are passed to the browser function. See the 886The additional ARGS are passed to the browser function. See the
886doc strings of the actual functions, starting with 887doc strings of the actual functions, starting with
@@ -888,7 +889,9 @@ doc strings of the actual functions, starting with
888significance of ARGS (most of the functions ignore it). 889significance of ARGS (most of the functions ignore it).
889 890
890If ARGS are omitted, the default is to pass 891If ARGS are omitted, the default is to pass
891`browse-url-new-window-flag' as ARGS." 892`browse-url-new-window-flag' as ARGS. Interactively, pass the
893prefix arg as ARGS; if `browse-url-new-window-flag' is non-nil,
894invert the prefix arg instead."
892 (interactive (browse-url-interactive-arg "URL: ")) 895 (interactive (browse-url-interactive-arg "URL: "))
893 (unless (called-interactively-p 'interactive) 896 (unless (called-interactively-p 'interactive)
894 (setq args (or args (list browse-url-new-window-flag)))) 897 (setq args (or args (list browse-url-new-window-flag))))