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

From: Juri Linkov <[email-masked]>
Date: Mon, 02 Apr 2018 22:48:38 +0300

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)))