diff options
| author | Andrea Corallo | 2020-05-07 10:24:30 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-05-07 10:24:30 +0100 |
| commit | 92dc81f85e1b91db04487ccf1b52c0cd3328dfee (patch) | |
| tree | bc3081252c6ee13007a02e52bf63c951e486b086 | |
| parent | cf105f604413d270c956adf375217960e3945e2a (diff) | |
| parent | de5f59219ac02c6502907f6a24538ddabf487839 (diff) | |
| download | emacs-92dc81f85e1b91db04487ccf1b52c0cd3328dfee.tar.gz emacs-92dc81f85e1b91db04487ccf1b52c0cd3328dfee.zip | |
Merge remote-tracking branch 'savannah/master' into HEAD
| -rw-r--r-- | lisp/dnd.el | 19 | ||||
| -rw-r--r-- | lisp/net/browse-url.el | 64 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 4 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 4 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 2 |
5 files changed, 53 insertions, 40 deletions
diff --git a/lisp/dnd.el b/lisp/dnd.el index 2f7b16c56ed..c185794d6ea 100644 --- a/lisp/dnd.el +++ b/lisp/dnd.el | |||
| @@ -92,7 +92,6 @@ If no match is found here, `browse-url-handlers' and | |||
| 92 | If no match is found, just call `dnd-insert-text'. WINDOW is | 92 | If no match is found, just call `dnd-insert-text'. WINDOW is |
| 93 | where the drop happened, ACTION is the action for the drop, URL | 93 | where the drop happened, ACTION is the action for the drop, URL |
| 94 | is what has been dropped. Returns ACTION." | 94 | is what has been dropped. Returns ACTION." |
| 95 | (require 'browse-url) | ||
| 96 | (let (ret) | 95 | (let (ret) |
| 97 | (or | 96 | (or |
| 98 | (catch 'done | 97 | (catch 'done |
| @@ -102,19 +101,11 @@ is what has been dropped. Returns ACTION." | |||
| 102 | (throw 'done t))) | 101 | (throw 'done t))) |
| 103 | nil) | 102 | nil) |
| 104 | (catch 'done | 103 | (catch 'done |
| 105 | (require 'browse-url) ;; browse-url-handlers is not autoloaded. | 104 | (let ((browser (browse-url-select-handler url))) |
| 106 | (dolist (bf (append | 105 | (when browser |
| 107 | ;; The alist choice of browse-url-browser-function | 106 | (setq ret 'private) |
| 108 | ;; is deprecated since 28.1, so the (unless ...) | 107 | (funcall browser url action) |
| 109 | ;; can be removed at some point in time. | 108 | (throw 'done t))) |
| 110 | (unless (functionp browse-url-browser-function) | ||
| 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) | 109 | nil) |
| 119 | (progn | 110 | (progn |
| 120 | (dnd-insert-text window action url) | 111 | (dnd-insert-text window action url) |
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 1275c15578f..b34665358ca 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el | |||
| @@ -601,10 +601,17 @@ down (this *won't* always work)." | |||
| 601 | "Calls `browse-url-man-function' with URL and ARGS." | 601 | "Calls `browse-url-man-function' with URL and ARGS." |
| 602 | (funcall browse-url-man-function url args)) | 602 | (funcall browse-url-man-function url args)) |
| 603 | 603 | ||
| 604 | (defun browse-url--browser (url &rest args) | ||
| 605 | "Calls `browse-url-browser-function' with URL and ARGS." | ||
| 606 | (funcall browse-url-browser-function url args)) | ||
| 607 | |||
| 604 | ;;;###autoload | 608 | ;;;###autoload |
| 605 | (defvar browse-url-default-handlers | 609 | (defvar browse-url-default-handlers |
| 606 | '(("\\`mailto:" . browse-url--mailto) | 610 | '(("\\`mailto:" . browse-url--mailto) |
| 607 | ("\\`man:" . browse-url--man) | 611 | ("\\`man:" . browse-url--man) |
| 612 | ;; Render file:// URLs if they are HTML pages, otherwise just find | ||
| 613 | ;; the file. | ||
| 614 | ("\\`file://.*\\.html?\\b" . browse-url--browser) | ||
| 608 | ("\\`file://" . browse-url-emacs)) | 615 | ("\\`file://" . browse-url-emacs)) |
| 609 | "Like `browse-url-handlers' but populated by Emacs and packages. | 616 | "Like `browse-url-handlers' but populated by Emacs and packages. |
| 610 | 617 | ||
| @@ -628,6 +635,32 @@ match, the URL is opened using the value of | |||
| 628 | :value-type (function :tag "Handler")) | 635 | :value-type (function :tag "Handler")) |
| 629 | :version "28.1") | 636 | :version "28.1") |
| 630 | 637 | ||
| 638 | ;;;###autoload | ||
| 639 | (defun browse-url-select-handler (url) | ||
| 640 | "Return a handler suitable for browsing URL. | ||
| 641 | This searches `browse-url-handlers', and | ||
| 642 | `browse-url-default-handlers' for a matching handler. Return nil | ||
| 643 | if no handler is found. | ||
| 644 | |||
| 645 | Currently, it also consults `browse-url-browser-function' first | ||
| 646 | if it is set to an alist, although this usage is deprecated since | ||
| 647 | Emacs 28.1 and will be removed in a future release." | ||
| 648 | (catch 'custom-url-handler | ||
| 649 | (dolist (regex-handler | ||
| 650 | (append | ||
| 651 | ;; The alist choice of browse-url-browser-function | ||
| 652 | ;; is deprecated since 28.1, so the (unless ...) | ||
| 653 | ;; can be removed at some point in time. | ||
| 654 | (when (and (consp browse-url-browser-function) | ||
| 655 | (not (functionp browse-url-browser-function))) | ||
| 656 | (warn "Having `browse-url-browser-function' set to an | ||
| 657 | alist is deprecated. Use `browse-url-handlers' instead.") | ||
| 658 | browse-url-browser-function) | ||
| 659 | browse-url-handlers | ||
| 660 | browse-url-default-handlers)) | ||
| 661 | (when (string-match-p (car regex-handler) url) | ||
| 662 | (throw 'custom-url-handler (cdr regex-handler)))))) | ||
| 663 | |||
| 631 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 664 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 632 | ;; URL encoding | 665 | ;; URL encoding |
| 633 | 666 | ||
| @@ -821,14 +854,8 @@ If ARGS are omitted, the default is to pass | |||
| 821 | (not (string-match "\\`[a-z]+:" url))) | 854 | (not (string-match "\\`[a-z]+:" url))) |
| 822 | (setq url (expand-file-name url))) | 855 | (setq url (expand-file-name url))) |
| 823 | (let ((process-environment (copy-sequence process-environment)) | 856 | (let ((process-environment (copy-sequence process-environment)) |
| 824 | (function | 857 | (function (or (browse-url-select-handler url) |
| 825 | (catch 'custom-url-handler | 858 | browse-url-browser-function)) |
| 826 | (dolist (regex-handler (append browse-url-handlers | ||
| 827 | browse-url-default-handlers)) | ||
| 828 | (when (string-match-p (car regex-handler) url) | ||
| 829 | (throw 'custom-url-handler (cdr regex-handler)))) | ||
| 830 | ;; No special handler found. | ||
| 831 | browse-url-browser-function)) | ||
| 832 | ;; Ensure that `default-directory' exists and is readable (bug#6077). | 859 | ;; Ensure that `default-directory' exists and is readable (bug#6077). |
| 833 | (default-directory (or (unhandled-file-name-directory default-directory) | 860 | (default-directory (or (unhandled-file-name-directory default-directory) |
| 834 | (expand-file-name "~/")))) | 861 | (expand-file-name "~/")))) |
| @@ -837,24 +864,9 @@ If ARGS are omitted, the default is to pass | |||
| 837 | ;; which may not even exist any more. | 864 | ;; which may not even exist any more. |
| 838 | (if (stringp (frame-parameter nil 'display)) | 865 | (if (stringp (frame-parameter nil 'display)) |
| 839 | (setenv "DISPLAY" (frame-parameter nil 'display))) | 866 | (setenv "DISPLAY" (frame-parameter nil 'display))) |
| 840 | (if (and (consp function) | 867 | (if (functionp nil) |
| 841 | (not (functionp function))) | 868 | (apply function url args) |
| 842 | ;; The `function' can be an alist; look down it for first | 869 | (error "No suitable browser for URL %s" url)))) |
| 843 | ;; match and apply the function (which might be a lambda). | ||
| 844 | ;; However, this usage is deprecated as of Emacs 28.1. | ||
| 845 | (progn | ||
| 846 | (warn "Having `browse-url-browser-function' set to an | ||
| 847 | alist is deprecated. Use `browse-url-handlers' instead.") | ||
| 848 | (catch 'done | ||
| 849 | (dolist (bf function) | ||
| 850 | (when (string-match (car bf) url) | ||
| 851 | (apply (cdr bf) url args) | ||
| 852 | (throw 'done t))) | ||
| 853 | (error "No browse-url-browser-function matching URL %s" | ||
| 854 | url))) | ||
| 855 | ;; Unbound symbols go down this leg, since void-function from | ||
| 856 | ;; apply is clearer than wrong-type-argument from dolist. | ||
| 857 | (apply function url args)))) | ||
| 858 | 870 | ||
| 859 | ;;;###autoload | 871 | ;;;###autoload |
| 860 | (defun browse-url-at-point (&optional arg) | 872 | (defun browse-url-at-point (&optional arg) |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 7f829f15205..7ef07afb8ef 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -918,6 +918,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 918 | (kill-buffer (tramp-get-connection-buffer v)) | 918 | (kill-buffer (tramp-get-connection-buffer v)) |
| 919 | (setq ret 1))) | 919 | (setq ret 1))) |
| 920 | 920 | ||
| 921 | ;; Handle signals. | ||
| 922 | (when (and (natnump ret) (> ret 128)) | ||
| 923 | (setq ret (format "Signal %d" (- ret 128)))) | ||
| 924 | |||
| 921 | ;; Provide error file. | 925 | ;; Provide error file. |
| 922 | (when tmpstderr (rename-file tmpstderr (cadr destination) t)) | 926 | (when tmpstderr (rename-file tmpstderr (cadr destination) t)) |
| 923 | 927 | ||
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index c6eb7a8ff49..c609f58cdd8 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -3159,6 +3159,10 @@ STDERR can also be a file name." | |||
| 3159 | (kill-buffer (tramp-get-connection-buffer v)) | 3159 | (kill-buffer (tramp-get-connection-buffer v)) |
| 3160 | (setq ret 1))) | 3160 | (setq ret 1))) |
| 3161 | 3161 | ||
| 3162 | ;; Handle signals. | ||
| 3163 | (when (and (natnump ret) (> ret 128)) | ||
| 3164 | (setq ret (format "Signal %d" (- ret 128)))) | ||
| 3165 | |||
| 3162 | ;; Provide error file. | 3166 | ;; Provide error file. |
| 3163 | (when tmpstderr (rename-file tmpstderr (cadr destination) t)) | 3167 | (when tmpstderr (rename-file tmpstderr (cadr destination) t)) |
| 3164 | 3168 | ||
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 462539a7c17..4cacfa2f712 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -4209,6 +4209,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4209 | (should-not (zerop (process-file "false"))) | 4209 | (should-not (zerop (process-file "false"))) |
| 4210 | (should-not (zerop (process-file "binary-does-not-exist"))) | 4210 | (should-not (zerop (process-file "binary-does-not-exist"))) |
| 4211 | (should (= 42 (process-file "sh" nil nil nil "-c" "exit 42"))) | 4211 | (should (= 42 (process-file "sh" nil nil nil "-c" "exit 42"))) |
| 4212 | ;; Return string in case the process is interrupted. | ||
| 4213 | (should (stringp (process-file "sh" nil nil nil "-c" "kill -2 $$"))) | ||
| 4212 | (with-temp-buffer | 4214 | (with-temp-buffer |
| 4213 | (write-region "foo" nil tmp-name) | 4215 | (write-region "foo" nil tmp-name) |
| 4214 | (should (file-exists-p tmp-name)) | 4216 | (should (file-exists-p tmp-name)) |