Add inhibit-remote-files and without-remote-files

* doc/emacs/files.texi (Remote Files): Do not document tramp-mode
any longer.  Describe inhibit-remote-files instead.

* doc/lispref/files.texi (Magic File Names): Add without-remote-files.

* doc/misc/tramp.texi (Frequently Asked Questions): Do not
document tramp-mode any longer.  Describe inhibit-remote-files and
without-remote-files instead.

* etc/NEWS: Add inhibit-remote-files and without-remote-files.
Fix typos.

* lisp/net/tramp.el (inhibit-remote-files): New defun.
(without-remote-files): New defmacro.

* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test49-without-remote-files):
* test/lisp/net/tramp-tests.el (tramp-test49-without-remote-files):
New tests.
(tramp-test50-unload): Rename.
This commit is contained in:
Michael Albinus 2023-07-22 10:16:04 +02:00
parent b6207ee4dc
commit 9069699795
7 changed files with 109 additions and 19 deletions

View file

@ -2093,10 +2093,11 @@ Otherwise, Emacs uses @command{ssh}.
@end enumerate
@cindex disabling remote files
@cindex inhibit-remote-files
@noindent
You can entirely turn off the remote file name feature by setting the
variable @code{tramp-mode} to @code{nil}. You can turn off the
feature in individual cases by quoting the file name with @samp{/:}
You can entirely turn off the remote file name feature by running
@kbd{M-x inhibit-remote-files}. You can turn off the feature in
individual cases by quoting the file name with @samp{/:}
(@pxref{Quoted File Names}).
@cindex @code{ange-ftp}

View file

@ -3698,6 +3698,17 @@ between consecutive checks. For example:
@end example
@end defopt
@defmac without-remote-files body@dots{}
The @code{without-remote-files} macro evaluates the @var{body} forms
with deactivated file name handlers for remote files. Those file
names would be handled literally.
The macro should be used only in forms where it is obvious, that
remote files cannot appear or where it is intended not to handle
remote file names. It also reduces checks with
@code{file-name-handler-alist}, resulting in more performant code.
@end defmac
@node Format Conversion
@section File Format Conversion

View file

