29

From elisp manual: -- Function: file-directory-p filename This function returns ‘t’ if FILENAME is the name of an existing directory, ‘nil’ otherwise. See also its docstring, with a note concerning symlinks: (file-directory-p FILENAME) Return t if FILENAME names an existing directory. Symbolic links to directories count as directories. See ‘...


24

There are (at least) two ways. First, typing C-u C-c C-o on a link should force it to be opened in emacs, rather than in an external app. Second, you can permanently override the default behavior by adding an entry to the variable org-file-apps: (add-to-list 'org-file-apps '(directory . emacs)) which tells org-mode to use dired for all directory links. ...


24

Additionally you can use dired-subtree from dired-hacks repo. Here you have short demo and screenshot from my setup where I press i to drill down folder and ; to go back.: (define-key dired-mode-map "i" 'dired-subtree-insert) (define-key dired-mode-map ";" 'dired-subtree-remove) PS I'm also aware of direx which looks like that: :


23

There are a couple of options for this. You can check out dirtree, which is based on dired. There is also an emacs port of vim's NERDTree called neotree. Both are excellent packages, though I tend to favor neotree as it has convenient bindings to let me create and delete files and directories. I do not believe dirtree has this support, though I could be ...


23

You can modify the link description as follows : [[file+emacs:~/projects][Projects]] It will open the link in Emacs with typing C-c C-o.


17

file-name-directory does what you request. However, (file-name-directory "/home/sk/parent/") (with a trailing slash) returns that same directory, not its parent. This does what I'm guessing you really want: (file-name-directory (directory-file-name "/home/sk/parent/ab.el")) ; => "/home/sk/parent/" (file-name-directory (directory-file-name "/home/sk/...


16

You don't need to do that, if that's your question. C-x C-f /some/new/directory/newfile.txt Emacs prints a message to let you know that the directory /some/new/directory/ does not yet exist: Use M-x make-directory RET RET to create the directory and its parents. Insert text into the new buffer for new file newfile.txt. C-x C-s to save the file. Emacs ...


15

You are looking for the function locate-dominating-file. Here is the emacs documentation for this function: (locate-dominating-file FILE NAME) Look up the directory hierarchy from FILE for a directory containing NAME. Stop at the first parent directory containing a file NAME, and return the directory. Return nil if not found. Instead of a string,...


15

