emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master ab37ceb: Fix Bug#31489


From: Michael Albinus
Subject: [Emacs-diffs] master ab37ceb: Fix Bug#31489
Date: Mon, 21 May 2018 13:48:27 -0400 (EDT)

branch: master
commit ab37ceb9eecdd20b913d1b2b00d81e8f83e1caf7
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    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.
---
 doc/misc/tramp.texi          | 16 ++++++++++++++++
 etc/NEWS                     |  4 ++++
 lisp/net/tramp.el            | 15 +++++++++++++--
 test/lisp/net/tramp-tests.el |  6 ++++++
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 329c46b..5dd1a2c 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -3994,6 +3994,7 @@ in @file{.emacs}:
 @end lisp
 
 @item
address@hidden 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}.
@@ -4003,6 +4004,21 @@ To disable both @value{tramp} (and Ange FTP), set 
@code{tramp-mode} to
 @end lisp
 
 @item
address@hidden tramp-ignored-file-name-regexp
+To deactivate @value{tramp} for some look-alike remote file names, set
address@hidden to a proper regexp in
address@hidden  @strong{Note}, that we don't use
address@hidden, in order to avoid loading
address@hidden
+
address@hidden
+(setq tramp-ignored-file-name-regexp "\\`/ssh:example\\.com:")
address@hidden 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:}.
+
address@hidden
 To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp @key{RET}}.
 Unloading @value{tramp} resets Ange FTP plugins also.
 @end itemize
diff --git a/etc/NEWS b/etc/NEWS
index ae8a366..4cb31ef 100644
--- 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.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index e14a515..499fcad 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
 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
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 2c0b319..65ffcb3 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."
   (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:address@hidden:")))
+  ;; `tramp-ignored-file-name-regexp' suppresses Tramp.
+  (let ((tramp-ignored-file-name-regexp "^/method:address@hidden:"))
+    (should-not (tramp-tramp-file-p "/method:address@hidden:")))
   ;; Methods shall be at least two characters on MS Windows, except
   ;; the default method.
   (let ((system-type 'windows-nt))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]