emacs - 如何在 Emacs 中复制字符串并粘贴子字符串?
问题描述
在网上找到这个:
(defun clipboard/set (astring)
"Copy a string to clipboard"
(with-temp-buffer
(insert astring)
(clipboard-kill-region (point-min) (point-max))))
我想让它交互,通过子字符串运行字符串,然后将其复制到剪贴板
(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))))
如何做到这一点?
解决方案
您需要告诉interactive
如何填充参数:
(interactive "sAstring: ")
此外, 的语法let
不同,它以变量和值列表的列表开头,即
(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)))))
并在最后关闭它。
推荐阅读
- sql-server - ASP.NET 应用程序使用唯一的活动目录凭据连接到远程 SQL Server
- android - 完全透明的状态栏在某些设备上不起作用
- c# - QnA Api 返回响应代码 200 OK,无论 KB 中是否存在匹配项
- c# - 我可以创建 C# 独立应用程序而不是在 Windows 中安装而不运行吗?
- java - 哪些版本的 Atlassian 插件 SDK 支持哪些版本的 confluence?
- sql - 如何按家庭计算孩子的数量并将其放在oracle中的父行中
- python - 如何在 django 中保存一个模型的 3 种形式?
- javascript - 将 STEP 文件导入到 three.js / 在 JS 中将 STEP 转换为 STL?
- swift - 禁用特定的选择器项目
- javascript - 我应该使用 useselector/useDispatch 而不是 mapStateToProps