3

Is there a way to use bookmarks or the buffer list of open buffers to efficiently copy/move marked files/directories to another directory?

As an example, imagine I want to copy the files foo.txt and bar.txt from existing location to a bookmarked directory.

emacs copy marked files

The image above shows the result after marking the two files in dired and then hitting C.

At this point, emacs suggests the current directory as the destination for copying.

I would like to be able to quickly choose an alternative destination from within the mini-buffer:

  • a bookmarked directory
  • a directory from the current buffer list

So, once I have marked files, hit C, and am in the mini-buffer, ideally it would be possible to either:

  • invoke bookmark jump to quickly save marked files to a bookmarked directory
  • invoke something (?) to quickly select a directory from the current buffer list and then save marked files to that directory

I know I can impact the default destination directory by splitting the window and having the desired destination directory visible, but that seems like additional steps that shouldn't be necessary.

I currently use ivy/counsel/swiper, and thought that it might be possible with that, but haven't been able to find a solution.

I would prefer a solution based on ivy/counsel/swiper, but am open to other solutions that make use of dired or dired+ (e.g, ido, icicles). I'm not interested in solutions that involve alternatives to dired or dired+ (e.g., dropping to a shell, ranger, midnight commander).

Unfortunately, I don't have the skills to write something like this myself, so I'm hoping there is an existing solution. This seems like the kind of thing that many emacs users would want to be able to do, so I'm surprised my searches didn't turn up anything.

2
  • why not use a shell? Dec 5, 2018 at 6:06
  • Thanks for suggestion, @manandearth, but I would prefer a solution based on dired or dired+. Have updated my question to make this clear.
    – noob
    Dec 7, 2018 at 2:58

1 Answer 1

1

Not sure what you want to do, or why, but it sounds like you might just want to write a command that does it.

Otherwise, at least if you use Bookmark+ and possibily Dired+ (not sure whether either or both are required), you can do this:

  1. Set enable-recursive-minibuffers to t. (Not needed if you use Icicles.

  2. In the Dired source buffer, use R (or C to copy - better for testing).

  3. At the prompt, use C-x 4 j d (bmkp-dired-jump-other-window), and choose the Dired bookmark for the target directory.

  4. w in that target Dired buffer. (Depending on your window manager, you might need to manually switch to that buffer first.)

  5. Use C-a C-y C-k in the minibuffer, to yank the target directory name to the beginning of the minibuffer input and delete the default dir name following it.

  6. RET, to accept that target directory name.

Yes, that's a lot of steps. Not sure it really helps. The point, I guess, is that you can jump to the bookmarked Dired directory (C-x 4 j d) and grab its full directory name (w), then insert that directory in the minibuffer as the target of the move/copy.

1
  • Thanks for your suggestion, @Drew. Since you say you are not sure what I want to do or why, I have revised my question to hopefully make it more clear.
    – noob
    Dec 7, 2018 at 2:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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