I want to mark interesting files while I am browsing my folders, when I am done with marking, I want to copy these files to another place (with dired copy or dired-ranger-copy) or send them as attachment. To prevent too many dired buffer I have this setting

 (diredp-toggle-find-file-reuse-dir 1)

the problem is when I go into a subfolder and come back, the marks are gone, currently I have to mark in one folder, copy the files, mark in another folder, copy files, it's too many copying operations. I have tried to set reuse dire to nil, but I can't work on all marked files in different buffer either. Is there any package that can let me do that?

  • I use a tree-view custom file manager for just this very purpose -- dired-mode (in my opinion) is not ideal for this type of copy/attach operation. To use dired-mode, the list would need to be stored in a variable and appended/pushed to, and then emptied at a time determined by the author of that feature (when written, if it doesn't yet exist).
    – lawlist
    Jun 29, 2015 at 20:26
  • An alternative approach is an attachment function that prompts to attach additional files, and then just attach everything desired within a particular directory and then move on to the next directory. That is how I did it for about a year or so until I created my tree-view mode.
    – lawlist
    Jun 29, 2015 at 20:33
  • Can you share your setup? Emacs-neotree seems to be the most popular, but it doesn't have marking abilities.
    – godblessfq
    Jun 30, 2015 at 1:15
  • I took ztree-mode github.com/fourier/ztree and turned it into a file manager with marking capabilities, breaking some of the original functionality and leaving those broken pieces where they lay -- the new monster draws upon various customized functions taken from dired-mode, and a couple of modified core functions from files.el. I'd need to spend considerable time cleaning up the broken/unused pieces, or restore them to their working state. I'll need to put this on my todo-list . . .
    – lawlist
    Jun 30, 2015 at 1:30

1 Answer 1

  1. diredp-toggle-find-file-reuse-dir does not prevent you from opening multiple Dired buffers for different directories (e.g. subdirs). It should be irrelevant here, but you might want to describe just what you are doing, step by step.

  2. With multiple Dired buffers open, you can mark files (and subdirs) in any of them. with Dired+ (which you are apparently using), you can use M-+ C in a parent directory's Dired buffer to copy all of the files that are marked in that buffer and all of the files that are marked in any of its marked subdirs, with this rule applying recursively.

  3. As an alternative to #2, you can of course also include subdirs in the same Dired buffer, using i. Then act on (e.g. C to copy) all files marked in the buffer.

Your problem of losing marks happens because you are using RET or C-x C-f to move to another directory. Use C-x d instead, and you do not lose the previous Dired buffer. Or just use C-M-S-r to toggle diredp-toggle-find-file-reuse-dir and turn off reusing temporarily.

FWIW, I don't tell Dired+ to automatically reuse Dired buffers when I hit RET. Instead, I use C-x C-v whenever I want to change to a different directory and I don't care to save the current Dired buffer. My fingers decide whether to keep or toss the current Dired buffer when I visit another one: RET to keep, C-x C-v to toss. (And I don't worry about having lots of buffers, in general.)

IOW, this comes under the heading of "If it hurts, don't do it." If you purposely kill a Dired buffer, which is what "reusing" means here, then, well, the buffer no longer exists. If it no longer exists then its markings etc. are gone too.

In sum, reuse when you want, and don't reuse when you want. Both behaviors are available at all times. If you start marking things, then think before you use RET to change directories - use C-x d or C-x 4 d instead. It's probably just a question of habit. And don't forget that you have i too.

  • When diredp-toggle-find-file-reuse-dir is t, I hit "e" or return on a subdir, the parent dir is closed, I am using a netbook so I prefer not to open too many buffers. Point 2 and 3 are viable solutions, but it might be more convenient to have a variable that stores marked file path so you don't have to go to the parent folder again or insert the subdir content, and we can always unmark and refresh the variable. I think it might be easy to add the variable, but to make other function that work on marked files aware of that may be difficult.
    – godblessfq
    Jun 30, 2015 at 0:40
  • Dunno what you mean by "marked file path"; sorry.
    – Drew
    Jun 30, 2015 at 2:10
  • I mean a list of paths for marked files, probably not a good idea. I find insert subdir in the parent buffer is good enough.
    – godblessfq
    Jun 30, 2015 at 21:17
  • If you use Bookmark+ then you can bookmark a Dired buffer (or even a set of Dired buffers), and this records its current markings. Then, whenever you jump to that bookmark the Dired buffer is restored, including its saved markings. And you can use C-J in Dired to jump to any of the Dired bookmarks for the same directory, thus switching among different markings by jumping to different bookmarks with C-J.
    – Drew
    Jun 30, 2015 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.