问题
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?
回答1:
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...
来源:https://stackoverflow.com/questions/44042620/how-do-you-define-and-call-a-function-in-spacemacs