mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
Bind SPC f Y
to yank path relative to project
Also, both commands now announce "Copied path to clipboard: ..." to make it clear it worked (and what is being copied).
This commit is contained in:
@ -32,13 +32,24 @@
|
||||
((error "No kill-ring search backend available. Enable ivy or helm!")))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +default/yank-buffer-filename ()
|
||||
(defun +default/yank-buffer-path (&optional root)
|
||||
"Copy the current buffer's path to the kill ring."
|
||||
(interactive)
|
||||
(if-let (filename (or buffer-file-name (bound-and-true-p list-buffers-directory)))
|
||||
(message (kill-new (abbreviate-file-name filename)))
|
||||
(if-let (filename (or (buffer-file-name (buffer-base-buffer))
|
||||
(bound-and-true-p list-buffers-directory)))
|
||||
(message "Copied path to clipboard: %s"
|
||||
(kill-new (abbreviate-file-name
|
||||
(if root
|
||||
(file-relative-name filename root)
|
||||
filename))))
|
||||
(error "Couldn't find filename in current buffer")))
|
||||
|
||||
;;;###autoload
|
||||
(defun +default/yank-buffer-path-relative-to-project ()
|
||||
"Copy the current buffer's path to the kill ring."
|
||||
(interactive)
|
||||
(+default/yank-buffer-path (doom-project-root)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +default/insert-file-path (arg)
|
||||
"Insert the file name (absolute path if prefix ARG).
|
||||
|
Reference in New Issue
Block a user