File path to clipboard in Emacs

前端 未结 7 940
闹比i
闹比i 2021-01-31 02:40

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

7条回答
  •  再見小時候
    2021-01-31 03:09

    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))))
    

提交回复
热议问题