]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Bug#31489
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 21 May 2018 17:48:15 +0000 (19:48 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 21 May 2018 17:48:15 +0000 (19:48 +0200)
* 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.

doc/misc/tramp.texi
etc/NEWS
lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index 329c46bdaad42fddf8f1290f9719833f8242f8c5..5dd1a2ca4ee25aa2a1925b615299ae00249451f5 100644 (file)
@@ -3994,6 +3994,7 @@ in @file{.emacs}:
 @end lisp
 
 @item
+@vindex tramp-mode
 To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to
 @code{nil} in @file{.emacs}.  @strong{Note}, that we don't use
 @code{customize-set-variable}, in order to avoid loading @value{tramp}.
@@ -4002,6 +4003,21 @@ To disable both @value{tramp} (and Ange FTP), set @code{tramp-mode} to
 (setq tramp-mode nil)
 @end lisp
 
+@item
+@vindex tramp-ignored-file-name-regexp
+To deactivate @value{tramp} for some look-alike remote file names, set
+@code{tramp-ignored-file-name-regexp} to a proper regexp in
+@file{.emacs}.  @strong{Note}, that we don't use
+@code{customize-set-variable}, in order to avoid loading
+@value{tramp}.
+
+@lisp
+(setq tramp-ignored-file-name-regexp "\\`/ssh:example\\.com:")
+@end lisp
+
+This is needed, if you mount for example a virtual file system on your
+local host's root directory as @file{/ssh:example.com:}.
+
 @item
 To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp @key{RET}}.
 Unloading @value{tramp} resets Ange FTP plugins also.
index ae8a366f4bfec5d74d7df0567c16952694b6f581..4cb31ef4d417f3d3374521c655aaa5ebbd8e63ca 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -422,6 +422,10 @@ or NextCloud hosted files and directories.
 +++
 *** Validated passwords are saved by auth-source backends which support this.
 
++++
+*** The user option 'tramp-ignored-file-name-regexp' allows to disable
+Tramp for some look-alike remote file names.
+
 ---
 ** The options.el library has been removed.
 It was obsolete since Emacs 22.1, replaced by customize.
index e14a515b8bb052e64867ce9ba52c2c2d7ddcbea6..499fcadffffb76f0f4031c8ad75b443431edcbd3 100644 (file)
@@ -991,6 +991,14 @@ This regexp should match Tramp file names but no other file
 names.  When calling `tramp-register-file-name-handlers', the
 initial value is overwritten by the car of `tramp-file-name-structure'.")
 
+;;;###autoload
+(defcustom tramp-ignored-file-name-regexp nil
+  "Regular expression matching file names that are not under Tramp’s control."
+  :version "27.1"
+  :group 'tramp
+  :type '(choice (const nil) string)
+  :require 'tramp)
+
 (defconst tramp-completion-file-name-regexp-default
   (concat
    "\\`/\\("
@@ -1279,12 +1287,15 @@ entry does not exist, return nil."
 ;;;###tramp-autoload
 (defun tramp-tramp-file-p (name)
   "Return t if NAME is a string with Tramp file name syntax."
-  (and (stringp name)
+  (and tramp-mode (stringp name)
        ;; No "/:" and "/c:".  This is not covered by `tramp-file-name-regexp'.
        (not (string-match-p
             (if (memq system-type '(cygwin windows-nt))
                 "^/[[:alpha:]]?:" "^/:")
             name))
+       ;; Excluded file names.
+       (or (null tramp-ignored-file-name-regexp)
+          (not (string-match-p tramp-ignored-file-name-regexp name)))
        (string-match-p tramp-file-name-regexp name)
        t))
 
@@ -2254,7 +2265,7 @@ preventing reentrant calls of Tramp.")
   "Invoke Tramp file name handler.
 Falls back to normal file name handler if no Tramp file name handler exists."
   (let ((filename (apply 'tramp-file-name-for-operation operation args)))
-    (if (and tramp-mode (tramp-tramp-file-p filename))
+    (if (tramp-tramp-file-p filename)
        (save-match-data
           (setq filename (tramp-replace-environment-variables filename))
           (with-parsed-tramp-file-name filename nil
index 2c0b3199be661e42af0646abd0e89170bd0bb33e..65ffcb34f7636f5e8720a82c45cb4aca77a3ec44 100644 (file)
@@ -267,6 +267,12 @@ handled properly.  BODY shall not contain a timeout."
   (should-not (tramp-tramp-file-p "/::"))
   (should-not (tramp-tramp-file-p "/:@:"))
   (should-not (tramp-tramp-file-p "/:[]:"))
+  ;; When `tramp-mode' is nil, Tramp is not activated.
+  (let (tramp-mode)
+    (should-not (tramp-tramp-file-p "/method:user@host:")))
+  ;; `tramp-ignored-file-name-regexp' suppresses Tramp.
+  (let ((tramp-ignored-file-name-regexp "^/method:user@host:"))
+    (should-not (tramp-tramp-file-p "/method:user@host:")))
   ;; Methods shall be at least two characters on MS Windows, except
   ;; the default method.
   (let ((system-type 'windows-nt))