GNU bug report logs - #17351
Trunk emacs splats .emacs.desktop at startup

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Sat, 26 Apr 2014 18:09:02 UTC

Severity: important

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

Full log


Message #32 received at 17351 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Alan Mackenzie <acm <at> muc.de>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 17351 <at> debbugs.gnu.org
Subject: Re: bug#17351: Trunk emacs splats .emacs.desktop at startup
Date: Tue, 24 Jun 2014 01:57:52 +0300
>> This would keep the desktop file open all the time,
>> and users might not like to see it in the buffer list.
>
> So read it into an invisible buffer, set buffer-file-name, and enable
> auto-save-mode.

auto-save-mode doesn't seem necessary because the contents of the
desktop file buffer has to be generated at the given time interval
anyway, so at the end it can be saved as well like in this patch:

=== modified file 'lisp/desktop.el'
--- lisp/desktop.el	2014-06-06 23:38:40 +0000
+++ lisp/desktop.el	2014-06-23 22:45:20 +0000
@@ -1038,8 +1038,15 @@ (defun desktop-save (dirname &optional r
 			     (point))))
 		 (checksum (and beg (md5 (current-buffer) beg (point-max) 'emacs-mule))))
 	    (unless (and checksum (equal checksum desktop-file-checksum))
-	      (let ((coding-system-for-write 'emacs-mule))
-		(write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage))
+	      (let ((coding-system-for-write 'emacs-mule)
+		    (buffer-string (buffer-string)))
+		(with-current-buffer (find-file-noselect (desktop-full-file-name))
+		  ;; Make the buffer invisible
+		  (unless (eq (aref (buffer-name) 0) ?\s)
+		    (rename-buffer (concat " " (buffer-name))))
+		  (erase-buffer)
+		  (insert buffer-string)
+		  (save-buffer)))
 	      (setq desktop-file-checksum checksum)
 	      ;; We remember when it was modified (which is presumably just now).
 	      (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name)))))))))))





This bug report was last modified 10 years and 290 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.