Search code examples
emacslispelisp

How to get folder path in dired-mode?


I can get the file path with:

(message (file-name-directory (or buffer-file-name load-file-name)))

But if the buffer in dired-mode, the above code evaluates to nil.

How can I get the folder path in dired-mode with elisp?


Solution

  • There's dired-directory, however this Q&A indicates that it is unreliable in certain circumstances, and that default-directory is a better choice.

    • C-hv default-directory RET
    • C-hv dired-directory RET