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 (#16766)

* * layers/+spacemacs/spacemacs-defaults/funcs.el: Enhance copying file path for dired-mode

* [defaults] Avoid unnecessary exception raising, also ensure truename

---------

Co-authored-by: Aaron L. Zeng <[email protected]>
  • Loading branch information
sunlin7 and bcc32 authored Jan 1, 2025
1 parent a2a4737 commit 0d176e2
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.
In Dired, the result will be the file path under cursor if any,
otherwise the listed directory's path."
(interactive)
(if-let* ((file-path (spacemacs--file-path)))
(if-let* ((file-path (or (spacemacs--file-path)
(and (derived-mode-p 'dired-mode)
(dired-get-filename nil t))
(spacemacs--directory-path))))
(progn
(kill-new file-path)
(message "%s" file-path))
Expand Down

0 comments on commit 0d176e2

Please sign in to comment.