开发者

How to copy some content in a system clipboard not a kill ring with elisp/emacs?

开发者 https://www.devze.com 2023-01-15 09:36 出处:网络
I learned that copy something to kill buffer, I can use the kill-new buffer (kill-new (file-truename buffer-file-name))

I learned that copy something to kill buffer, I can use the kill-new buffer

(kill-new (file-truename buffer-file-name))

How about copying the content to clipboard? Does emacs/elisp prov开发者_运维问答ide the function?

ADDED

I got 2 answers, but the answer seems to apply X windows system. As I use Aquamacs, it may not be a universal solution that can be applied to my problem.


(x-set-selection nil (file-truename buffer-file-name))

Documentation for x-set-selection says:

This function sets a “selection” in the X server. It takes two arguments: a selection type type, and the value to assign to it, data. If data is nil, it means to clear out the selection. Otherwise, data may be a string, a symbol, an integer (or a cons of two integers or list of two integers), an overlay, or a cons of two markers pointing to the same buffer. An overlay or a pair of markers stands for text in the overlay or between the markers.

The argument data may also be a vector of valid non-vector selection values.

Each possible type has its own selection value, which changes independently. The usual values of type are PRIMARY, SECONDARY and CLIPBOARD; these are symbols with upper-case names, in accord with X Window System conventions. If type is nil, that stands for PRIMARY.


You can configure Emacs to automatically copy to the system clipboard as well as to the kill ring. The function kill-new calls interprogram-cut-function, which typically copies to a system clipboard if there is one. Under X Window, the variable x-select-enable-clipboard controls whether the primary selection or the clipboard is used.

0

精彩评论

暂无评论...
验证码 换一张
取 消