mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -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:
@ -403,7 +403,8 @@
|
||||
:desc "Save file as..." "S" #'write-file
|
||||
:desc "Sudo find file" "u" #'doom/sudo-find-file
|
||||
:desc "Sudo this file" "U" #'doom/sudo-this-file
|
||||
:desc "Yank filename" "y" #'+default/yank-buffer-filename)
|
||||
:desc "Yank file path" "y" #'+default/yank-buffer-path
|
||||
:desc "Yank file path from project" "Y" #'+default/yank-buffer-path-relative-to-project)
|
||||
|
||||
;;; <leader> g --- git/version control
|
||||
(:prefix-map ("g" . "git")
|
||||
|
@ -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