Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading