From 11426aa864861d013c5abe454872a7fd65ac89ca Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 30 Aug 2014 01:31:45 -0400 Subject: Break up km/dired-copy-project-filename-as-kill Plan to use `km/dired-copy-filename-relative-to-directory' elsewhere. --- lisp/init-dired.el | 17 +++++++++++------ 1 file 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))) -- cgit v1.2.3