0

Is there any function that can print a symlink's full path in dired mode? Alternatively is there any function that can print an arbitrary buffers' full path?

2

Yes. this is lifted from emacs-prelude

    (defun prelude-copy-file-name-to-clipboard ()
      "Copy the current buffer file name to the clipboard."
      (interactive)
  (let ((filename (if (equal major-mode 'dired-mode)
                      default-directory
                    (buffer-file-name))))
    (when filename
      (kill-new filename)
      (message "Copied buffer file name '%s' to the clipboard." filename))))

Plus, in the most recent version, neotree has a function for revealing the full path of the node point is at: neotree-copy-filepath-to-yank-ring. I even have this on my configuration:

    (defun ninrod/neotree-copy-path ()
  (interactive)
  (message (concat "copied path: \"" (neotree-copy-filepath-to-yank-ring) "\" to the clipboard.")))
2

file-truename returns the real path of a file and follows symlinks. You can combine it into something like (file-truename (buffer-file-name)) to get the path of the file stored in a buffer.

https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Name-Expansion.html#File-Name-Expansion

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.