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-q
affectevil-fill-and-move
in anyway ? I do not use evil hence I am curious. If region is activefill-paragraph
callsfill-region
anyway. So you might advice or replacefill-region
with your function. – Vamsi Sep 24 '14 at 01:02evil-fill-and-move
is bound to the key sequencegq
in evil's normal mode. RebindingM-q
should 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-function
is your custom elisp defun. This will set that key combo only in Auctex. You could probably useshell-command-on-region
with the REPLACE argument to defineyour-fill-function
. – Vamsi Sep 24 '14 at 01:18