How to check if a variable is set to what in elisp/emacs?

Viewed 14396

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.

5 Answers

If you just want to see the variable value in the echo area (less of a mess), try:

(defun describe-variable-short (var)
  (interactive "vVariable: ")
  (message (format "%s: %s" (symbol-name var) (symbol-value var))) )
(global-set-key "\C-hV" 'describe-variable-short)
Related