Direct implementation of what you want:
(defun copy-full-path-to-kill-ring () "copy buffer full path to kill ring" (interactive) (when buffer-file-name (kill-new (file-truename buffer-file-name))))
However, I find it incredibly useful to be able to get the full path to what is in the minibuffer, and this is what I use:
(define-key minibuffer-local-completion-map "\Cr" 'resolve-sym-link) (defun resolve-sym-link () "Try to resolve symbolic links into true paths." (interactive) (beginning-of-line) (let* ((file (buffer-substring (point) (save-excursion (end-of-line) (point)))) (file-dir (file-name-directory file)) (file-true-dir (file-truename file-dir)) (file-name (file-name-nondirectory file))) (delete-region (point) (save-excursion (end-of-line) (point))) (insert (concat file-true-dir file-name))))
And if I want it on the clipboard, I just kill the string ( Ca Ck ). But we could easily copy the name truename to the clipboard in the above command, just change the last line:
(insert (kill-new (concat file-true-dir file-name)))))
The new part is a call to 'kill-new , which places the string in the kill ring.
Trey Jackson Sep 08 '10 at 15:59 2010-09-08 15:59
source share