tags:

views:

69

answers:

1

What is the most simple way to send current full file name with file path to clipboard?

What I am using now is messages buffer: I copy file name that appears there after saving a file. But, I suppose, there should be much more simple way.

+1  A: 

I use this:

(defun my-put-file-name-on-clipboard ()
  "Put the current file name on the clipboard"
  (interactive)
  (let ((filename (if (equal major-mode 'dired-mode)
                      default-directory
                    (buffer-file-name))))
    (when filename
      (with-temp-buffer
        (insert filename)
        (clipboard-kill-region (point-min) (point-max)))
      (message filename))))
scottfrazer
You can do that without the temp buffer, using "kill-new":(let ((x-select-enable-clipboard t)) (kill-new filename))
sanityinc