From ce4a62eece608f13db2449e5d4e2d38f253663c4 Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Tue, 24 Oct 2023 14:51:04 +0200 Subject: [PATCH] Fix desktop-save on remote dired (bug#66697) Do not gather "misc data" for dired buffer not meant to be desktop saved. lisp/dired.el (dired-desktop-save-p): New function to test if `dired-directory' should be desktop saved. (dired-desktop-buffer-misc-data): Use it. --- lisp/dired.el | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/lisp/dired.el b/lisp/dired.el index 99156b28365..c710e06722f 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -4877,22 +4877,30 @@ Ask means pop up a menu for the user to select one of copy, move or link." (eval-when-compile (require 'desktop)) (declare-function desktop-file-name "desktop" (filename dirname)) +(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)))) + (defun dired-desktop-buffer-misc-data (dirname) "Auxiliary information to be saved in desktop file." - (cons - ;; Value of `dired-directory'. - (if (consp dired-directory) - ;; Directory name followed by list of files. - (cons (desktop-file-name (car dired-directory) dirname) - (cdr dired-directory)) - ;; Directory name, optionally with shell wildcard. - (desktop-file-name dired-directory dirname)) - ;; Subdirectories in `dired-subdir-alist'. - (cdr - (nreverse - (mapcar - (lambda (f) (desktop-file-name (car f) dirname)) - dired-subdir-alist))))) + (when (and (stringp desktop-files-not-to-save) + (dired-desktop-save-p)) + (cons + ;; Value of `dired-directory'. + (if (consp dired-directory) + ;; Directory name followed by list of files. + (cons (desktop-file-name (car dired-directory) dirname) + (cdr dired-directory)) + ;; Directory name, optionally with shell wildcard. + (desktop-file-name dired-directory dirname)) + ;; Subdirectories in `dired-subdir-alist'. + (cdr + (nreverse + (mapcar + (lambda (f) (desktop-file-name (car f) dirname)) + dired-subdir-alist)))))) (defun dired-restore-desktop-buffer (_file-name _buffer-name -- 2.39.2