Emacs 不将M-Del删除的单词加入粘贴板
原文:https://jblevins.org/log/clipboard
I use a clipboard manager called Copied that syncs previously copied text across all my devices. Short of having an OS X version of Drafts, this is a very efficient way to get text from a Mac to an iOS device. However, when I’m working in Emacs, my clipboard history quickly becomes cluttered because every bit of text I “kill” in Emacs gets “copied” to the system pasteboard and then synchronized to all of my devices.
Indeed, every time I select a sentence or paragraph and kill it with C-w (kill-region), that text gets added to the clipboard history. Worse still, every time I press M-DEL (backward-kill-word) to kill the previous word, that word also gets added to my history. I use these commands a lot, so even with a history of 100 previous items, the important items in my history are quickly buried under a heap of words and phrases that I have killed in Emacs during the normal process of writing and editing text.
This is mitigated to some extent by the fact that Copied allows one to quickly filter the history by just typing a search string in the main window. However, I discovered today that Emacs has a minor mode called delete-selection-mode and when this mode is active, the region is replaced when a character is inserted or deleted (e.g., with backspace). The practical implication of this is that one can remove the active region by pressing DEL rather than C-w:
By default, text insertion occurs normally even if the mark is active–for example, typing a inserts the character ‘a’, then deactivates the mark. If you enable Delete Selection mode, a minor mode, then inserting text while the mark is active causes the text in the region to be deleted first. To toggle Delete Selection mode on or off, type M-x delete-selection-mode.
Source: GNU Emacs Manual, section 11.3.
Also see DeleteSelectionMode on the EmacsWiki and in the Emacs FAQ. To summarize, if one uses DEL instead of C-w to remove text in the active region, it won’t end up in the kill ring or clipboard history. Somehow this slipped by me, but delete-selection-mode is enabled by default in Emacs 24 and 25.
Replacing M-DEL with an alternative that deletes without adding to the kill ring is less obvious. Without adding a custom function, a long version would be C-SPC M-b DEL. This sequence activates the mark1, moves the point backward by one word, and deletes the active region. If you find yourself using this often, it might be better to define a backward-delete-word function to your init.el (source):
(defun backward-delete-word (arg)
"Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (backward-word arg) (point))))
I moved the default backward-kill-word binding to C-M-DEL and set M-DEL to this new function:
(global-set-key (kbd "C-M-<backspace>") 'backward-kill-word)
(global-set-key (kbd "M-DEL") 'backward-delete-word)
Emacs 不将M-Del删除的单词加入粘贴板的更多相关文章
- Python对象引用和del删除引用
1.首先介绍下python的对象引用 1)Python中不存在传值调用,一切传递的都是对象引用,也可以认为是传址调用.即Python不允许程序员选择采用传值或传引用.Python参数传递采用的是“传对 ...
- C# 命令行如何静默调用 del 删除文件
如果在 C# 命令行调用 del 删除文件,很多时候会提示是否需要删除,本文告诉大家如何调用命令行的时候静默删除 在C# 命令行 调用 del 删除文件的时候,会提示是否删除,通过在命令行加上 \Q ...
- iOS——文件操作NSFileManager (创建、删除,复制,粘贴)
iOS——文件操作NSFileManager (创建.删除,复制,粘贴) iOS的沙盒机制,应用只能访问自己应用目录下的文件.iOS不像android,没有SD卡概念,不能直接访问图像.视 ...
- linux(4) vi编辑/删除、复制、粘贴 /bash shell 环境变量设置/数据流重定向 | 的用法
一.vi文字处理器1.vi与vimvi:文字处理器vim:程序开发工具2.vi介绍三种模式:一般模式(vi刚进入的,不可编辑),编辑模式(按i后,左下方是insert)和命令行模式(按esc退出,:w ...
- VS Code 配置删除左边单词快捷键(同Sublime 和 Atom)
VS Code 中删除一行的快捷键默认是 cmd + shift + k,或者使用简介 cmd + x,对于一个长期使用 Sublime 和 Atom 的程序猿来说,在VS Code 上删除行,特别是 ...
- vim 删除单个单词,cc和dd关系
c 功能和d相同,区别在于完成删除操作后进入INSERT MODE cc 也是删除当前行,然后进入INSERT MODE 删除每行第一个字符 :%s/^.//g ...
- 列表:remove/del删除方法中的逻辑“误区”
结果: list_1=["A","B","C","D","E","F",&quo ...
- Myeclipse for Mac快捷键
myeclipse for mac 的快捷键汇总 快键键 作用 备注 Command+1 快速修复(自动导包等) 比如与Syso配合,与main配合可快速构造方法签名 Alt+/ 自动补全 Comma ...
- MyEclipse for mac 快捷键
原文出处:http://blog.csdn.net/ray_seu/article/details/17384463 一直比较欣赏myeclipse的快捷键,网上搜索了一圈,发现windows平台下面 ...
随机推荐
- 解决资源id冲突
--摘自<android插件化开发指南> 1.一套完整的Android App打包流程(Gradle方案) 第一步:aapt.为res目录下的资源生成R.java文件,同时为Android ...
- hdu 4725 The Shortest Path in Nya Graph 【拆点】+【最短路】
<题目链接> <转载于 >>> > 题目大意: 每个点放在一层,然后给了n个点,相邻的两层距离是固定的c,有额外m条无向边,然后求1到n的最短路径,如果没有 ...
- 【java并发核心八】Fork-Join分治编程
jdk1.7中提供了Fork/Join并行执行任务框架,主要作用就是把大任务分割成若干个小任务,再对每个小任务得到的结果进行汇总. 正常情况下,一些小任务我们可以使用单线程递归来实现,但是如果要想充分 ...
- SpringMVC(二八) 重定向
在控制器中在返回的字符串中使用 return "redirect:/index.jsp" 的形式,使返回重定向到另外一个页面. 控制器参考代码: package com.tiek ...
- orz gzy
然而orz gzy内嵌不进去...
- 2017-9-15-Linux移植:WinSCP软件 & SSH Server开启
在Linux电脑上面安装了TFTP server,但是各种不给力,决定寻找其他办法在Windows和Linux之间传输文件. WinSCP 是一个 Windows 环境下使用 SSH 的开源图形化 S ...
- JavaScript基础笔记(九)事件
事件 一.事件流 事件流描述的是从页面中接收事件的顺序. 一)事件冒泡 IE的事件流叫做事件冒泡,即事件开始时由最具体的元素接收,然后逐级向上传播到较为不具体的节点. 如:div------>b ...
- [蓝点ZigBee] Zstack 之点亮OLED液晶 ZigBee/CC2530 视频资料
这一小节主要演示如何在Zstack 下移植液晶驱动,我们选取了目前比较流行的OLED 作为移植目标. 移植关键点 1 修改 GPIO pin, 2 如何将Zstack ...
- tcp协议下粘包问题的产生及解决方案
1 tcp有粘包及udp无粘包 - TCP 是面向连接的,面向流的可靠协议:发送端为了将多个发往接收端的包,更有效的发到对方,使用了优化方法(Nagle算法),将多次间隔较小且数据量小的数据, 合并成 ...
- 第2讲——wiz
PC端信息收集 网页剪藏 win+s 屏幕截图:win+printscreen微博收集:@mywiz @我的印象笔记 按ESC隐藏/恢复左边导航栏 F11全屏阅读 打标签:解决文件夹重叠问题 搜索 ...