Ala*_*ing 11 emacs replace case-sensitive dot-emacs
我刚刚问了一个相关的问题(setq问题),但它有明显的不同,所以我决定分开这个问题.
在我的.emacs
文件中,我定义了一个绑定到该replace-string
命令的键:
(define-key global-map "\C-r" 'replace-string)
Run Code Online (Sandbox Code Playgroud)
replace-string
做基本的搜索和替换.假设搜索字符串的第一个字母是小写,如果case-fold-search
是,nil
则进行replace-string
区分大小写的搜索,否则它会进行不区分大小写的搜索.
问题是case-fold-search
控制"搜索"(如search-forward
命令)和"搜索和替换"(如replace-string
命令)的"区分大小写" .
现在的问题是如何让我JUST的replace-string
命令(或任何C-r
必然)区分大小写,留下search-forward
不区分大小写的,因为它是在默认情况下.
也许我需要设置case-fold-search
到nil
只为replace-string
命令,但我不知道该怎么做.
dfa*_*fan 10
把它放在你的.emacs中:
(defadvice replace-string (around turn-off-case-fold-search)
(let ((case-fold-search nil))
ad-do-it))
(ad-activate 'replace-string)
Run Code Online (Sandbox Code Playgroud)
这确实你说什么,设定case-fold-search
到nil
只为replace-string
.
实际上,这几乎就是Emacs Lisp参考手册中的示例.
试试这个方法,不需要建议:
(global-set-key (kbd "C-r")
(lambda ()
(interactive)
(let ((case-fold-search nil))
(call-interactively 'replace-string))))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2870 次 |
最近记录: |