From 7a171cd57a078ad49dfb8e50ba44eb888ae7c6cb Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 28 Apr 2015 22:02:20 -0400 Subject: Add fallback for copying project name at point This also fixes a bug: fname should not have been passed down when it was nil. --- lisp/init-projectile.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lisp/init-projectile.el') 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)) -- cgit v1.2.3