Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrong type argument: stringp, nil

Tags:

emacs

elisp

Before now I've just been cutting and pasting code into my .emacs file, but then I decided to add some maven functionality to emacs. Now, I don't see how I was able to mess this up, but last night I kept getting the error I put in the title when I run M-x jarl-mvn-exec. I slept on it, and came back the next day but I'm still not getting anywhere.

(defun jarl-get-pom ()
  (concat (locate-dominating-file 
       (buffer-file-name 
        (current-buffer))
       "pom.xml")
      "pom.xml"))

(defun jarl-visit-pom ()
  (interactive)
  (find-file (jarl-get-pom)))

(defun jarl-mvn-exec ()
  (interactive)
  (switch-to-buffer (get-buffer-create "maven"))
  (start-process-shell-command "mvn-exec" "maven" "mvn" "-f" (jarl-get-pom) "compile")
  (start-process-shell-command "mvn-exec" "maven" "mvn" "-f" (jarl-get-pom) "exec:exec"))
like image 482
HahaHortness Avatar asked Mar 24 '11 02:03

HahaHortness


2 Answers

You'll need to provide more information to be sure. Try setting

(setq debug-on-error t)

which will give you a stack trace showing what function is complaining about the string being nil.

My guess is that buffer-file-name is returning nil, and that's where the problem lies (not all buffers have file names). Check out the debugging section of An Introduction To Programming in Emacs Lisp, or the debugging section of the Emacs Lisp manual.

like image 138
Trey Jackson Avatar answered Nov 19 '22 05:11

Trey Jackson


The secret to finding a problem in your init file is not a secret: binary search.

Use comment-region to comment out half your init file, then 3/4, 7/8,... It is very quick to identify the problem. comment-region also uncomments: C-h f comment-region RET.

like image 15
Drew Avatar answered Nov 19 '22 05:11

Drew