4

I've defined a emacs / lisp function within defun dotspacemacs/user-config () like so:

(defun clientdir ()
"docstring"
neotree-dir "~/Projects/Clients"
)

How do I execute it?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
  • 1
    You would call it like usually on Emacs :) see [elisp in 15 minutes - interactive functions](http://wikemacs.org/wiki/Emacs_Lisp_in_15_minutes#Interactive_functions) and [other ressources](http://wikemacs.org/wiki/Category:Emacs_Lisp), hope that helps ! – Ehvince May 18 '17 at 20:48

1 Answers1

5

That function will evaluate the neotree-dir variable and discard the result, then evaluate the "~/Projects/Clients" string and return it.

i.e. Your function unconditionally returns the value "~/Projects/Clients" (unless neotree-dir is not bound as a variable, in which case it will trigger an error).

I am guessing that you wanted to call a function called neotree-dir and pass it "~/Projects/Clients" as an argument? That would look like this: (neotree-dir "~/Projects/Clients")

If you want to call the function interactively you must declare it as an interactive function:

(defun clientdir ()
  "Invoke `neotree-dir' on ~/Projects/Clients"
  (interactive)
  (neotree-dir "~/Projects/Clients"))

You can then call it with M-x clientdir RET, or bind it to a key sequence, etc...

phils
  • 71,335
  • 11
  • 153
  • 198