我正在从 Google Chrome 或 PDF 复制文本,然后粘贴到 Emacs 中。
原文有巧妙的引语。我不想在输出中使用智能引号。
有没有办法在复制端或粘贴端自动去除智能引号?
Tom*_*Tom 14
怎么样:
(defun replace-smart-quotes (beg end)
"Replace 'smart quotes' in buffer or region with ascii quotes."
(interactive "r")
(format-replace-strings '(("\x201C" . "\"")
("\x201D" . "\"")
("\x2018" . "'")
("\x2019" . "'"))
nil beg end))
Run Code Online (Sandbox Code Playgroud)
把它放在你的~/.emacs,你应该能够M-x replace-smart-quotes用来修复当前缓冲区或选定区域中的所有引号。
为避免重新启动 Emacs 以使~/.emacs更改生效,请将光标移动到defunwith的末尾M-C-e并对其进行评估C-x C-e。
更新评论:
要在猛拉(粘贴)时自动执行此操作,您可以执行以下操作:
(defun yank-and-replace-smart-quotes ()
"Yank (paste) and replace smart quotes from the source with ascii quotes."
(interactive)
(yank)
(replace-smart-quotes (mark) (point)))
Run Code Online (Sandbox Code Playgroud)
如果你想在你点击时这样做C-y,你可以使用以下方法绑定它:
(global-set-key (kbd "C-y") 'yank-and-replace-smart-quotes)
Run Code Online (Sandbox Code Playgroud)
使用另一个键可能是一个更好的主意(也许C-c y),因为这将使用一些默认yank功能。
| 归档时间: |
|
| 查看次数: |
2040 次 |
| 最近记录: |