2017-04-15 11 views
0

ファイルマネージャでファイルを右クリックしてEmacsで文書を開くときに、次の関数(Replace one space by two after sentences in Emacs)を起動します。Emacsの起動時に関数を実行する方法

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

これは、既存の2つのスペースの発生のスペースを増やすことなく、". "". "に変換します。

どのようにこれを行うことができます。私はinit.elに(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. 
+0

これは特定の種類のファイルですか?私はおそらく適切なメジャーモードにフックを追加するだろう。 – Chris

答えて

1

は試してみてください。

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

しかし、これはに開くすべてのファイルを、あなたの関数を実行します。それはあなたが欲しいものですか?

関連する問題