Hot answers tagged

62

From the documentation: dired-dwim-target is a variable defined in `dired.el'. Its value is nil Documentation: If non-nil, Dired tries to guess a default target directory. This means: if there is a Dired buffer displayed in the next window, use its current directory, instead of this Dired buffer's current directory. The target is used in ...


31

You could do the following: M-x ibuffer * / to mark buffers in dired mode. D to delete them.


28

@Malabarba mentioned the use of wgrep package for editing grep/ack/ag results. I would like to write a detailed walk-through of how I use the ag package and wgrep-ag packages to achieve editing of 'ag'ged results using multiple-cursors package. These packages are available through Melpa. You also need to have ag aka the_silver_searcher installed on your ...


24

Move the cursor to the directory header line (where the directory is shown - e.g., use M-<), then hit w. That copies the directory name to the kill ring. (w copies any file name from Dired, and it works for the directory header too.) And if you haven't already done so, customize x-select-enable-clipboard to non-nil, so selection is copied to the ...


23

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: :


22

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


20

C-h f dired tells you the answer. Just pass to dired, as the DIRNAME argument, a list that has as its car the Dired buffer name you want (any string) and as cdr the list of file names you want listed in the buffer. Generally, you want to use absolute file names. For example: (dired (list "My Dired Buffer Name*" ; The Dired buffer name "/...


17

Dependent on your desktop environment the method to set a default application may differ. That said, many desktop environments respect the associations in ~/.local/share/applications/mimeapps.list, where you can set up an association for the application/x-directory and/or inode/directory types. My mimeapps.list looks like this now: [Default Applications] ...


16

Write a custom function for dired-initial-position-hook. In this function you can use various dired functions to search for files, and eventually call dired-goto-file to move point to the “best” file: (defun my-dired-goto-important-file () "Go to an important file in the current dired buffer." (unless (bound-and-true-p save-place) (let ((candidates ...


15

When you are saying "I am using tramp via ssh" I suppose you open a file like /ssh:host:/path/to/file. This is supposed to use always the ssh method. If you want to use the scp method, you shall use /scp:host:/path/to/file. This uses automatically ssh for short files, and scp for large files. If you trust the default method set in tramp-default-method, you ...


14

Try this: C-u C-x d This let's you enter arguments for how Dired should list files. By default it says -al at the prompt. Add R to that, ending up with -alR. Type RET. Select/type a directory and then press RET. This will recursively open all directories from the one you select, and below. From here, type % m to mark all files matching a certain file ...


13

What I would like to do is to either quickly build a dired buffer from existing grep output [...], or transform grep output into a list of buffers for multi-occur [...]. You don't need to convert the grep results buffer into anything, there's already a mode specifically for editing grep output (and reflecting the changes on the files, of course). Install ...


13

Customize option auto-revert-verbose to nil. C-h v tells you this: auto-revert-verbose is a variable defined in autorevert.el. Its value is t Documentation: When nil, Auto-Revert Mode does not generate any messages. When non-nil, a message is generated whenever a file is reverted. You can customize this variable. It's kind of a ...


12

Yes, you can do that. You don't need to (explicitly) use FTP. Just use C in Dired to copy from one directory to the other. You can copy in either direction: from local to remote or remote to local. For example: Dired buffer #1 is for local directory ~jpepin/mydir/. Dired buffer #1 is for remote directory /foo.bar.toto.com:/home/jpepin/mydir/. (Tip: ...


12

The dired command accepts a list of file-names as argument. Just create one and pass to it: (dired (cons "Open Files" (sort (remove nil (mapcar #'buffer-file-name (buffer-list))) #'string<)))


12

emacs 25.x The emacs 25.1 release will have in-built support for handling different kinds of archives from within dired. Below is the relevant excerpt from the NEWS file (C-h C-n). +++ *** The command `dired-do-compress' bound to `Z' now can compress directories and decompress zip files. +++ *** New command `dired-do-compress-to' bound to `c' can be used ...


12

U (if necessary) followed by t dired-unmark-all-marks dired-toggle-marks


11

Just use function dired-get-marked-files. It gives you a list of the marked file and directory names. And then just use funcall or apply to pass them to a function. (You can also use w in Dired to copy the marked names, separated by spaces, to a (single) string on the kill-ring, which you can then yank to insert them as a group wherever you want.)


11

Here's my config: (setq dired-listing-switches "-laGh1v --group-directories-first") The relevant part is -1v.


11

With your keyboard setup, the key ^ is most probably a "dead key". It is a key meant to be used in conjunction with another one, in order to produce another character. In this case, it is meant to produce accented characters : ^e will produce ê, ^a will produce â and so on. It should not be specific to emacs though : I guess all your applications require ...


10

Do you have many Dired buffers because you wanted them all at one point? IOW, did you want to create each of them as separate buffers? If not, the solution is simple: tell Dired to reuse an existing Dired buffer when you hit RET a directory name to open it in Dired. Here is how to do that: Load library Dired+ (dired+.el): (require 'dired+) Tell Dired to ...


10

Instead of add another function to kill all dired buffers, I suggest you take advantage of filter groups in ibuffer, it allow you to group buffer by many condition. Here is a example to set filter groups: (setq-default ibuffer-saved-filter-groups `(("Default" ;; I create a group call Dired, which contains all buffer in dired-...


10

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

External ls GNU's ls has an option --group-directories-first, and you can control the list of options passed to ls by dired with the variable dired-listing-switches (assuming that you haven't already customized this, you'd set it to -al --group-directories-first). Unfortunately, on Windows, emacs usually uses lisp emulation of ls and as you can see from ...


9

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


9

Here is my super hacky way to simulate key down/up event binding by taking advantage of timers. Overall I would suggest going by Sigma's answer, but you asked for a way to close the preview by letting go so I'm obliged to try. Basically what you can do is bind some function that will be your "keydown" function to a keybinding and inside that action, start ...


9

Firstly, take note of JeanPierre's comment -- you're not renaming files by using convert like that. You're creating new and different files (lower quality ones, although the difference may or may not matter in practice, depending on your use-cases). Here are a few different options for renaming files in dired using a number sequence. The first two are ...


9

It is true that MELPA no longer pulls libraries from EmacsWiki. Please obtain Dired+ and other libraries by me from EmacsWiki: dired+.el. All of my pages on EmacsWiki are locked (they require a site administrator to unlock them). There has never been an actual security problem reported, AFAIK. Yes, it is true that a locked web page does not present the ...


8

Something like this (scroll a bit)? (defun kill-dired-buffers () (interactive) (mapc (lambda (buffer) (when (eq 'dired-mode (buffer-local-value 'major-mode buffer)) (kill-buffer buffer))) (buffer-list)))


8

As pointed in comments, functions are bound to keys, not events. But to take a step back, I'm not sure I understand why it's important for you to keep the key down while you're (presumably) reading the content of the file. It would also be incompatible with basic (and reasonable) actions like scrolling to get more of it. Not to mention the fact that if it ...


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