[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#71905: 29.2.50; recover-session fails to disable dired-omit-mode if
From: |
Juri Linkov |
Subject: |
bug#71905: 29.2.50; recover-session fails to disable dired-omit-mode if the latter is set globally |
Date: |
Tue, 02 Jul 2024 21:27:03 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) |
> When dired-omit-mode is set non-nil globally, recover-session fails to
> show any auto-save files because they continue to be omitted.
>
> For example, running this command:
>
> emacs -Q -l dired-x --eval "(setopt dired-omit-mode t)" -f recover-session
>
> I see no files listed in the dired buffer, but toggling
> dired-omit-mode shows them.
>
> I see that recover-session has this bit of code:
>
> (let ((ls-lisp-support-shell-wildcards t)
> ;; Ensure that we don't omit the session files as the user may
> ;; have (as suggested by the manual) `dired-omit-mode' in the
> ;; hook.
> (dired-mode-hook (delete 'dired-omit-mode dired-mode-hook)))
>
> This seems incorrect as well, since it would destructively modify the
> user's preferred dired-mode-hook. It seems that changing delete to
> remove should be fine, and then binding dired-omit-mode to nil, should
> do the trick, regardless of how the user enables dired-omit-mode.
Indeed, handling of dired-omit-mode in recover-session is wrong.
For example, I'm using a lambda and it fails. Therefore needed
to rely on such patch:
diff --git a/lisp/files.el b/lisp/files.el
index 042b8e2d515..7c291b3f54c 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -7263,7 +7263,7 @@ recover-file
(after-find-file nil nil t))
(t (user-error "Recover-file canceled")))))
-(defvar dired-mode-hook)
+(declare-function dired-omit-mode "dired-x" (&optional arg))
(defun recover-session ()
"Recover auto save files from a previous Emacs session.
@@ -7284,14 +7284,11 @@ recover-session
(concat "\\`" (regexp-quote nd)))
t)
(error "No previous sessions to recover")))
- (require 'dired)
- (let ((ls-lisp-support-shell-wildcards t)
- ;; Ensure that we don't omit the session files as the user may
- ;; have (as suggested by the manual) `dired-omit-mode' in the
- ;; hook.
- (dired-mode-hook (delete 'dired-omit-mode dired-mode-hook)))
+ (let ((ls-lisp-support-shell-wildcards t))
(dired (concat auto-save-list-file-prefix "*")
- (concat (connection-local-value dired-listing-switches) " -t")))
+ (concat (connection-local-value dired-listing-switches) " -t"))
+ (when (bound-and-true-p dired-omit-mode)
+ (dired-omit-mode -1)))
(use-local-map (nconc (make-sparse-keymap) (current-local-map)))
(define-key (current-local-map) "\C-c\C-c" 'recover-session-finish)
(save-excursion