2017-04-15 29 views
0

我想要啓動以下功能(從Replace one space by two after sentences in Emacs)運行時,我右鍵單擊文件管理器中的文件以使用Emacs打開文檔。如何在Emacs啓動時執行一個函數

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

這種轉換". "". "在不增加現有兩家空間發生的空間。

這是怎麼做到的。我想爲init.el添加(space12),但它似乎在文檔加載之前加載。

樣品輸入:

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. 
+0

這是針對特定類型的文件嗎?我可能會添加一個鉤子到適當的主要模式。 – Chris

回答

1

嘗試添加以下內容到init.el:

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

然而,這將在運行功能的每一文件打開。那是你要的嗎?

相關問題