Subject: 24.1; (wrong-type-argument processp nil) in `shell-mode'

From: "Drew Adams" <[email-masked]>
Date: Mon, 9 Jul 2012 08:36:30 -0700

I am seeing this in my own setup.  Have not yet been able to repro
starting with emacs -Q (see below at end).  But hopefully this report
will help anyway.
 
I visit an Emacs-Lisp file foo.el, then `M-x shell-mode'.  Yes, I imagine
that that is not an expected user interaction.  Still, the error message
shown does not seem appropriate (low-level).
 
This is the backtrace:
 
Debugger entered--Lisp error: (wrong-type-argument processp nil)
* process-command(nil)
* (car (process-command (get-buffer-process (current-buffer))))
* (file-name-nondirectory (car (process-command (get-buffer-process (curren=
t-buffer)))))
* (let ((shell (file-name-nondirectory (car (process-command (get-buffer-pr=
ocess (current-buffer)))))) (hsize (getenv "HISTSIZE"))) (and (stringp hsiz=
e) (integerp (setq hsize (string-to-number hsize))) (> hsize 0) (set (make-=
local-variable (quote comint-input-ring-size)) hsize)) (setq comint-input-r=
ing-file-name (or (getenv "HISTFILE") (cond ((string-equal shell "bash") "~=
/.bash_history") ((string-equal shell "ksh") "~/.sh_history") (t "~/.histor=
y")))) (if (or (equal comint-input-ring-file-name "") (equal (file-truename=
 comint-input-ring-file-name) (file-truename "/dev/null"))) (setq comint-in=
put-ring-file-name nil)) (if (and comint-input-ring-file-name (string-match=
 shell-dumb-shell-regexp shell)) (set-process-sentinel (get-buffer-process =
(current-buffer)) (function shell-write-history-on-exit))) (setq shell-dirs=
tack-query (cond ((string-equal shell "sh") "pwd") ((string-equal shell "ks=
h") "echo $PWD ~-") (t "dirs"))) (when (string-equal shell "bash") (add-hoo=
k (quote comint-preoutput-filter-functions) (quote shell-filter-ctrl-a-ctrl=
-b) nil t)))
* (progn (let ((shell (file-name-nondirectory (car (process-command (get-bu=
ffer-process ...))))) (hsize (getenv "HISTSIZE"))) (and (stringp hsize) (in=
tegerp (setq hsize (string-to-number hsize))) (> hsize 0) (set (make-local-=
variable (quote comint-input-ring-size)) hsize)) (setq comint-input-ring-fi=
le-name (or (getenv "HISTFILE") (cond ((string-equal shell "bash") "~/.bash=
_history") ((string-equal shell "ksh") "~/.sh_history") (t "~/.history"))))=
 (if (or (equal comint-input-ring-file-name "") (equal (file-truename comin=
t-input-ring-file-name) (file-truename "/dev/null"))) (setq comint-input-ri=
ng-file-name nil)) (if (and comint-input-ring-file-name (string-match shell=
-dumb-shell-regexp shell)) (set-process-sentinel (get-buffer-process (curre=
nt-buffer)) (function shell-write-history-on-exit))) (setq shell-dirstack-q=
uery (cond ((string-equal shell "sh") "pwd") ((string-equal shell "ksh") "e=
cho $PWD ~-") (t "dirs"))) (when (string-equal shell "bash") (add-hook (quo=
te comint-preoutput-filter-functions) (quote shell-filter-ctrl-a-ctrl-b) ni=
l t))) (comint-read-input-ring t))
* (if (ring-empty-p comint-input-ring) (progn (let ((shell (file-name-nondi=
rectory (car (process-command ...)))) (hsize (getenv "HISTSIZE"))) (and (st=
ringp hsize) (integerp (setq hsize (string-to-number hsize))) (> hsize 0) (=
set (make-local-variable (quote comint-input-ring-size)) hsize)) (setq comi=
nt-input-ring-file-name (or (getenv "HISTFILE") (cond ((string-equal shell =
"bash") "~/.bash_history") ((string-equal shell "ksh") "~/.sh_history") (t =
"~/.history")))) (if (or (equal comint-input-ring-file-name "") (equal (fil=
e-truename comint-input-ring-file-name) (file-truename "/dev/null"))) (setq=
 comint-input-ring-file-name nil)) (if (and comint-input-ring-file-name (st=
ring-match shell-dumb-shell-regexp shell)) (set-process-sentinel (get-buffe=
r-process (current-buffer)) (function shell-write-history-on-exit))) (setq =
shell-dirstack-query (cond ((string-equal shell "sh") "pwd") ((string-equal=
 shell "ksh") "echo $PWD ~-") (t "dirs"))) (when (string-equal shell "bash"=
) (add-hook (quote comint-preoutput-filter-functions) (quote shell-filter-c=
trl-a-ctrl-b) nil t))) (comint-read-input-ring t)))
* (when (ring-empty-p comint-input-ring) (let ((shell (file-name-nondirecto=
ry (car (process-command (get-buffer-process ...))))) (hsize (getenv "HISTS=
IZE"))) (and (stringp hsize) (integerp (setq hsize (string-to-number hsize)=
)) (> hsize 0) (set (make-local-variable (quote comint-input-ring-size)) hs=
ize)) (setq comint-input-ring-file-name (or (getenv "HISTFILE") (cond ((str=
ing-equal shell "bash") "~/.bash_history") ((string-equal shell "ksh") "~/.=
sh_history") (t "~/.history")))) (if (or (equal comint-input-ring-file-name=
 "") (equal (file-truename comint-input-ring-file-name) (file-truename "/de=
v/null"))) (setq comint-input-ring-file-name nil)) (if (and comint-input-ri=
ng-file-name (string-match shell-dumb-shell-regexp shell)) (set-process-sen=
tinel (get-buffer-process (current-buffer)) (function shell-write-history-o=
n-exit))) (setq shell-dirstack-query (cond ((string-equal shell "sh") "pwd"=
) ((string-equal shell "ksh") "echo $PWD ~-") (t "dirs"))) (when (string-eq=
ual shell "bash") (add-hook (quote comint-preoutput-filter-functions) (quot=
e shell-filter-ctrl-a-ctrl-b) nil t))) (comint-read-input-ring t))
* (let ((delay-mode-hooks t)) (comint-mode) (setq major-mode (quote shell-m=
ode)) (setq mode-name "Shell") (progn (if (get (quote comint-mode) (quote m=
ode-class)) (put (quote shell-mode) (quote mode-class) (get (quote comint-m=
ode) (quote mode-class)))) (unless (keymap-parent shell-mode-map) (set-keym=
ap-parent shell-mode-map (current-local-map))) (let ((parent (char-table-pa=
rent shell-mode-syntax-table))) (unless (and parent (not (eq parent (standa=
rd-syntax-table)))) (set-char-table-parent shell-mode-syntax-table (syntax-=
table)))) (unless (or (abbrev-table-get shell-mode-abbrev-table :parents) (=
eq shell-mode-abbrev-table local-abbrev-table)) (abbrev-table-put shell-mod=
e-abbrev-table :parents (list local-abbrev-table)))) (use-local-map shell-m=
ode-map) (set-syntax-table shell-mode-syntax-table) (setq local-abbrev-tabl=
e shell-mode-abbrev-table) (setq comint-prompt-regexp shell-prompt-pattern)=
 (shell-completion-vars) (set (make-local-variable (quote paragraph-separat=
e)) "\\'") (set (make-local-variable (quote paragraph-start)) comint-prompt=
-regexp) (set (make-local-variable (quote font-lock-defaults)) (quote (shel=
l-font-lock-keywords t))) (set (make-local-variable (quote shell-dirstack))=
 nil) (set (make-local-variable (quote shell-last-dir)) nil) (shell-dirtrac=
k-mode 1) (set (make-local-variable (quote ansi-color-apply-face-function))=
 (lambda (beg end face) (when face (put-text-property beg end (quote font-l=
ock-face) face)))) (setq list-buffers-directory (expand-file-name default-d=
irectory)) (when (ring-empty-p comint-input-ring) (let ((shell (file-name-n=
ondirectory (car (process-command ...)))) (hsize (getenv "HISTSIZE"))) (and=
 (stringp hsize) (integerp (setq hsize (string-to-number hsize))) (> hsize =
0) (set (make-local-variable (quote comint-input-ring-size)) hsize)) (setq =
comint-input-ring-file-name (or (getenv "HISTFILE") (cond ((string-equal sh=
ell "bash") "~/.bash_history") ((string-equal shell "ksh") "~/.sh_history")=
 (t "~/.history")))) (if (or (equal comint-input-ring-file-name "") (equal =
(file-truename comint-input-ring-file-name) (file-truename "/dev/null"))) (=
setq comint-input-ring-file-name nil)) (if (and comint-input-ring-file-name=
 (string-match shell-dumb-shell-regexp shell)) (set-process-sentinel (get-b=
uffer-process (current-buffer)) (function shell-write-history-on-exit))) (s=
etq shell-dirstack-query (cond ((string-equal shell "sh") "pwd") ((string-e=
qual shell "ksh") "echo $PWD ~-") (t "dirs"))) (when (string-equal shell "b=
ash") (add-hook (quote comint-preoutput-filter-functions) (quote shell-filt=
er-ctrl-a-ctrl-b) nil t))) (comint-read-input-ring t)))
* (progn (make-local-variable (quote delay-mode-hooks)) (let ((delay-mode-h=
ooks t)) (comint-mode) (setq major-mode (quote shell-mode)) (setq mode-name=
 "Shell") (progn (if (get (quote comint-mode) (quote mode-class)) (put (quo=
te shell-mode) (quote mode-class) (get (quote comint-mode) (quote mode-clas=
s)))) (unless (keymap-parent shell-mode-map) (set-keymap-parent shell-mode-=
map (current-local-map))) (let ((parent (char-table-parent shell-mode-synta=
x-table))) (unless (and parent (not (eq parent ...))) (set-char-table-paren=
t shell-mode-syntax-table (syntax-table)))) (unless (or (abbrev-table-get s=
hell-mode-abbrev-table :parents) (eq shell-mode-abbrev-table local-abbrev-t=
able)) (abbrev-table-put shell-mode-abbrev-table :parents (list local-abbre=
v-table)))) (use-local-map shell-mode-map) (set-syntax-table shell-mode-syn=
tax-table) (setq local-abbrev-table shell-mode-abbrev-table) (setq comint-p=
rompt-regexp shell-prompt-pattern) (shell-completion-vars) (set (make-local=
-variable (quote paragraph-separate)) "\\'") (set (make-local-variable (quo=
te paragraph-start)) comint-prompt-regexp) (set (make-local-variable (quote=
 font-lock-defaults)) (quote (shell-font-lock-keywords t))) (set (make-loca=
l-variable (quote shell-dirstack)) nil) (set (make-local-variable (quote sh=
ell-last-dir)) nil) (shell-dirtrack-mode 1) (set (make-local-variable (quot=
e ansi-color-apply-face-function)) (lambda (beg end face) (when face (put-t=
ext-property beg end (quote font-lock-face) face)))) (setq list-buffers-dir=
ectory (expand-file-name default-directory)) (when (ring-empty-p comint-inp=
ut-ring) (let ((shell (file-name-nondirectory (car ...))) (hsize (getenv "H=
ISTSIZE"))) (and (stringp hsize) (integerp (setq hsize (string-to-number hs=
ize))) (> hsize 0) (set (make-local-variable (quote comint-input-ring-size)=
) hsize)) (setq comint-input-ring-file-name (or (getenv "HISTFILE") (cond (=
... "~/.bash_history") (... "~/.sh_history") (t "~/.history")))) (if (or (e=
qual comint-input-ring-file-name "") (equal (file-truename comint-input-rin=
g-file-name) (file-truename "/dev/null"))) (setq comint-input-ring-file-nam=
e nil)) (if (and comint-input-ring-file-name (string-match shell-dumb-shell=
-regexp shell)) (set-process-sentinel (get-buffer-process (current-buffer))=
 (function shell-write-history-on-exit))) (setq shell-dirstack-query (cond =
((string-equal shell "sh") "pwd") ((string-equal shell "ksh") "echo $PWD ~-=
") (t "dirs"))) (when (string-equal shell "bash") (add-hook (quote comint-p=
reoutput-filter-functions) (quote shell-filter-ctrl-a-ctrl-b) nil t))) (com=
int-read-input-ring t))))
* (delay-mode-hooks (comint-mode) (setq major-mode (quote shell-mode)) (set=
q mode-name "Shell") (progn (if (get (quote comint-mode) (quote mode-class)=
) (put (quote shell-mode) (quote mode-class) (get (quote comint-mode) (quot=
e mode-class)))) (unless (keymap-parent shell-mode-map) (set-keymap-parent =
shell-mode-map (current-local-map))) (let ((parent (char-table-parent shell=
-mode-syntax-table))) (unless (and parent (not (eq parent (standard-syntax-=
table)))) (set-char-table-parent shell-mode-syntax-table (syntax-table)))) =
(unless (or (abbrev-table-get shell-mode-abbrev-table :parents) (eq shell-m=
ode-abbrev-table local-abbrev-table)) (abbrev-table-put shell-mode-abbrev-t=
able :parents (list local-abbrev-table)))) (use-local-map shell-mode-map) (=
set-syntax-table shell-mode-syntax-table) (setq local-abbrev-table shell-mo=
de-abbrev-table) (setq comint-prompt-regexp shell-prompt-pattern) (shell-co=
mpletion-vars) (set (make-local-variable (quote paragraph-separate)) "\\'")=
 (set (make-local-variable (quote paragraph-start)) comint-prompt-regexp) (=
set (make-local-variable (quote font-lock-defaults)) (quote (shell-font-loc=
k-keywords t))) (set (make-local-variable (quote shell-dirstack)) nil) (set=
 (make-local-variable (quote shell-last-dir)) nil) (shell-dirtrack-mode 1) =
(set (make-local-variable (quote ansi-color-apply-face-function)) (lambda (=
beg end face) (when face (put-text-property beg end (quote font-lock-face) =
face)))) (setq list-buffers-directory (expand-file-name default-directory))=
 (when (ring-empty-p comint-input-ring) (let ((shell (file-name-nondirector=
y (car (process-command ...)))) (hsize (getenv "HISTSIZE"))) (and (stringp =
hsize) (integerp (setq hsize (string-to-number hsize))) (> hsize 0) (set (m=
ake-local-variable (quote comint-input-ring-size)) hsize)) (setq comint-inp=
ut-ring-file-name (or (getenv "HISTFILE") (cond ((string-equal shell "bash"=
) "~/.bash_history") ((string-equal shell "ksh") "~/.sh_history") (t "~/.hi=
story")))) (if (or (equal comint-input-ring-file-name "") (equal (file-true=
name comint-input-ring-file-name) (file-truename "/dev/null"))) (setq comin=
t-input-ring-file-name nil)) (if (and comint-input-ring-file-name (string-m=
atch shell-dumb-shell-regexp shell)) (set-process-sentinel (get-buffer-proc=
ess (current-buffer)) (function shell-write-history-on-exit))) (setq shell-=
dirstack-query (cond ((string-equal shell "sh") "pwd") ((string-equal shell=
 "ksh") "echo $PWD ~-") (t "dirs"))) (when (string-equal shell "bash") (add=
-hook (quote comint-preoutput-filter-functions) (quote shell-filter-ctrl-a-=
ctrl-b) nil t))) (comint-read-input-ring t)))
  shell-mode()
* call-interactively(shell-mode t nil)
  execute-extended-command(nil)
  call-interactively(execute-extended-command nil nil)
 
Clearly, this code in shell.el is not tolerant of there being no process:
 
(file-name-nondirectory
 (car (process-command (get-buffer-process (current-buffer)))))
 
I imagine that it should be, or rather that it should perhaps raise an
error with a more suitable message.
 
When I try with emacs -Q, and then load cygwin-mount.el, then load
setup-cygwin.el, and then do `M-x shell-mode', I get no such error.  The
buffer is put in the proper mode (the mode-line lighter is
"Shell-script[bash]", and I get the message "Indentation setup for shell
type bash").

In GNU Emacs 24.1.1 (i386-mingw-nt5.1.2600)
 of 2012-06-10 on MARVIN
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (4.6) --cflags
 -ID:/devel/emacs/libs/libXpm-3.5.8/include
 -ID:/devel/emacs/libs/libXpm-3.5.8/src
 -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
 -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
 -ID:/devel/emacs/libs/giflib-4.1.4-1/include
 -ID:/devel/emacs/libs/jpeg-6b-4/include
 -ID:/devel/emacs/libs/tiff-3.8.2-1/include
 -ID:/devel/emacs/libs/gnutls-3.0.9/include'