aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my/my-editing.el
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-06-24 17:30:01 +1000
committerYuchen Pei <id@ypei.org>2023-06-24 17:30:01 +1000
commit2f1d2fb9b87fb9ee334b646ac84468c5245eecf9 (patch)
treecd839c828ee15faec2b61d6839318637184ed373 /emacs/.emacs.d/lisp/my/my-editing.el
parentba77033a0c81952f5b9b8e140a17c4d12f4e9d05 (diff)
copy buffer file name
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-editing.el')
-rw-r--r--emacs/.emacs.d/lisp/my/my-editing.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-editing.el b/emacs/.emacs.d/lisp/my/my-editing.el
index a8fe822..47e33a3 100644
--- a/emacs/.emacs.d/lisp/my/my-editing.el
+++ b/emacs/.emacs.d/lisp/my/my-editing.el
@@ -372,5 +372,18 @@ Basically move the line up
(setq beg (point)))
(kill-region beg (point)))))
+(defun my-copy-buffer-file-name (&optional relative)
+ "Copy the file name of the current buffer.
+
+With an prefix-arg, copy the file name relative to project root."
+ (interactive "P")
+ (let ((to-kill
+ (if (and relative (project-current))
+ (file-relative-name (buffer-file-name)
+ (project-root (project-current)))
+ (buffer-file-name))))
+ (kill-new to-kill)
+ (message "Copied %s" to-kill)))
+
(provide 'my-editing)
;;; my-editing.el ends here