想复制的时候打印出kill-ring中的内容

(message (current-kill 0))

但是结果是

#("(message (current-kill 0))" 0 1 (ws-butler-chg chg fontified t face (rainbow-delimiters-depth-1-face)) 1 8 (ws-butler-chg chg fontified t composition (7 7 [167]) prettify-symbols-start 603 prettify-symbols-end 610) 8 9 (ws-butler-chg chg fontified t face whitespace-space) 9 10 (ws-butler-chg chg fontified t face (rainbow-delimiters-depth-2-face)) 10 22 (ws-butler-chg chg fontified t) 22 23 (ws-butler-chg chg fontified t face whitespace-space) 23 24 (ws-butler-chg chg fontified t face highlight-numbers-number) 24 25 (ws-butler-chg chg fontified t face (rainbow-delimiters-depth-2-face)) 25 26 (ws-butler-chg chg rear-nonsticky t fontified t face (rainbow-delimiters-depth-1-face)))

如何把格式显示出来呢

试试看 helm-show-kill-ring

试过了,读过源码,没用到 current-kill 呢

得到的结果就是一个字符串了,只是这个字符串身上还附着了属性(Text Properties),所以你所见到的已经是你想要的了。

;; 给一个字符串加上 Text Props
(propertize "hello" 'face 'underline)
    ⇒ #("hello" 0 5 (face underline))

;; 还是字符串
(stringp #("hello" 0 5 (face underline)))
    ⇒ t

;; 去掉 Text Props
(substring-no-properties #("hello" 0 5 (face underline)))
    ⇒ "hello"
2 个赞