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
(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 "sAstring: ")
Also, the syntax of let
is different, it starts with a list of lists of variables and values, ie
(let ((bstring (substring astring -11)))
; ^^
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.