1

当我右键单击文件管理器中的文件以使用 Emacs 打开文档时,我想开始执行以下功能(从Emacs 中的句子后用两个替换一个空格)运行。

(defun space12 ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "\\. \\([^ ]\\)" nil t)
      (replace-match ".  \\1" t))))

这将转换". "". "不增加现有两个空间出现的空间。

如何才能做到这一点。我想将 (space12) 添加到 init.el 但它似乎是在加载文档之前加载的。

样本输入:

This is for test. This is second line with only one space at start.  This is third line which already has 2 spaces before it. End of document.
4

1 回答 1

2

尝试将此添加到您的 init.el:

(add-hook 'find-file-hook 'space12)

但是,这将在您打开的每个文件上运行您的函数。那是你要的吗?

于 2017-04-15T15:46:32.723 回答