Using browse-url-of-file should work when given a directory. You could implement a command that opens the directory of the current file like this: (defun browse-file-directory () "Open the current file's directory however the OS would." (interactive) (if default-directory (browse-url-of-file (expand-file-name default-directory)) (error "No `...


15

file-directory-p is your friend. Found using C-u C-h a directory RET and browsing the result.


13

Have you ever tried Emacs' M-x speedbar? :-) before installing some new package I'd try an inbuilt solution... Update 2020-01-10 Actually I'm using now dired-sidebar which is available via Melpa.


13

You can configure the mode line format as you wish. If you want to show the parent directory together with the buffer name (which is usually the file name, for a buffer that's visiting a file), modify mode-line-buffer-identification; otherwise, add an entry to mode-line-format. There isn't a built-in construct for “parent directory of the current file”, so ...


11

In Dired you can include a subdirectory using i, with the cursor on the subdir line. You can do likewise on a subdir line within a subdir listing, so you can list any number of levels of any number of subdirs in the same Dired buffer. $ on a subdir-listing header line hides/shows that subdir listing. So it corresponds more or less with the expand/contract ...


10

You can invoke dired with an argument, ie. C-u C-x d and after prompting for the directory it will also let you modify the switches passed to ls. Add R and dired will recursively list all sub-directories, each in it's own section. If you only want to see the contents of some sub-directories, press i when the point is on a directory name. You can also use ...


10

I assume you mean that you want to see the directory instead of the buffer name. (setq-default mode-line-buffer-identification '(:eval default-directory)) Or if you want your home directory abbreviated to ~/ (instead of an absolute file name, from the root), then: (setq-default mode-line-buffer-identification '(:eval (...


8

You could use M-x make-directory DIRNAME RET. The default path is the path to the current buffer folder. You could bind it to key (like C-x C-f) with (global-set-key (kbd "C-c d") 'make-directory). You could create buffer in nonexist path with C-x C-f non/exist/path/file.name RET and then create nececcary folders with M-x make-directory RET RET.


7

You install use smart-mode-line. It's configured to display the file path in the mode-line, whenever that's relevant. Just install it, and then turn it on with (sml/setup). It also has a lot of features to make that display more concise. For instance, “~/.emacs.d/” gets replaced with “:ED:” (and you can configure further replacements).


7

For ido users Do C-x C-f (which should call ido-find-file) and enter a non-existent path. Press M-m (mnemonic for make new dir?). Hit RET. Continue with typing the new file name that you want to create in that new dir. Hit RET.


7

This seems to work: (defadvice hack-dir-local-variables (around second-dir-locals-file activate) ad-do-it (let ((dir-locals-file ".alt-dir-locals.el")) ad-do-it))


7

According to the documentation: default-directory is a variable defined in ‘C source code’. Its value is "~/" Local in buffer *scratch*; global value is nil Automatically becomes permanently buffer-local when set. This variable is safe as a file local variable if its value satisfies the predicate 'stringp'. Documentation: Name of ...


7

(length (directory-files "~/Pictures" nil "\\.png\\'")) See C-hf directory-files


6

For MS Windows: Load library w32-browser.el and use command w32explore. It does exactly what you are requesting. See MS Shell Execute. If you also use Dired+ then M-RET on a file or dir name in Dired opens Windows Explorer for it.


6

Recursive compile, no dependencies attached: (defun desperately-compile () "Traveling up the path, find a Makefile and `compile'." (interactive) (with-temp-buffer (while (and (not (file-exists-p "Makefile")) (not (equal "/" default-directory))) (cd "..")) (when (file-exists-p "Makefile") (compile "make -k"))))


6

It's unclear to me why you want/need to add such symlinks. Why not just use Emacs bookmarks? If you use Bookmark+ then you can have: Bookmarks to Dired buffers (which record lots of stuff, including markings, subdir insertions, omit settings, etc.). Bookmarks to bookmark files (to load different sets of bookmarks). Bookmarks to bookmark-list displays (...


5

default-directory is a buffer local variable which can be set by all sorts of things although it is always set on loading a file. The simplest dumb solution is to use the find-file-hook and set it back to what you want: (add-hook 'find-file-hook #'(lambda () (setq default-directory (expand-file-name "~/")))) However this does have the disadvantage of ...


5

For simplicity, here is another take on a function that opens the next or previous file (by name) in the current directory. (defun find-next-file (&optional backward) "Find the next file (by name) in the current directory. With prefix arg, find the previous file." (interactive "P") (when buffer-file-name (let* ((file (expand-file-name buffer-...


5

make-temp-file can be used to make a directory instead of a file, this example simply calls make-temp-file, then removes the directory afterwards. (let ((temp-dir (make-temp-file "foo" t))) (unwind-protect (progn ;; do stuff ) (delete-directory temp-dir t))) This same functionality as a macro: (defmacro with-temp-dir (temp-dir &...


4

There is also ztree. I use it when I need to take a look at directory structure, although usually I use vanilla Dired for all other things.


4

I just added this feature to helm-make. Give it a go and let me know if it works as you wanted, you just need to set the custom: (setq helm-make-do-save t) Here's the code that does it: (when helm-make-do-save (let* ((regex (format "^%s" (regexp-quote default-directory))) (buffers (cl-remove-if-not (lambda (b) (...


4

As of I think version 26.1, Emacs does support a second additional .dir-locals.el file (aptly named .dir-locals-2.el). From the Emacs Manual: "Per-Directory Local Variables": You can also use .dir-locals-2.el; if found, Emacs loads it in addition to .dir-locals.el. This is useful when .dir-locals.el is under version control in a shared repository and ...


Only top voted, non community-wiki answers of a minimum length are eligible