-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfill-sentence.el
27 lines (26 loc) · 963 Bytes
/
fill-sentence.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;; Copied from Ingo Lohmar
;; Fills according to sentences (ignoring fill-column): Whenever there is
;; a new sentence, it inserts a line break
(defun fill-sentence ()
"Fill the current paragraph, separating sentences w/ a newline.
AUCTeX's latex.el reimplements the fill functions and is *very*
convoluted. We use part of it --- skip comment par we are in."
(interactive)
(if (save-excursion
(beginning-of-line) (looking-at TeX-comment-start-regexp))
(TeX-comment-forward)
(let ((to (progn
(LaTeX-forward-paragraph)
(point)))
(from (progn
(LaTeX-backward-paragraph)
(point)))
(to-marker (make-marker)))
(set-marker to-marker to)
(while (< from (marker-position to-marker))
(forward-sentence)
(setq tmp-end (point))
(LaTeX-fill-region-as-paragraph from tmp-end)
(setq from (point))
(unless (bolp)
(LaTeX-newline))))))