diff options
| author | Jim Porter | 2024-03-07 21:55:45 -0800 |
|---|---|---|
| committer | Jim Porter | 2024-03-10 14:05:09 -0700 |
| commit | 46afc91c9f7e6ee6a7917537c83052e0877fa4f2 (patch) | |
| tree | ef9cc8ec38efe69fbf82357d610affeef4bff755 | |
| parent | c17ecd2dcd27b73d673df51ce66f4b188afff6db (diff) | |
| download | emacs-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.el | 17 |
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 | |||
| 704 | point. If invoked with a mouse button, it moves point to the | 704 | point. If invoked with a mouse button, it moves point to the |
| 705 | position clicked before acting. | 705 | position clicked before acting. |
| 706 | 706 | ||
| 707 | This function returns a list (URL NEW-WINDOW-FLAG) | 707 | This function returns a list (URL NEW-WINDOW-FLAG) for use in |
| 708 | for 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 | ||
| 710 | instead." | ||
| 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' |
| 880 | determine which browser function to use. | 881 | determine which browser function to use. |
| 881 | 882 | ||
| 882 | This command prompts for a URL, defaulting to the URL at or | 883 | Interactively, this command prompts for a URL, defaulting to the |
| 883 | before point. | 884 | URL at or before point. |
| 884 | 885 | ||
| 885 | The additional ARGS are passed to the browser function. See the | 886 | The additional ARGS are passed to the browser function. See the |
| 886 | doc strings of the actual functions, starting with | 887 | doc strings of the actual functions, starting with |
| @@ -888,7 +889,9 @@ doc strings of the actual functions, starting with | |||
| 888 | significance of ARGS (most of the functions ignore it). | 889 | significance of ARGS (most of the functions ignore it). |
| 889 | 890 | ||
| 890 | If ARGS are omitted, the default is to pass | 891 | If 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 |
| 893 | prefix arg as ARGS; if `browse-url-new-window-flag' is non-nil, | ||
| 894 | invert 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)))) |