aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2020-05-06 16:48:57 +0200
committerTassilo Horn2020-05-06 16:48:57 +0200
commit4b8e6939bf7664fda33a7aaa03d2d8069358ff7b (patch)
treeed3411303899b40c3712333315c7b48a6f543c3b
parentd9e10a1d1a56b8740a276a3fa418f628f79790d0 (diff)
downloademacs-4b8e6939bf7664fda33a7aaa03d2d8069358ff7b.tar.gz
emacs-4b8e6939bf7664fda33a7aaa03d2d8069358ff7b.zip
Consult browse-url-{default-,}handlers in drag&drop.
* lisp/dnd.el (dnd-handle-one-url): Consult `browse-url-handlers' and `browse-url-default-handlers' for a matching handler. Adapt docstring. * doc/lispref/frames.texi (Drag and Drop): Remove the docs for the deprecated alist choice of `browse-url-browser-function' and mention `browse-url-handlers' and `browse-url-default-handlers'.
-rw-r--r--doc/lispref/frames.texi10
-rw-r--r--lisp/dnd.el34
2 files changed, 26 insertions, 18 deletions
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index 905e5c2e6ce..6bf5db2aa1d 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -3875,13 +3875,15 @@ detailed knowledge of what types other applications use for drag and
3875drop. 3875drop.
3876 3876
3877@vindex dnd-protocol-alist 3877@vindex dnd-protocol-alist
3878@vindex browse-url-handlers
3879@vindex browse-url-default-handlers
3878 When an URL is dropped on Emacs it may be a file, but it may also be 3880 When an URL is dropped on Emacs it may be a file, but it may also be
3879another URL type (https, etc.). Emacs first checks 3881another URL type (https, etc.). Emacs first checks
3880@code{dnd-protocol-alist} to determine what to do with the URL@. If 3882@code{dnd-protocol-alist} to determine what to do with the URL@. If
3881there is no match there and if @code{browse-url-browser-function} is 3883there is no match there, Emacs looks for a match in
3882an alist, Emacs looks for a match there. If no match is found the 3884@code{browse-url-handlers} and @code{browse-url-default-handlers}. If
3883text for the URL is inserted. If you want to alter Emacs behavior, 3885still no match has been found, the text for the URL is inserted. If
3884you can customize these variables. 3886you want to alter Emacs behavior, you can customize these variables.
3885 3887
3886@node Color Names 3888@node Color Names
3887@section Color Names 3889@section Color Names
diff --git a/lisp/dnd.el b/lisp/dnd.el
index 905659e817b..2f7b16c56ed 100644
--- a/lisp/dnd.el
+++ b/lisp/dnd.el
@@ -87,12 +87,11 @@ and is the default except for MS-Windows."
87(defun dnd-handle-one-url (window action url) 87(defun dnd-handle-one-url (window action url)
88 "Handle one dropped url by calling the appropriate handler. 88 "Handle one dropped url by calling the appropriate handler.
89The handler is first located by looking at `dnd-protocol-alist'. 89The handler is first located by looking at `dnd-protocol-alist'.
90If no match is found here, and the value of `browse-url-browser-function' 90If no match is found here, `browse-url-handlers' and
91is a pair of (REGEXP . FUNCTION), those regexps are tried for a match. 91`browse-url-default-handlers' are searched for a match.
92If no match is found, just call `dnd-insert-text'. 92If no match is found, just call `dnd-insert-text'. WINDOW is
93WINDOW is where the drop happened, ACTION is the action for the drop, 93where the drop happened, ACTION is the action for the drop, URL
94URL is what has been dropped. 94is what has been dropped. Returns ACTION."
95Returns ACTION."
96 (require 'browse-url) 95 (require 'browse-url)
97 (let (ret) 96 (let (ret)
98 (or 97 (or
@@ -102,14 +101,21 @@ Returns ACTION."
102 (setq ret (funcall (cdr bf) url action)) 101 (setq ret (funcall (cdr bf) url action))
103 (throw 'done t))) 102 (throw 'done t)))
104 nil) 103 nil)
105 (when (not (functionp browse-url-browser-function)) 104 (catch 'done
106 (catch 'done 105 (require 'browse-url) ;; browse-url-handlers is not autoloaded.
107 (dolist (bf browse-url-browser-function) 106 (dolist (bf (append
108 (when (string-match (car bf) url) 107 ;; The alist choice of browse-url-browser-function
109 (setq ret 'private) 108 ;; is deprecated since 28.1, so the (unless ...)
110 (funcall (cdr bf) url action) 109 ;; can be removed at some point in time.
111 (throw 'done t))) 110 (unless (functionp browse-url-browser-function)
112 nil)) 111 browse-url-browser-function)
112 browse-url-handlers
113 browse-url-default-handlers))
114 (when (string-match (car bf) url)
115 (setq ret 'private)
116 (funcall (cdr bf) url action)
117 (throw 'done t)))
118 nil)
113 (progn 119 (progn
114 (dnd-insert-text window action url) 120 (dnd-insert-text window action url)
115 (setq ret 'private))) 121 (setq ret 'private)))