]> git.eshelyaron.com Git - emacs.git/commitdiff
Consult browse-url-{default-,}handlers in drag&drop.
authorTassilo Horn <tsdh@gnu.org>
Wed, 6 May 2020 14:48:57 +0000 (16:48 +0200)
committerTassilo Horn <tsdh@gnu.org>
Wed, 6 May 2020 14:48:57 +0000 (16:48 +0200)
* 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'.

doc/lispref/frames.texi
lisp/dnd.el

index 905e5c2e6ce35d70434fa29b7c633b48150a4f83..6bf5db2aa1d274487db8622ce63307067dcbd933 100644 (file)
@@ -3875,13 +3875,15 @@ detailed knowledge of what types other applications use for drag and
 drop.
 
 @vindex dnd-protocol-alist
+@vindex browse-url-handlers
+@vindex browse-url-default-handlers
   When an URL is dropped on Emacs it may be a file, but it may also be
 another URL type (https, etc.).  Emacs first checks
 @code{dnd-protocol-alist} to determine what to do with the URL@.  If
-there is no match there and if @code{browse-url-browser-function} is
-an alist, Emacs looks for a match there.  If no match is found the
-text for the URL is inserted.  If you want to alter Emacs behavior,
-you can customize these variables.
+there is no match there, Emacs looks for a match in
+@code{browse-url-handlers} and @code{browse-url-default-handlers}.  If
+still no match has been found, the text for the URL is inserted.  If
+you want to alter Emacs behavior, you can customize these variables.
 
 @node Color Names
 @section Color Names
index 905659e817b0780b74f289946439b5df9e3701bd..2f7b16c56edd68a2a2b8b83b281b91b3009b5eb7 100644 (file)
@@ -87,12 +87,11 @@ and is the default except for MS-Windows."
 (defun dnd-handle-one-url (window action url)
   "Handle one dropped url by calling the appropriate handler.
 The handler is first located by looking at `dnd-protocol-alist'.
-If no match is found here, and the value of `browse-url-browser-function'
-is a pair of (REGEXP . FUNCTION), those regexps are tried for a match.
-If no match is found, just call `dnd-insert-text'.
-WINDOW is where the drop happened, ACTION is the action for the drop,
-URL is what has been dropped.
-Returns ACTION."
+If no match is found here, `browse-url-handlers' and
+`browse-url-default-handlers' are searched for a match.
+If no match is found, just call `dnd-insert-text'.  WINDOW is
+where the drop happened, ACTION is the action for the drop, URL
+is what has been dropped.  Returns ACTION."
   (require 'browse-url)
   (let (ret)
     (or
@@ -102,14 +101,21 @@ Returns ACTION."
           (setq ret (funcall (cdr bf) url action))
           (throw 'done t)))
        nil)
-     (when (not (functionp browse-url-browser-function))
-       (catch 'done
-        (dolist (bf browse-url-browser-function)
-          (when (string-match (car bf) url)
-            (setq ret 'private)
-            (funcall (cdr bf) url action)
-            (throw 'done t)))
-        nil))
+     (catch 'done
+       (require 'browse-url) ;; browse-url-handlers is not autoloaded.
+       (dolist (bf (append
+                    ;; The alist choice of browse-url-browser-function
+                    ;; is deprecated since 28.1, so the (unless ...)
+                    ;; can be removed at some point in time.
+                    (unless (functionp browse-url-browser-function)
+                      browse-url-browser-function)
+                    browse-url-handlers
+                    browse-url-default-handlers))
+        (when (string-match (car bf) url)
+          (setq ret 'private)
+          (funcall (cdr bf) url action)
+          (throw 'done t)))
+       nil)
      (progn
        (dnd-insert-text window action url)
        (setq ret 'private)))