[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 90696997955: Add inhibit-remote-files and without-remote-files
|
From: |
Michael Albinus |
|
Subject: |
master 90696997955: Add inhibit-remote-files and without-remote-files |
|
Date: |
Sat, 22 Jul 2023 04:16:21 -0400 (EDT) |
branch: master
commit 906969979556ab7963ec9a75fe456e5483952e93
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
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.
---
doc/emacs/files.texi | 7 ++++---
doc/lispref/files.texi | 11 +++++++++++
doc/misc/tramp.texi | 33 +++++++++++++++++++++++----------
etc/NEWS | 25 +++++++++++++++++++++----
lisp/net/tramp.el | 19 +++++++++++++++++++
test/lisp/net/tramp-archive-tests.el | 14 ++++++++++++++
test/lisp/net/tramp-tests.el | 17 ++++++++++++++++-
7 files changed, 108 insertions(+), 18 deletions(-)
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 9734223b95e..ac7751ceb53 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -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}
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 31d4aaca507..aaab4e455a0 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -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
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index ff2a66ae720..1d8e0095328 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index d1af3b1b866..c2c436fb477 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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`.
+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
+*** 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
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 55e1ca932e4..53a80c41680 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -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
diff --git a/test/lisp/net/tramp-archive-tests.el
b/test/lisp/net/tramp-archive-tests.el
index 5485b12f74f..e34e830cb83 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -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)
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 16afc0f477a..9bc8ad8ce39 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -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)
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 90696997955: Add inhibit-remote-files and without-remote-files,
Michael Albinus <=