I am new to emacs and would like to make a simple function to automate a series of commands I use repeatedly.
In auto-fill-mode
after I edit the text I often need to re-wrap the lines. (I am writing in LaTeX with each sentence starting on a new line.) To do this I type M-a
,C-SPC
,M-e
,M-q
. This is equivalent to backward-sentence
, set-mark-command
, forward-sentence
, fill-region
.
How can I wrap these together in one simple command?
This is my non-working attempt:
(defun fill-sentence()
"In auto-fill mode, select current sentence and re-wrap it."
(interactive)
((backward-sentence)
(set-mark-command)
(forward-sentence)
(fill-region)))