summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-04-28 22:02:20 -0400
committerKyle Meyer <kyle@kyleam.com>2015-04-28 22:02:20 -0400
commit7a171cd57a078ad49dfb8e50ba44eb888ae7c6cb (patch)
tree12a81515fe2bf1694184e35272a49030203d9af3 /lisp
parentf092b2ee5d5c1126f940c34ed29100b9eb5be9ee (diff)
downloademacs.d-7a171cd57a078ad49dfb8e50ba44eb888ae7c6cb.tar.gz
Add fallback for copying project name at point
This also fixes a bug: fname should not have been passed down when it was nil.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-projectile.el8
1 files changed, 7 insertions, 1 deletions
diff --git a/lisp/init-projectile.el b/lisp/init-projectile.el
index f0cfbb8..c11a9e9 100644
--- a/lisp/init-projectile.el
+++ b/lisp/init-projectile.el
@@ -49,8 +49,14 @@ Interactive arguments are processed according to
(file-relative-name it (projectile-project-root))))
(defun km/projectile-copy-project-filename-as-kill ()
+ "Copy name of project file.
+If point is on a file, copy this as the file name. Otherwise,
+use the name of the current file."
(interactive)
- (let ((fname (km/project-filename-at-point)))
+ (-when-let (fname (or (km/project-filename-at-point)
+ (and buffer-file-name
+ (file-relative-name buffer-file-name
+ (projectile-project-root)))))
(if (eq last-command 'kill-region)
(kill-append fname nil)
(kill-new fname))