I would like to change the behavior of fill-paragraph in certain modes (e.g. LaTeX-mode provided by AucTeX).
I could just rebind the key M-q, but I am also using evil-mode whose implementation of evil-fill-and-move uses fill-region. Ideally, my custom fill function to override both the functions fill-paragraph (so it works with M-q) and fill-region (so it works with evil).
Assuming that I have a standalone program format that takes in LaTeX code via stdin and output formatted code on stdout, how would I go about override the above two fill functions to use format?
(Note: this is similar to vim's formatprg option.)
M-qaffectevil-fill-and-movein anyway ? I do not use evil hence I am curious. If region is activefill-paragraphcallsfill-regionanyway. So you might advice or replacefill-regionwith your function. – Vamsi Sep 24 '14 at 01:02evil-fill-and-moveis bound to the key sequencegqin evil's normal mode. RebindingM-qshould not affect this keybinding.In some sense, my question is really two questions:
The reason for 2) is that I already have an external, non-Elisp solution.
– Kevin Sep 24 '14 at 01:06(add-hook 'LaTeX-mode-hook (lambda () local-set-key (kbd "M-q") 'your-fill-function))whereyour-fill-functionis your custom elisp defun. This will set that key combo only in Auctex. You could probably useshell-command-on-regionwith the REPLACE argument to defineyour-fill-function. – Vamsi Sep 24 '14 at 01:18