I am setting up a few hydras, one of which should open a frequently accessed file. The following command works, if I bind a keyboard sequence to it:

(lambda () (interactive) (find-file "~/capture.org"))

How would I rewrite it if I want to get the file (capture.org here) from a variable?

(setq my-file-variable "~/capture.org")
(lambda () (interactive) (find-file my-file-variable))

This returns an error: "Wrong type argument: stringp, ("~/capture.org")"

It seems that the variable contains a list with one element (the string I want), and not just the string.

1 Answer 1


I would guess that you may have accidentally set my-file-variable to the list (such as with (add-to-list 'my-file-variable "~/capture.org") ?). There's no stack trace, so I can't be absolutely certain, but something inside find-file is probably complaining that it has received a list argument rather than a string.

Just re-run your code exactly as you have it and it should work!

If it doesn't, try looking at the stack trace (and maybe update your question). Use M-x toggle-debug-on-error to cause the function to break on the error in that case.

  • 1
    Of course. My bad. I c&p'ed code from org-ref that looked like this: ;; see org-ref for use of these variables (setq org-ref-bibliography-notes "~/Dropbox/bibliography/notes.org" org-ref-default-bibliography '("~/Dropbox/bibliography/references.bib") org-ref-pdf-directory "~/Dropbox/bibliography/bibtex-pdfs/"). And org-ref-default-bibliography was a list that I overlooked. Thanks! Commented Nov 13, 2018 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.