tags:

views:

76

answers:

4

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?

Added

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.

+3  A: 

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 funtion 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.

Paul Rubel
A: 

Try:

(print default-directory)

write the above code in one line inside of emacs, got to the end of the line and hit C-x C-e

+4  A: 

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.

Starkey
+1  A: 

As previously stated, C-h v is the easiest way to find out a variables value. To make it even better, place your cursor on the variable you want to know about, and then run C-h v, and it will default to the word under the cursor. Really handy.

monotux