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平台下面 ...
随机推荐
- 斐波那契数列-java编程:三种方法实现斐波那契数列
题目要求:编写程序在控制台输出斐波那契数列前20项,每输出5个数换行 斐波那契数列指的是这样一个数列:1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, … 这个数列 ...
- 正则表达式在python中的简单使用
正则表达式独立与编程语言,基本上所有的编程语言都实现了正则表达式的相关操作.在Python中正则表达式的表现为re模块: import re 其操作有三个方法: my_string = "h ...
- Gym 102091K The Stream of Corning 2【线段树】
<题目链接> 题目大意: 进行两种操作:1.给定一个数的出现时间.价值.消失时间: 2.进行一次询问,问你当前时间,第K大的数的价值. 解题分析: 采用离线集中处理,将每个数的出现时间和它 ...
- Mysql数据库报错:Cannot add or update a child row: a foreign key constraint fails(添加多对多关系)
#创建班级表 class Classes(models.Model): title = models.CharField(max_length=32) n=models.ManyToManyField ...
- Beautifulsoup关于find的测试
from bs4 import BeautifulSoup import requests url='https://book.douban.com/subject_search?search_tex ...
- 关于GitHub中文乱码的问题
其实跟Git里中文乱码相比,这个问题好解决得多. GitHub中的乱码是由于其使用的编码与Windows记事本的默认编码不同.只要在本地将编码改成UTF-8,再重新push就可以了. 修改编码的方法是 ...
- webpack打包之无依赖模块
一.入口文件main.js // main.js console.log('webpack'); 二.出口文件bundle.js 1.浏览代码 2.本质 // 实际就是一个自执行函数 (functio ...
- opencv3 学习笔记(二)
1.OpenCv 颜色追踪 import cv2import numpy as npcap=cv2.VideoCapture(0)cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1 ...
- 因数表进阶:1--x的因数和
紧接着上一个文章,进阶一个因数表,来自牛客网一道比赛题: 打从1到n所有因数的和 代码如下: #include<cstdio> #define ll long long using nam ...
- Module not found: Error: Can't resolve 'XXX' in 'XXXX'
故障 控制台运行webpack/npm时出现 Module not found: Error: Can't resolve 'XXX' in 'XXXX' 解决方案 npm i XXX --save ...