[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-devel] LaTeX-fill-region-as-paragraph: each sentence starts in a
From: |
Uwe Brauer |
Subject: |
[AUCTeX-devel] LaTeX-fill-region-as-paragraph: each sentence starts in a new line |
Date: |
Thu, 08 Sep 2016 08:13:26 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
Hi
One of the few things I miss in vanilla auctex, is a generalisation of
LaTeX-fill-region-as-paragraph: each sentence starts in a new line.
That is very helpful if one uses a version-control system for ones LaTeX
files.
The issue has been discussed for example in
http://stackoverflow.com/questions/539984/how-do-i-get-emacs-to-fill-sentences-but-not-paragraphs
I tested all the proposed solutions and must say the best one is the one
found in
http://pleasefindattached.blogspot.de/2011/12/emacsauctex-sentence-fill-greatly.html
It uses defadvice:
(defadvice LaTeX-fill-region-as-paragraph (around LaTeX-sentence-filling)
"Start each sentence on a new line."
(let ((from (ad-get-arg 0))
(to-marker (set-marker (make-marker) (ad-get-arg 1)))
tmp-end)
(while (< from (marker-position to-marker))
(forward-sentence)
;; might have gone beyond to-marker --- use whichever is smaller:
(ad-set-arg 1 (setq tmp-end (min (point) (marker-position to-marker))))
ad-do-it
(ad-set-arg 0 (setq from (point)))
(unless (or
(bolp)
(looking-at "\\s *$"))
(LaTeX-newline)))
(set-marker to-marker nil)))
(ad-activate 'LaTeX-fill-region-as-paragraph)
A couple of questions and suggestions:
- could anyone with knowledge of the original
LaTeX-fill-region-as-paragraph try to implement this feature
without using defadvice.
- if not, could that code be included, although it uses defadvice.
Of course if would then be necessary to ask for permission and to
convince the author to sign the relevant FSF papers [1], which I
could try to do, if the maintainer think the code should be
included.
Regards
Uwe Brauer
Footnotes:
[1] which can take some time as I recently learnt.
- [AUCTeX-devel] LaTeX-fill-region-as-paragraph: each sentence starts in a new line,
Uwe Brauer <=