Windows 10, Emacs 25.1, Dired

If I want to copy to parent's directory name to kill-ring I go to folder name and press w

Here result:

Success copy

OK. It's work.

But I wan't to move cursor and get parent's directory name. I try by command digit-argument w but I get the next result:

Not get name

As you can see Emacs copy to kill-ring files name and dirs names. But it not copy the parent's directory name.

  • I don't quite understand the question. Are you asking for a command that moves the cursor temporarily to the top line (where the current directory name is) and then does what w does? Can you get what you want by defining and using a keyboard macro? If so, then a recipe that details defining the macro you use would make clear just what action you want to perform. To me it's not clear yet.
    – Drew
    Oct 14, 2017 at 16:11
  • I want the next: it does not matter where is cursor is position on the Dired buffer, I want to get parent name by one command. Is it possible?
    – Alex
    Oct 15, 2017 at 7:14

1 Answer 1


It's still not very clear what you're asking, but I'm guessing this is it:

(defun copy-parent-dir-as-kill ()
  (kill-new (expand-file-name default-directory)))

If you don't want to convert ~/ to its expansion, remove the expand-file-name.

(This is unrelated to Dired+ or even to Dired in general, BTW. You can use the same command in any buffer, to copy the current directory to the kill-ring.)


Your Answer

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

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