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)))
fill-paragraph
trims newlines to adjust the whole paragraph. – musarithmia Nov 5 '15 at 17:41visual-line-mode
in the past but am experimenting withauto-fill-mode
instead to see if there are any advantages. – musarithmia Nov 5 '15 at 18:46fill-sentence
won't change adjacent sentences the way it does in my tests on normal paragraphs. – Tyler Nov 5 '15 at 18:54