summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-dired.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/init-dired.el b/lisp/init-dired.el
index 0e5b2cf..0b64258 100644
--- a/lisp/init-dired.el
+++ b/lisp/init-dired.el
@@ -33,10 +33,18 @@
This is similar to `dired-copy-filename-as-kill', but the leading
path is always relative to `projectile-project-root'."
(interactive)
- (let* ((project-dir (projectile-project-root))
- (string
+ (let ((project-dir (projectile-project-root)))
+ (km/dired-copy-filename-relative-to-directory project-dir)))
+
+(after 'projectile
+ (define-key dired-mode-map "W" 'km/dired-copy-project-filename-as-kill))
+
+(defun km/dired-copy-filename-relative-to-directory (directory)
+ "Like `dired-copy-filename-as-kill', but the filename is always
+relative to DIRECTORY."
+ (let* ((string
(mapconcat 'identity
- (--map (file-relative-name it project-dir)
+ (--map (file-relative-name it directory)
(dired-get-marked-files t))
" ")))
(if (eq last-command 'kill-region)
@@ -44,9 +52,6 @@ path is always relative to `projectile-project-root'."
(kill-new string))
(message "%s" string)))
-(after 'projectile
- (define-key dired-mode-map "W" 'km/dired-copy-project-filename-as-kill))
-
(defun km/dired-switch-to-buffer ()
(interactive)
(let ((buffer-name (km/dired-completing-buffer)))