aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2018-05-21 19:48:15 +0200
committerMichael Albinus2018-05-21 19:48:15 +0200
commitab37ceb9eecdd20b913d1b2b00d81e8f83e1caf7 (patch)
tree9ad1f74753a4985f55ba9f1ad60b246ec2a7ff84
parent4010631fe915503e5376458d8a8b482d37360f87 (diff)
downloademacs-ab37ceb9eecdd20b913d1b2b00d81e8f83e1caf7.tar.gz
emacs-ab37ceb9eecdd20b913d1b2b00d81e8f83e1caf7.zip
Fix Bug#31489
* doc/misc/tramp.texi (Frequently Asked Questions): Mention `tramp-ignored-file-name-regexp'. Improve index. ; * etc/NEWS: Mention `tramp-ignored-file-name-regexp'. * lisp/net/tramp.el (tramp-ignored-file-name-regexp): New defcustom. (tramp-tramp-file-p): Use it. Check also for `tramp-mode'. (tramp-file-name-handler): Don't check for `tramp-mode'. (Bug#31489) * test/lisp/net/tramp-tests.el (tramp-test01-file-name-syntax): Extend test.
-rw-r--r--doc/misc/tramp.texi16
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/net/tramp.el15
-rw-r--r--test/lisp/net/tramp-tests.el6
4 files changed, 39 insertions, 2 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 329c46bdaad..5dd1a2ca4ee 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -3994,6 +3994,7 @@ in @file{.emacs}:
3994@end lisp 3994@end lisp
3995 3995
3996@item 3996@item
3997@vindex tramp-mode
3997To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to 3998To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to
3998@code{nil} in @file{.emacs}. @strong{Note}, that we don't use 3999@code{nil} in @file{.emacs}. @strong{Note}, that we don't use
3999@code{customize-set-variable}, in order to avoid loading @value{tramp}. 4000@code{customize-set-variable}, in order to avoid loading @value{tramp}.
@@ -4003,6 +4004,21 @@ To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to
4003@end lisp 4004@end lisp
4004 4005
4005@item 4006@item
4007@vindex tramp-ignored-file-name-regexp
4008To deactivate @value{tramp} for some look-alike remote file names, set
4009@code{tramp-ignored-file-name-regexp} to a proper regexp in
4010@file{.emacs}. @strong{Note}, that we don't use
4011@code{customize-set-variable}, in order to avoid loading
4012@value{tramp}.
4013
4014@lisp
4015(setq tramp-ignored-file-name-regexp "\\`/ssh:example\\.com:")
4016@end lisp
4017
4018This is needed, if you mount for example a virtual file system on your
4019local host's root directory as @file{/ssh:example.com:}.
4020
4021@item
4006To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp @key{RET}}. 4022To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp @key{RET}}.
4007Unloading @value{tramp} resets Ange FTP plugins also. 4023Unloading @value{tramp} resets Ange FTP plugins also.
4008@end itemize 4024@end itemize
diff --git a/etc/NEWS b/etc/NEWS
index ae8a366f4bf..4cb31ef4d41 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -422,6 +422,10 @@ or NextCloud hosted files and directories.
422+++ 422+++
423*** Validated passwords are saved by auth-source backends which support this. 423*** Validated passwords are saved by auth-source backends which support this.
424 424
425+++
426*** The user option 'tramp-ignored-file-name-regexp' allows to disable
427Tramp for some look-alike remote file names.
428
425--- 429---
426** The options.el library has been removed. 430** The options.el library has been removed.
427It was obsolete since Emacs 22.1, replaced by customize. 431It was obsolete since Emacs 22.1, replaced by customize.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index e14a515b8bb..499fcadffff 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -991,6 +991,14 @@ This regexp should match Tramp file names but no other file
991names. When calling `tramp-register-file-name-handlers', the 991names. When calling `tramp-register-file-name-handlers', the
992initial value is overwritten by the car of `tramp-file-name-structure'.") 992initial value is overwritten by the car of `tramp-file-name-structure'.")
993 993
994;;;###autoload
995(defcustom tramp-ignored-file-name-regexp nil
996 "Regular expression matching file names that are not under Tramp’s control."
997 :version "27.1"
998 :group 'tramp
999 :type '(choice (const nil) string)
1000 :require 'tramp)
1001
994(defconst tramp-completion-file-name-regexp-default 1002(defconst tramp-completion-file-name-regexp-default
995 (concat 1003 (concat
996 "\\`/\\(" 1004 "\\`/\\("
@@ -1279,12 +1287,15 @@ entry does not exist, return nil."
1279;;;###tramp-autoload 1287;;;###tramp-autoload
1280(defun tramp-tramp-file-p (name) 1288(defun tramp-tramp-file-p (name)
1281 "Return t if NAME is a string with Tramp file name syntax." 1289 "Return t if NAME is a string with Tramp file name syntax."
1282 (and (stringp name) 1290 (and tramp-mode (stringp name)
1283 ;; No "/:" and "/c:". This is not covered by `tramp-file-name-regexp'. 1291 ;; No "/:" and "/c:". This is not covered by `tramp-file-name-regexp'.
1284 (not (string-match-p 1292 (not (string-match-p
1285 (if (memq system-type '(cygwin windows-nt)) 1293 (if (memq system-type '(cygwin windows-nt))
1286 "^/[[:alpha:]]?:" "^/:") 1294 "^/[[:alpha:]]?:" "^/:")
1287 name)) 1295 name))
1296 ;; Excluded file names.
1297 (or (null tramp-ignored-file-name-regexp)
1298 (not (string-match-p tramp-ignored-file-name-regexp name)))
1288 (string-match-p tramp-file-name-regexp name) 1299 (string-match-p tramp-file-name-regexp name)
1289 t)) 1300 t))
1290 1301
@@ -2254,7 +2265,7 @@ preventing reentrant calls of Tramp.")
2254 "Invoke Tramp file name handler. 2265 "Invoke Tramp file name handler.
2255Falls back to normal file name handler if no Tramp file name handler exists." 2266Falls back to normal file name handler if no Tramp file name handler exists."
2256 (let ((filename (apply 'tramp-file-name-for-operation operation args))) 2267 (let ((filename (apply 'tramp-file-name-for-operation operation args)))
2257 (if (and tramp-mode (tramp-tramp-file-p filename)) 2268 (if (tramp-tramp-file-p filename)
2258 (save-match-data 2269 (save-match-data
2259 (setq filename (tramp-replace-environment-variables filename)) 2270 (setq filename (tramp-replace-environment-variables filename))
2260 (with-parsed-tramp-file-name filename nil 2271 (with-parsed-tramp-file-name filename nil
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 2c0b3199be6..65ffcb34f76 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -267,6 +267,12 @@ handled properly. BODY shall not contain a timeout."
267 (should-not (tramp-tramp-file-p "/::")) 267 (should-not (tramp-tramp-file-p "/::"))
268 (should-not (tramp-tramp-file-p "/:@:")) 268 (should-not (tramp-tramp-file-p "/:@:"))
269 (should-not (tramp-tramp-file-p "/:[]:")) 269 (should-not (tramp-tramp-file-p "/:[]:"))
270 ;; When `tramp-mode' is nil, Tramp is not activated.
271 (let (tramp-mode)
272 (should-not (tramp-tramp-file-p "/method:user@host:")))
273 ;; `tramp-ignored-file-name-regexp' suppresses Tramp.
274 (let ((tramp-ignored-file-name-regexp "^/method:user@host:"))
275 (should-not (tramp-tramp-file-p "/method:user@host:")))
270 ;; Methods shall be at least two characters on MS Windows, except 276 ;; Methods shall be at least two characters on MS Windows, except
271 ;; the default method. 277 ;; the default method.
272 (let ((system-type 'windows-nt)) 278 (let ((system-type 'windows-nt))