Apply remote-file-name-access-timeout in desktop.el and recentf.el
* doc/emacs/files.texi (File Conveniences): * doc/emacs/misc.texi (Saving Emacs Sessions): Mention remote-file-name-access-timeout. * doc/misc/tramp.texi (Frequently Asked Questions): Add note. * etc/NEWS: Explain use of 'remote-file-name-access-timeout' in desktop.el and recentf.el. * lisp/desktop.el (desktop-access-file): New defun. (desktop-restore-file-buffer): Use it. * lisp/recentf.el (recentf-access-file): New defun. (recentf-keep-default-predicate): Use it. * lisp/net/tramp.el (tramp-handle-access-file): Improve error handling.
This commit is contained in:
parent
793a416653
commit
b34f9a4439
7 changed files with 52 additions and 5 deletions
|
@ -2255,6 +2255,12 @@ to visit one of these files. @kbd{M-x recentf-save-list} saves the
|
|||
current @code{recentf-list} to a file, and @kbd{M-x recentf-edit-list}
|
||||
edits it.
|
||||
|
||||
@vindex remote-file-name-access-timeout
|
||||
If you use remote files, you might also consider to customize
|
||||
@code{remote-file-name-access-timeout} to a proper value (number of
|
||||
seconds), after which time a check whether a remote file shall be used
|
||||
in Recentf is stopped. This prevents Emacs to be blocked.
|
||||
|
||||
@c FIXME partial-completion-mode (complete.el) is obsolete.
|
||||
The @kbd{M-x ffap} command generalizes @code{find-file} with more
|
||||
powerful heuristic defaults (@pxref{FFAP}), often based on the text at
|
||||
|
|
|
@ -2812,9 +2812,13 @@ frame parameters you don't want to be restored; they will then be set
|
|||
according to your customizations in the init file.
|
||||
|
||||
@vindex desktop-files-not-to-save
|
||||
@vindex remote-file-name-access-timeout
|
||||
Information about buffers visiting remote files is not saved by
|
||||
default. Customize the variable @code{desktop-files-not-to-save} to
|
||||
change this.
|
||||
change this. In this case, you might also consider to customize
|
||||
@code{remote-file-name-access-timeout} to a proper value (number of
|
||||
seconds), after which time a buffer restoration of a remote file is
|
||||
stopped. This prevents Emacs to be blocked.
|
||||
|
||||
@vindex desktop-restore-eager
|
||||
By default, all the buffers in the desktop are restored in one go.
|
||||
|
|
|
@ -5181,6 +5181,11 @@ If the connection to the remote host isn't established yet, and if
|
|||
this requires an interactive password, the timeout check doesn't work
|
||||
properly.
|
||||
|
||||
@c Since Emacs 30.
|
||||
@strong{Note}: In recent versions of Emacs, both packages apply
|
||||
already this check. You just need to customize
|
||||
@code{remote-file-name-access-timeout}.
|
||||
|
||||
|
||||
@item
|
||||
Does @value{tramp} support @acronym{SSH} security keys?
|
||||
|
|
18
etc/NEWS
18
etc/NEWS
|
@ -454,6 +454,24 @@ which makes them visually distinct from subroutine prototypes.
|
|||
CPerl mode supports the new keywords for exception handling and the
|
||||
object oriented syntax which were added in Perl 5.36 and 5.38.
|
||||
|
||||
** Emacs Sessions (Desktop)
|
||||
|
||||
+++
|
||||
*** Restoring buffers with remote files should not block.
|
||||
When a buffer is restored which uses a remote file, the user option
|
||||
'remote-file-name-access-timeout' could be set to a positive number.
|
||||
This value will be used as timeout (in seconds) for checking, whether
|
||||
the remote file is accessible.
|
||||
|
||||
** Recentf
|
||||
|
||||
+++
|
||||
*** Checking recent remote files should not block.
|
||||
When a a remote file is checked in 'recentf-list', the user option
|
||||
'remote-file-name-access-timeout' could be set to a positive number.
|
||||
This value will be used as timeout (in seconds) for checking, whether
|
||||
the remote file is accessible.
|
||||
|
||||
|
||||
* New Modes and Packages in Emacs 30.1
|
||||
|
||||
|
|
|
@ -1499,6 +1499,11 @@ This function is called from `window-configuration-change-hook'."
|
|||
(desktop-clear)
|
||||
(desktop-read desktop-dirname))
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
(defun desktop-access-file (filename)
|
||||
"Check whether FILENAME is accessible."
|
||||
(ignore-errors (not (access-file filename "Restoring desktop buffer"))))
|
||||
|
||||
(defvar desktop-buffer-major-mode)
|
||||
(defvar desktop-buffer-locals)
|
||||
(defvar auto-insert) ; from autoinsert.el
|
||||
|
@ -1508,8 +1513,8 @@ This function is called from `window-configuration-change-hook'."
|
|||
_buffer-misc)
|
||||
"Restore a file buffer."
|
||||
(when buffer-filename
|
||||
(if (or (file-exists-p buffer-filename)
|
||||
(let ((msg (format "Desktop: File \"%s\" no longer exists."
|
||||
(if (or (desktop-access-file buffer-filename)
|
||||
(let ((msg (format "Desktop: File \"%s\" no longer accessible."
|
||||
buffer-filename)))
|
||||
(if desktop-missing-file-warning
|
||||
(y-or-n-p (concat msg " Re-create buffer? "))
|
||||
|
|
|
@ -3993,9 +3993,14 @@ Let-bind it when necessary.")
|
|||
(with-parsed-tramp-file-name filename v
|
||||
(with-tramp-timeout
|
||||
(timeout
|
||||
(unless (when-let ((p (tramp-get-connection-process v)))
|
||||
(and (process-live-p p)
|
||||
(tramp-get-connection-property p "connected")))
|
||||
(tramp-cleanup-connection v 'keep-debug 'keep-password))
|
||||
(tramp-error
|
||||
v 'file-error
|
||||
(format "%s: Timeout %s second(s) accessing %s" string timeout filename)))
|
||||
(format
|
||||
"%s: Timeout %s second(s) accessing %s" string timeout filename)))
|
||||
(setq filename (file-truename filename))
|
||||
(if (file-exists-p filename)
|
||||
(unless
|
||||
|
|
|
@ -112,11 +112,15 @@ must return non-nil to exclude it."
|
|||
:group 'recentf
|
||||
:type '(repeat (choice regexp function)))
|
||||
|
||||
(defun recentf-access-file (filename)
|
||||
"Check whether FILENAME is accessible."
|
||||
(ignore-errors (not (access-file filename "Checking recentf file"))))
|
||||
|
||||
(defun recentf-keep-default-predicate (file)
|
||||
"Return non-nil if FILE should be kept in the recent list.
|
||||
It handles the case of remote files as well."
|
||||
(cond
|
||||
((file-remote-p file nil t) (file-readable-p file))
|
||||
((file-remote-p file nil t) (recentf-access-file file))
|
||||
((file-remote-p file))
|
||||
((file-readable-p file))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue