summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-08-30 01:31:54 -0400
committerKyle Meyer <kyle@kyleam.com>2014-08-30 01:31:54 -0400
commita81a5b01a23728806655c9802d0e07c342f40abb (patch)
tree88a57c0a70e90732a8c181a9307c4a8d045da18c
parent11426aa864861d013c5abe454872a7fd65ac89ca (diff)
downloademacs.d-a81a5b01a23728806655c9802d0e07c342f40abb.tar.gz
Add km/dired-copy-relative-filename-as-kill
-rw-r--r--lisp/init-dired.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/init-dired.el b/lisp/init-dired.el
index 0b64258..b92af65 100644
--- a/lisp/init-dired.el
+++ b/lisp/init-dired.el
@@ -52,6 +52,21 @@ relative to DIRECTORY."
(kill-new string))
(message "%s" string)))
+(defun km/dired-copy-relative-filename-as-kill ()
+ "Copy names of marked files into kill ring.
+This is similar to `dired-copy-filename-as-kill', but the leading
+path is always relative to the `default-directory' of the other
+window."
+ (interactive)
+ (let ((other-dir (km/other-default-directory)))
+ (km/dired-copy-filename-relative-to-directory other-dir)))
+
+(defun km/other-default-directory ()
+ "Get `default-directory' for result of `(other-window 1)'."
+ (save-window-excursion
+ (other-window 1)
+ default-directory))
+
(defun km/dired-switch-to-buffer ()
(interactive)
(let ((buffer-name (km/dired-completing-buffer)))