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?


Yes. this is lifted from emacs-prelude

    (defun prelude-copy-file-name-to-clipboard ()
      "Copy the current buffer file name to the clipboard."
  (let ((filename (if (equal major-mode 'dired-mode)
    (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 ()
  (message (concat "copied path: \"" (neotree-copy-filepath-to-yank-ring) "\" to the clipboard.")))

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.


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.