aemoncannon/ensime — Issue #207: Ensime fails on unsaved buffers (Error in modeline update: (wrong-type-argument arrayp nil))
Author: zane
Created: 2011-11-21 14:12:30+00:00
State: open

Ensime chokes when trying to set the modeline if it is active on a buffer that has no associated file on disk (for example, the scratch buffer). When active on such a buffer the following error message appears repeatedly:

Error in modeline update: (wrong-type-argument arrayp nil)

The error message is from an exception being thrown in `ensime-owning-connection-for-source-file`:

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
file-truename(nil)
(let ((file (file-truename file-in))) (when file (catch (quote return) (dolist (conn ensime-net-processes) (when-let (conn (ensime-validated-connection conn)) (let* ((config ...) (project-root ...) (source-roots ...)) (if (and loose ...) (throw ... conn) (dolist ... ...))))))))
ensime-owning-connection-for-source-file(nil)
(ensime-validated-connection (ensime-owning-connection-for-source-file buffer-file-name))
(or (ensime-validated-connection ensime-dispatching-connection) (ensime-validated-connection ensime-buffer-connection) (ensime-validated-connection (ensime-owning-connection-for-source-file buffer-file-name)))
ensime-current-connection()
(let ((conn (ensime-current-connection))) (cond ((and ensime-mode (not conn)) (cond ((ensime-probable-owning-connection-for-source-file buffer-file-name) " [ENSIME: Connected...]") (t " [ENSIME: No Connection]"))) ((and ensime-mode (ensime-connected-p conn)) (concat " " "[ENSIME: " (or (plist-get (ensime-config conn) :project-name) "Connected...") (let ((status (ensime-modeline-state-string conn)) (unready (not ...))) (cond (status (concat " (" status ")")) (unready " (analyzing...)") (t ""))) (concat (format " : %s/%s" (ensime-num-errors conn) (ensime-num-warnings))) "]")) (ensime-mode " [ENSIME: Dead Connection]")))
ensime-modeline-string()
eval((ensime-modeline-string) nil)
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
recursive-edit()
debug(error (void-function ensime-modeline-string))
(ensime-modeline-string)
eval((ensime-modeline-string) nil)
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
recursive-edit()
debug(error (void-variable conn))
(ensime-config conn)
eval((ensime-config conn) nil)
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
recursive-edit()
debug(error (void-function t))
(t " [ENSIME: No Connection]")
eval((t " [ENSIME: No Connection]") nil)
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)

Expected behavior would probably be for ensime to report that it has no connection under these circumstances.