@ -5851,16 +5851,6 @@ If you want to enable Ange FTP's syntax, add the following form:
(tramp-change-syntax 'simplified)
@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}.
@lisp
(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
@ -5877,6 +5867,29 @@ 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
@findex inhibit-remote-files
To disable both @value{tramp} (and Ange FTP), type @kbd{M-x
inhibit-remote-files @key{RET}}. You can also add this to your
@file{.emacs}.
@lisp
(inhibit-remote-files)
@end lisp
@item
@findex without-remote-files
If you write code, which is intended to run only for local files, you
can use the @code{without-remote-files} macro.
@lisp
(without-remote-files @dots{})
@end lisp
This improves performance, because many primitive file name operations
don't check any longer for Tramp file name regexps then.
@item
@findex tramp-unload-tramp
To unload @value{tramp}, type @kbd{M-x tramp-unload-tramp @key{RET}}.
Unloading @value{tramp} resets Ange FTP plugins also.
@end itemize

View file

@ -93,11 +93,12 @@ The 'tool-bar-position' frame parameter can be set to 'bottom' on all
window systems other than Nextstep.
** cl-print
*** You can expand the "..." truncation everywhere.
The code that allowed "..." to be expanded in the *Backtrace* should
now work anywhere the data is generated by `cl-print`.
*** hash-tables' contents can be expanded via the ellipsis
*** You can expand the "..." truncation everywhere.
The code that allowed "..." to be expanded in the "*Backtrace*" buffer
should now work anywhere the data is generated by 'cl-print'.
*** hash-tables' contents can be expanded via the ellipsis.
** Modeline elements can now be right-aligned.
Anything following the symbol 'mode-line-format-right-align' in
@ -264,6 +265,8 @@ docstring, or a comment, or (re)indents the surrounding defun if
point is not in a comment or a string. It is by default bound to
'M-q' in 'prog-mode' and all its descendants.
** Which Function Mode
+++
*** Which Function Mode can now display function names on the header line.
The new user option 'which-func-display' allows choosing where the
@ -300,6 +303,19 @@ sessions, respectively.
It allows to kill only selected remote buffers, controlled by user
option 'tramp-cleanup-some-buffers-hook'.
+++
*** New command 'inhibit-remote-files'.
This command disables the handling of file names with the special
remote file name syntax. It should be applied only when remote files
won't be used in this Emacs instance. It provides a slightly improved
performance of file name handling in Emacs.
+++
*** New macro 'without-remote-files'.
This macro could wrap code which handles local files only. Due to the
temporary deactivation of remote files, it results in a slightly
improved performance of file name handling in Emacs.
** EWW
+++
@ -602,7 +618,7 @@ behavior back for any other reason, you can do that using the
'coding-system-put' function. For example, the following restores the
previous behavior of showing 'U' in the mode line for 'koi8-u':
(coding-system-put 'koi8-u :mnemonic ?U)
(coding-system-put 'koi8-u :mnemonic ?U)
+++
** Infinities and NaNs no longer act as symbols on non-IEEE platforms.
@ -611,6 +627,7 @@ tokens like 0.0e+NaN and 1.0e+INF are no longer read as symbols.
Instead, the Lisp reader approximates an infinity with the nearest
finite value, and a NaN with some other non-numeric object that
provokes an error if used numerically.
* Lisp Changes in Emacs 30.1

View file

@ -2967,6 +2967,25 @@ whether HANDLER is to be called. Add operations defined in
(put #'tramp-unload-file-name-handlers 'tramp-autoload t)
(add-hook 'tramp-unload-hook #'tramp-unload-file-name-handlers)
;;;###autoload
(progn (defun inhibit-remote-files ()
"Deactivate remote file names."
(interactive)
(when (fboundp 'tramp-cleanup-all-connections)
(funcall 'tramp-cleanup-all-connections))
(tramp-unload-file-name-handlers)
(setq tramp-mode nil)))
;;;###autoload
(progn (defmacro without-remote-files (&rest body)
"Deactivate remote file names temporarily.
Run BODY."
(declare (indent 0) (debug ((form body) body)))
`(let ((file-name-handler-alist (copy-tree file-name-handler-alist))
tramp-mode)
(tramp-unload-file-name-handlers)
,@body)))
;;; File name handler functions for completion mode:
;; This function takes action since Emacs 28.1, when

View file

@ -988,6 +988,20 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
code tae tramp-archive-test-file-archive
(concat tramp-archive-test-archive "foo"))))))))))
(ert-deftest tramp-archive-test49-without-remote-files ()
"Check that Tramp can be suppressed."
(skip-unless tramp-archive-enabled)
(should (file-exists-p tramp-archive-test-archive))
(should-not (without-remote-files (file-exists-p tramp-archive-test-archive)))
(should (file-exists-p tramp-archive-test-archive))
(inhibit-remote-files)
(should-not (file-exists-p tramp-archive-test-archive))
(tramp-register-file-name-handlers)
(setq tramp-mode t)
(should (file-exists-p tramp-archive-test-archive)))
(ert-deftest tramp-archive-test99-libarchive-tests ()
"Run tests of libarchive test files."
:tags '(:expensive-test :unstable)

View file

@ -8009,7 +8009,22 @@ process sentinels. They shall not disturb each other."
(mapconcat #'shell-quote-argument load-path " -L ")
(shell-quote-argument code)))))))
(ert-deftest tramp-test49-unload ()
(ert-deftest tramp-test49-without-remote-files ()
"Check that Tramp can be suppressed."
(skip-unless (tramp--test-enabled))
(should (file-remote-p ert-remote-temporary-file-directory))
(should-not
(without-remote-files (file-remote-p ert-remote-temporary-file-directory)))
(should (file-remote-p ert-remote-temporary-file-directory))
(inhibit-remote-files)
(should-not (file-remote-p ert-remote-temporary-file-directory))
(tramp-register-file-name-handlers)
(setq tramp-mode t)
(should (file-remote-p ert-remote-temporary-file-directory)))
(ert-deftest tramp-test50-unload ()
"Check that Tramp and its subpackages unload completely.
Since it unloads Tramp, it shall be the last test to run."
:tags '(:expensive-test)