Subject: Re: bug#66697: 30.0.50; [PATCH] desktop-save-mode with expiring remote buffers

From: Manuel Giraud <[email-masked]>
Date: Sat, 09 Dec 2023 13:05:24 +0100

Eli Zaretskii <[email-masked]> writes:

[...]

> Thanks, but I wonder whether a better way would be to modify
> dired-desktop-save-p such that it handled correctly non-string values
> of desktop-files-not-to-save?  That would make the handling of this
> variable more local, which is better for maintenance, I think.
>
> WDYT?

Sure.  Good idea.  Here is a new version.
-- 
Manuel Giraud
>From b421faf27c38d7ce8d3c4f39df68f21d2eccc735 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <[email-masked]>
Date: Sat, 9 Dec 2023 13:02:19 +0100
Subject: [PATCH] Fix desktop-save for dired buffers (bug#66697)

* lisp/dired.el (dired-desktop-save-p): Move all logic here.  Carry on
when 'desktop-files-not-to-save' is nil.
(dired-desktop-buffer-misc-data): Use it.
---
 lisp/dired.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 7f4b96353ee..36ca54efc37 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -4989,14 +4989,15 @@ dired-dnd-handle-file
 
 (defun dired-desktop-save-p ()
   "Should `dired-directory' be desktop saved?"
-  (if (consp dired-directory)
-      (not (string-match-p desktop-files-not-to-save (car dired-directory)))
-    (not (string-match-p desktop-files-not-to-save dired-directory))))
+  (or (null desktop-files-not-to-save)
+      (and (stringp desktop-files-not-to-save)
+           (if (consp dired-directory)
+               (not (string-match-p desktop-files-not-to-save (car dired-directory)))
+             (not (string-match-p desktop-files-not-to-save dired-directory))))))
 
 (defun dired-desktop-buffer-misc-data (dirname)
   "Auxiliary information to be saved in desktop file."
-  (when (and (stringp desktop-files-not-to-save)
-             (dired-desktop-save-p))
+  (when (dired-desktop-save-p)
     (cons
      ;; Value of `dired-directory'.
      (if (consp dired-directory)
-- 
2.43.0