2009-07-19

[Small Pieces In Emacs] Copy the name or path of the current buffer's file, if any.



(defun zs-copy-current-file-name-to-system-clipboard (&optional full-path-p)
"copy, if the current buffer accesses a file, the name or file path(given a
prefix argument) to the system clipboard(if under X) and append to the killing
ring."
(interactive "P")
(if (buffer-file-name)
(if full-path-p
;; (x-select-text (buffer-file-name))
(kill-new (buffer-file-name))
;; (x-select-text (file-name-nondirectory (buffer-file-name)))
(kill-new (file-name-nondirectory (buffer-file-name)))
)))

1 条评论:

Yu Zhao 说...

这个ms还挺有用的,俺以前都是C-x C-f C-a C-k 搞定的,,,