feat: add command to copy project-relative filename
This commit is contained in:
@@ -102,6 +102,20 @@ If PROJECT is not specified, assume current project root."
|
|||||||
(message "Copied '%s'" filename))
|
(message "Copied '%s'" filename))
|
||||||
(warn "Current buffer is not attached to a file!"))))
|
(warn "Current buffer is not attached to a file!"))))
|
||||||
|
|
||||||
|
;; Copia el nombre del archivo actual pero usando como raiz la raiz del proyecto
|
||||||
|
(defun copy-project-filename ()
|
||||||
|
"Copy the current buffer file name relative to project root to the clipboard."
|
||||||
|
(interactive)
|
||||||
|
(let ((filename (if (equal major-mode 'dired-mode)
|
||||||
|
default-directory
|
||||||
|
(buffer-file-name))))
|
||||||
|
(if-let* ((root (kj/project-root))
|
||||||
|
(rel-name (file-relative-name filename root)))
|
||||||
|
(progn
|
||||||
|
(kill-new rel-name)
|
||||||
|
(message "Copied '%s'" rel-name))
|
||||||
|
(warn "Couldn't determine project-relative filename!"))))
|
||||||
|
|
||||||
(defun copy-basename ()
|
(defun copy-basename ()
|
||||||
"Copy the current buffer basename to the clipboard."
|
"Copy the current buffer basename to the clipboard."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
(global-set-key (kbd "C-c ff") 'insert-filename)
|
(global-set-key (kbd "C-c ff") 'insert-filename)
|
||||||
(global-set-key (kbd "C-c fb") 'insert-basename)
|
(global-set-key (kbd "C-c fb") 'insert-basename)
|
||||||
(global-set-key (kbd "C-c fcf") 'copy-filename)
|
(global-set-key (kbd "C-c fcf") 'copy-filename)
|
||||||
|
(global-set-key (kbd "C-c fcp") 'copy-project-filename)
|
||||||
(global-set-key (kbd "C-c fcb") 'copy-basename)
|
(global-set-key (kbd "C-c fcb") 'copy-basename)
|
||||||
|
|
||||||
;; Deactivar el abrir *messages* al cliquear en el minibuffer
|
;; Deactivar el abrir *messages* al cliquear en el minibuffer
|
||||||
|
|||||||
Reference in New Issue
Block a user