[英]How to copy a string and paste a substring in Emacs?
Found this on the interwebs:在网上找到这个:
(defun clipboard/set (astring)
"Copy a string to clipboard"
(with-temp-buffer
(insert astring)
(clipboard-kill-region (point-min) (point-max))))
I want to make it interactive, run the string through substring, and then copy it to the clipboard我想让它交互,通过 substring 运行字符串,然后将其复制到剪贴板
(defun clipboard/set (astring)
"Copy a string to clipboard"
(interactive)
(let (bstring (substring astring -11)))
(with-temp-buffer
(insert bstring)
(clipboard-kill-region (point-min) (point-max))))
How would one do this?如何做到这一点?
You need to tell interactive
how to populate the arguments:您需要告诉
interactive
如何填充 arguments:
(interactive "sAstring: ")
Also, the syntax of let
is different, it starts with a list of lists of variables and values, ie此外,
let
的语法不同,它以变量和值列表的列表开始,即
(let ((bstring (substring astring -11)))
; ^^
ie IE
(defun clipboard/set (astring)
"Copy a string to clipboard"
(interactive "sAstring: ")
(let ((bstring (substring astring -11)))
(with-temp-buffer
(insert bstring)
(clipboard-kill-region (point-min) (point-max)))))
and close it at the very end.并在最后关闭它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.