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.
This commit is contained in:
parent
4010631fe9
commit
ab37ceb9ee
4 changed files with 39 additions and 2 deletions
|
@ -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.
|
||||
|
|
4
etc/NEWS
4
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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue