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?
The command + ( dired-create-directory ) reads a directory's name, and creates that directory. It signals an error if the directory already exists.
To enter into a directory, move to its listing in the Dired buffer, and simply hit the return key. To view a file, you can place the cursor on its entry and use the f or v key, or simply hit the return key.
Refresh the Dired buffer using switches as dired-listing-switches . Type g ( revert-buffer ) to update the contents of the Dired buffer, based on changes in the files and directories listed. This preserves all marks except for those on files that have vanished. Hidden subdirectories are updated but remain hidden.
There's dired-directory
, however this Q&A indicates that it is unreliable in certain circumstances, and that default-directory
is a better choice.
default-directory
RET
dired-directory
RET
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