I want start following function (from Replace one space by two after sentences in Emacs) to run when I right click a file in file-manager to open the document with Emacs.
(defun space12 ()
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\. \\([^ ]\\)" nil t)
(replace-match ". \\1" t))))
This converts ". "
to ". "
without increasing spaces of existing two space occurrences.
How can this be done. I thought of adding (space12) to init.el but it seems to be loaded before the document is loaded.
Sample input:
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.
Try adding this to your init.el:
(add-hook 'find-file-hook 'space12)
However this will run your function on every file you open. Is that what you want?