aboutsummaryrefslogtreecommitdiff
path: root/.emacs
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@debian.org>2015-05-11 11:29:45 -0400
committerRyan Kavanagh <rak@debian.org>2015-05-11 11:29:45 -0400
commit143f1b57acdbb270292e5aad31f3c2e3b8767f0d (patch)
treece6585fcdd4841787640aeacf0b2be38f74dde4a /.emacs
parentICD (diff)
Emacs
Diffstat (limited to '')
-rw-r--r--.emacs38
1 files changed, 38 insertions, 0 deletions
diff --git a/.emacs b/.emacs
index f2488ea..222692c 100644
--- a/.emacs
+++ b/.emacs
@@ -129,3 +129,41 @@
(fset 'yes-or-no-p 'y-or-n-p)
(put 'narrow-to-region 'disabled nil)
+
+;; Sentence-fill hack
+;; ==================
+;;
+;; The macros here are based on emacs/23.3/lisp/textmodes/fill.el.gz.
+;; To use them without modifying emacs, you can simply execute `cat
+;; hack.el >> ~/.emacs` if you have downloaded this file (say, by
+;; git). Otherwise, you can use
+;;
+;; curl http://fermi.mycloudnas.com/cgit.cgi/fill/plain/hack.el >> ~/.emacs
+
+(defun auto-fill-by-sentences ()
+ (if (looking-back (sentence-end))
+ ;; Break at a sentence
+ (progn
+ (LaTeX-newline)
+ t)
+ ;; Fall back to the default
+ (do-auto-fill)))
+(add-hook 'LaTeX-mode-hook (lambda () (setq auto-fill-function 'auto-fill-by-sentences)))
+
+;; Modified from http://pleasefindattached.blogspot.com/2011/12/emacsauctex-sentence-fill-greatly.html
+(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 (looking-back "^\\s *")
+ (looking-at "\\s *$"))
+ (LaTeX-newline)))
+ (set-marker to-marker nil)))
+(ad-activate 'LaTeX-fill-region-as-paragraph)