Skip to content

Commit

Permalink
* layers/+spacemacs/spacemacs-defaults/funcs.el: Enhance copying file…
Browse files Browse the repository at this point in the history
… path for dired-mode
  • Loading branch information
sunlin7 authored and Lin Sun committed Dec 29, 2024
1 parent c5fc206 commit bba77f4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions layers/+spacemacs/spacemacs-defaults/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,15 @@ ones created by `magit' and `dired'."
(user-error "Current buffer is not visiting a file or directory")))

(defun spacemacs/copy-file-path ()
"Copy and show the file path of the current buffer."
"Copy and show the file path of the current buffer. If the buffer is a
dired buffer, the result will be the file path under cursor, otherwise
the result is directory path."
(interactive)
(if-let* ((file-path (spacemacs--file-path)))
(if-let* ((file-path (or (spacemacs--file-path)
(and (derived-mode-p 'dired-mode)
(condition-case nil
(dired-get-file-for-visit)
(error default-directory))))))
(progn
(kill-new file-path)
(message "%s" file-path))
Expand Down

0 comments on commit bba77f4

Please sign in to comment.