summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-07-25 23:01:41 -0400
committerKyle Meyer <kyle@kyleam.com>2014-07-25 23:01:41 -0400
commit0eb7a64d85c01678f55433db63e1fad56eb46f7b (patch)
treee33513ef399f2c287e82a07bb8c9bb47e43b42d6 /lisp
parentd75ec995395baad15edd799a5d42d0dbc42cc698 (diff)
downloademacs.d-0eb7a64d85c01678f55433db63e1fad56eb46f7b.tar.gz
Add dired-copy-project-filename-as-kill
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-projectile.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/init-projectile.el b/lisp/init-projectile.el
index 4b2cfc0..ec311e6 100644
--- a/lisp/init-projectile.el
+++ b/lisp/init-projectile.el
@@ -50,6 +50,25 @@ I have set `projectile-switch-project-action' to
(define-key projectile-mode-map (kbd "C-c p j")
'km/projectile-switch-project-to-file)
+(defun km/dired-copy-project-filename-as-kill ()
+ "Copy names of marked project files into kill ring.
+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
+ (mapconcat 'identity
+ (--map (file-relative-name it project-dir)
+ (dired-get-marked-files t))
+ " ")))
+ (if (eq last-command 'kill-region)
+ (kill-append string nil)
+ (kill-new string))
+ (message "%s" string)))
+
+(after 'dired
+ (define-key dired-mode-map "W" 'km/dired-copy-project-filename-as-kill))
+
(key-chord-define-global ";s" 'projectile-switch-project)
(key-chord-define-global ";f" 'projectile-find-file)
(key-chord-define-global ";d" 'projectile-find-dir)