Subject: bug#31028: closed (Re: bug#31028: 27.0.50; Saving shell buffers to a file makes the desktop file unreadable)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 04 Apr 2018 20:45:02 +0000

Your bug report

#31028: 27.0.50; Saving shell buffers to a file makes the desktop file unreadable

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
31028: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31028
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#31028: 27.0.50; Saving shell buffers to a file makes the desktop file unreadable
From: Juri Linkov <[email-masked]>
To: [email-masked]
Date: Wed, 04 Apr 2018 23:44:07 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> 2. Still save but properly handle shell buffers on reading, i.e. fix shell-mode
>    to check for nil values such as in this patch:

This solution installed to master.

Subject: 27.0.50; Saving shell buffers to a file makes the desktop file unreadable
From: Juri Linkov <[email-masked]>
To: [email-masked]
Date: Mon, 02 Apr 2018 22:48:38 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

1. M-x shell RET
2. C-d (send EOF to exit shell)
3. C-x C-s (save to a file)
4. M-x desktop-save-in-desktop-dir RET
5. Restart Emacs

Loading the desktop file fails because the file buffer is saved with shell-mode,
but on reading shell-mode fails while trying to eval

  (process-command (get-buffer-process (current-buffer)))

where get-buffer-process returns nil that is unacceptable as an arg
to process-command.

Possible solutions:

1. Skip and don't save buffers with shell-mode
   by adding it to the default value of desktop-modes-not-to-save

2. Still save but properly handle shell buffers on reading, i.e. fix shell-mode
   to check for nil values such as in this patch:

diff --git a/lisp/shell.el b/lisp/shell.el
index 5c228a5..d4a0556 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -568,8 +568,10 @@ shell-mode
   (setq list-buffers-directory (expand-file-name default-directory))
   ;; shell-dependent assignments.
   (when (ring-empty-p comint-input-ring)
-    (let ((shell (file-name-nondirectory (car
-		   (process-command (get-buffer-process (current-buffer))))))
+    (let ((shell (if (get-buffer-process (current-buffer))
+                     (file-name-nondirectory
+                      (car (process-command (get-buffer-process (current-buffer)))))
+                   ""))
 	  (hsize (getenv "HISTSIZE")))
       (and (stringp hsize)
 	   (integerp (setq hsize (string-to-number hsize)))