Let's say I have the following line in .emacs file.
(setq-default default-directory "~/Desktop/mag")
How can I check the value for `default-directory' in elisp?
I asked this question as I need to check the value of default-directory based on this question.
The elisp code should change the default directory when I click C-x C-f, but I still get ~/, not ~/Desktop/mag. So, I need to check what value the default-directory has.
Special Form: (setq [symbol form]...) This special form is the most common method of changing a variable's value. Each SYMBOL is given a new value, which is the result of evaluating the corresponding FORM. The current binding of the symbol is changed. 'setq' does not evaluate SYMBOL; it sets the symbol that you write.
#'... is short-hand for (function ...) which is simply a variant of '... / (quote ...) that also hints to the byte-compiler that it can compile the quoted form as a function.
If you're at the console you can type C-h v, which will prompt you for a variable name. Type in default-directory (or any other name) and you'll get a buffer with some info about that variable, including its value.
The elisp function you're running is describe-variable:
(describe-variable VARIABLE)
I figured this out by C-h k C-h v. C-h k shows you what function the next key or key sequence would call.
If you just want to check the value, you can run the following from the *scratch* buffer:
(print default-directory) <ctrl-j>
The *scratch* buffer allows you to evaluate lisp on the fly. You must hit ctrl-j after to evaluate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With