diff options
author | Kyle Meyer <kyle@kyleam.com> | 2014-08-30 01:31:45 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2014-08-30 01:31:45 -0400 |
commit | 11426aa864861d013c5abe454872a7fd65ac89ca (patch) | |
tree | b5f85797b9f2cb22206a79cf06f1797456dd54c8 /lisp | |
parent | 0a118f184e4e84f603c293e7f637369ccfe4a827 (diff) | |
download | emacs.d-11426aa864861d013c5abe454872a7fd65ac89ca.tar.gz |
Break up km/dired-copy-project-filename-as-kill
Plan to use `km/dired-copy-filename-relative-to-directory' elsewhere.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/init-dired.el | 17 |
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))) |