diff options
| author | Michael Albinus | 2017-03-09 19:44:37 +0100 |
|---|---|---|
| committer | Michael Albinus | 2017-03-09 19:44:37 +0100 |
| commit | 37b88d7b92ba77a771ce0dbff940b3dec1a366c5 (patch) | |
| tree | a50ff6a979eecb2753c34cea32560330741cd3d9 | |
| parent | 550c23d326da983af082ad8f0227ace16c652021 (diff) | |
| download | emacs-37b88d7b92ba77a771ce0dbff940b3dec1a366c5.tar.gz emacs-37b88d7b92ba77a771ce0dbff940b3dec1a366c5.zip | |
Fix bug#23006
* lisp/minibuffer.el (completion--nth-completion):
Let-bind `non-essential'.
* lisp/net/tramp.el (tramp-completion-mode): Fix docstring.
(tramp-completion-mode-p): Optional parameter VEC. Replace
check for `last-input-event' by analysing VEC argument.
(tramp-error-with-buffer, tramp-file-name-handler)
(tramp-connectable-p, tramp-handle-file-name-as-directory):
* lisp/net/tramp-sh.el (tramp-maybe-open-connection): Use it.
| -rw-r--r-- | lisp/minibuffer.el | 31 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 57 |
3 files changed, 42 insertions, 48 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 00722ec4b15..530670fab76 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el | |||
| @@ -894,21 +894,22 @@ This overrides the defaults specified in `completion-category-defaults'." | |||
| 894 | ;; The quote/unquote function needs to come from the completion table (rather | 894 | ;; The quote/unquote function needs to come from the completion table (rather |
| 895 | ;; than from completion-extra-properties) because it may apply only to some | 895 | ;; than from completion-extra-properties) because it may apply only to some |
| 896 | ;; part of the string (e.g. substitute-in-file-name). | 896 | ;; part of the string (e.g. substitute-in-file-name). |
| 897 | (let ((requote | 897 | (let* ((requote |
| 898 | (when (completion-metadata-get metadata 'completion--unquote-requote) | 898 | (when (completion-metadata-get metadata 'completion--unquote-requote) |
| 899 | (cl-assert (functionp table)) | 899 | (cl-assert (functionp table)) |
| 900 | (let ((new (funcall table string point 'completion--unquote))) | 900 | (let ((new (funcall table string point 'completion--unquote))) |
| 901 | (setq string (pop new)) | 901 | (setq string (pop new)) |
| 902 | (setq table (pop new)) | 902 | (setq table (pop new)) |
| 903 | (setq point (pop new)) | 903 | (setq point (pop new)) |
| 904 | (cl-assert (<= point (length string))) | 904 | (cl-assert (<= point (length string))) |
| 905 | (pop new)))) | 905 | (pop new)))) |
| 906 | (result | 906 | (non-essential t) |
| 907 | (completion--some (lambda (style) | 907 | (result |
| 908 | (funcall (nth n (assq style | 908 | (completion--some (lambda (style) |
| 909 | completion-styles-alist)) | 909 | (funcall (nth n (assq style |
| 910 | string table pred point)) | 910 | completion-styles-alist)) |
| 911 | (completion--styles metadata)))) | 911 | string table pred point)) |
| 912 | (completion--styles metadata)))) | ||
| 912 | (if requote | 913 | (if requote |
| 913 | (funcall requote result n) | 914 | (funcall requote result n) |
| 914 | result))) | 915 | result))) |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 85619621d90..6cd52ae4e03 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -4654,7 +4654,7 @@ connection if a previous connection has died for some reason." | |||
| 4654 | ;; check this for the process related to | 4654 | ;; check this for the process related to |
| 4655 | ;; `tramp-buffer-name'; otherwise `start-file-process' | 4655 | ;; `tramp-buffer-name'; otherwise `start-file-process' |
| 4656 | ;; wouldn't run ever when `non-essential' is non-nil. | 4656 | ;; wouldn't run ever when `non-essential' is non-nil. |
| 4657 | (when (and (tramp-completion-mode-p) | 4657 | (when (and (tramp-completion-mode-p vec) |
| 4658 | (null (get-process (tramp-buffer-name vec)))) | 4658 | (null (get-process (tramp-buffer-name vec)))) |
| 4659 | (throw 'non-essential 'non-essential)) | 4659 | (throw 'non-essential 'non-essential)) |
| 4660 | 4660 | ||
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 406cd02b52d..03dcee4a97a 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -1559,7 +1559,7 @@ an input event arrives. The other arguments are passed to `tramp-error'." | |||
| 1559 | (when (and buf | 1559 | (when (and buf |
| 1560 | tramp-message-show-message | 1560 | tramp-message-show-message |
| 1561 | (not (zerop tramp-verbose)) | 1561 | (not (zerop tramp-verbose)) |
| 1562 | (not (tramp-completion-mode-p)) | 1562 | (not (tramp-completion-mode-p vec)) |
| 1563 | ;; Show only when Emacs has started already. | 1563 | ;; Show only when Emacs has started already. |
| 1564 | (current-message)) | 1564 | (current-message)) |
| 1565 | (let ((enable-recursive-minibuffers t)) | 1565 | (let ((enable-recursive-minibuffers t)) |
| @@ -2028,17 +2028,17 @@ Falls back to normal file name handler if no Tramp file name handler exists." | |||
| 2028 | (let ((filename (apply 'tramp-file-name-for-operation operation args))) | 2028 | (let ((filename (apply 'tramp-file-name-for-operation operation args))) |
| 2029 | (if (and tramp-mode (tramp-tramp-file-p filename)) | 2029 | (if (and tramp-mode (tramp-tramp-file-p filename)) |
| 2030 | (save-match-data | 2030 | (save-match-data |
| 2031 | (let* ((filename (tramp-replace-environment-variables filename)) | 2031 | (setq filename (tramp-replace-environment-variables filename)) |
| 2032 | (non-essential | 2032 | (with-parsed-tramp-file-name filename nil |
| 2033 | (and non-essential | 2033 | (let* ((non-essential |
| 2034 | (string-match | 2034 | (and non-essential |
| 2035 | tramp-completion-file-name-regexp filename))) | 2035 | (string-match |
| 2036 | (completion (tramp-completion-mode-p)) | 2036 | tramp-completion-file-name-regexp filename))) |
| 2037 | (foreign | 2037 | (completion (tramp-completion-mode-p v)) |
| 2038 | (tramp-find-foreign-file-name-handler | 2038 | (foreign |
| 2039 | filename operation completion)) | 2039 | (tramp-find-foreign-file-name-handler |
| 2040 | result) | 2040 | filename operation completion)) |
| 2041 | (with-parsed-tramp-file-name filename nil | 2041 | result) |
| 2042 | ;; Call the backend function. | 2042 | ;; Call the backend function. |
| 2043 | (if foreign | 2043 | (if foreign |
| 2044 | (tramp-condition-case-unless-debug err | 2044 | (tramp-condition-case-unless-debug err |
| @@ -2262,34 +2262,27 @@ Falls back to normal file name handler if no Tramp file name handler exists." | |||
| 2262 | 2262 | ||
| 2263 | ;;;###autoload | 2263 | ;;;###autoload |
| 2264 | (defvar tramp-completion-mode nil | 2264 | (defvar tramp-completion-mode nil |
| 2265 | "If non-nil, external packages signal that they are in file name completion. | 2265 | "If non-nil, external packages signal that they are in file name completion.") |
| 2266 | |||
| 2267 | This is necessary, because Tramp uses a heuristic depending on last | ||
| 2268 | input event. This fails when external packages use other characters | ||
| 2269 | but <TAB>, <SPACE> or ?\\? for file name completion. This variable | ||
| 2270 | should never be set globally, the intention is to let-bind it.") | ||
| 2271 | (make-obsolete-variable 'tramp-completion-mode 'non-essential "26.1") | 2266 | (make-obsolete-variable 'tramp-completion-mode 'non-essential "26.1") |
| 2272 | 2267 | ||
| 2273 | ;; Necessary because `tramp-file-name-regexp-unified' and | 2268 | ;; Necessary because `tramp-file-name-regexp-unified' and |
| 2274 | ;; `tramp-completion-file-name-regexp-unified' aren't different. If | 2269 | ;; `tramp-completion-file-name-regexp-unified' aren't different. If |
| 2275 | ;; nil is returned, `tramp-completion-run-real-handler' is called | 2270 | ;; nil is returned, `tramp-completion-run-real-handler' is called |
| 2276 | ;; (i.e. forwarding to `tramp-file-name-handler'). Otherwise, it | 2271 | ;; (i.e. forwarding to `tramp-file-name-handler'). Otherwise, it |
| 2277 | ;; takes `tramp-run-real-handler'. Using `last-input-event' is a | 2272 | ;; takes `tramp-run-real-handler'. |
| 2278 | ;; little bit risky, because completing a file might require loading | ||
| 2279 | ;; other files, like "~/.netrc", and for them it shouldn't be decided | ||
| 2280 | ;; based on that variable. On the other hand, those files shouldn't | ||
| 2281 | ;; have partial Tramp file name syntax. | ||
| 2282 | ;;;###autoload | 2273 | ;;;###autoload |
| 2283 | (progn (defun tramp-completion-mode-p () | 2274 | (progn (defun tramp-completion-mode-p (&optional vec) |
| 2284 | "Check, whether method / user name / host name completion is active." | 2275 | "Check, whether method / user name / host name completion is active." |
| 2285 | (or | 2276 | (or |
| 2286 | ;; Signal from outside. `non-essential' has been introduced in Emacs 24. | 2277 | ;; Signal from outside. `non-essential' has been introduced in Emacs 24. |
| 2287 | (and (boundp 'non-essential) (symbol-value 'non-essential)) | 2278 | (and (boundp 'non-essential) (symbol-value 'non-essential)) |
| 2288 | ;; This variable has been obsoleted in Emacs 26. | 2279 | ;; This variable has been obsoleted in Emacs 26. |
| 2289 | tramp-completion-mode | 2280 | tramp-completion-mode |
| 2290 | ;; Fallback. Some completion packages still don't support | 2281 | ;; When the host name is a method, we are still in completion mode. |
| 2291 | ;; `non-essential' sufficiently. | 2282 | ;; Due to autoload dependencies, we cannot use `tramp-file-name-host'. |
| 2292 | (equal last-input-event 'tab)))) | 2283 | (and (equal tramp-syntax 'ftp) |
| 2284 | (vectorp vec) | ||
| 2285 | (member (aref vec 2) (mapcar 'car tramp-methods)))))) | ||
| 2293 | 2286 | ||
| 2294 | (defun tramp-connectable-p (filename) | 2287 | (defun tramp-connectable-p (filename) |
| 2295 | "Check, whether it is possible to connect the remote host w/o side-effects. | 2288 | "Check, whether it is possible to connect the remote host w/o side-effects. |
| @@ -2297,10 +2290,10 @@ This is true, if either the remote host is already connected, or if we are | |||
| 2297 | not in completion mode." | 2290 | not in completion mode." |
| 2298 | (let (tramp-verbose) | 2291 | (let (tramp-verbose) |
| 2299 | (and (tramp-tramp-file-p filename) | 2292 | (and (tramp-tramp-file-p filename) |
| 2300 | (or (not (tramp-completion-mode-p)) | 2293 | (with-parsed-tramp-file-name filename nil |
| 2301 | (tramp-compat-process-live-p | 2294 | (or (not (tramp-completion-mode-p v)) |
| 2302 | (tramp-get-connection-process | 2295 | (tramp-compat-process-live-p |
| 2303 | (tramp-dissect-file-name filename))))))) | 2296 | (tramp-get-connection-process v))))))) |
| 2304 | 2297 | ||
| 2305 | (defun tramp-completion-handle-expand-file-name (name &optional dir) | 2298 | (defun tramp-completion-handle-expand-file-name (name &optional dir) |
| 2306 | "Like `expand-file-name' for Tramp files." | 2299 | "Like `expand-file-name' for Tramp files." |
| @@ -2878,7 +2871,7 @@ User is always nil." | |||
| 2878 | (tramp-file-name-method v) | 2871 | (tramp-file-name-method v) |
| 2879 | (tramp-file-name-user v) | 2872 | (tramp-file-name-user v) |
| 2880 | (tramp-file-name-host v) | 2873 | (tramp-file-name-host v) |
| 2881 | (if (and (tramp-completion-mode-p) | 2874 | (if (and (tramp-completion-mode-p v) |
| 2882 | (zerop (length (tramp-file-name-localname v)))) | 2875 | (zerop (length (tramp-file-name-localname v)))) |
| 2883 | "" | 2876 | "" |
| 2884 | (tramp-run-real-handler | 2877 | (tramp-run-real-handler |