diff options
author | Ryan Kavanagh <rak@debian.org> | 2017-09-05 12:31:26 -0400 |
---|---|---|
committer | Ryan Kavanagh <rak@debian.org> | 2017-09-05 12:31:26 -0400 |
commit | 0a9560255c7f5f5e95b9437f764a4ad69c45714a (patch) | |
tree | 7f69fdadafd5cadfae28ad9e20be637d3c83cc2c | |
parent | Python crap (diff) |
Fix paragraph filling in latex/auctex
Diffstat (limited to '')
-rw-r--r-- | .emacs | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -246,8 +246,35 @@ convoluted. We use part of it --- skip comment par we are in." (unless (bolp) (LaTeX-newline)))))) + +;; http://www.cs.au.dk/~abizjak/emacs/2016/03/06/latex-fill-paragraph.html +(defun ales/fill-paragraph (&optional P) + "When called with prefix argument call `fill-paragraph'. +Otherwise split the current paragraph into one sentence per line." + (interactive "P") + (if (not P) + (save-excursion + (let ((fill-column 12345678)) ;; relies on dynamic binding + (fill-paragraph) ;; this will not work correctly if the paragraph is + ;; longer than 12345678 characters (in which case the + ;; file must be at least 12MB long. This is unlikely.) + (let ((end (save-excursion + (forward-paragraph 1) + (backward-sentence) + (point-marker)))) ;; remember where to stop + (beginning-of-line) + (while (progn (forward-sentence) + (<= (point) (marker-position end))) + (just-one-space) ;; leaves only one space, point is after it + (delete-char -1) ;; delete the space + (newline) ;; and insert a newline + (LaTeX-indent-line) ;; I only use this in combination with late, so this makes sense + )))) + ;; otherwise do ordinary fill paragraph + (fill-paragraph P))) + (eval-after-load "latex" - '(define-key LaTeX-mode-map (kbd "C-M-q") 'my-fill-latex-paragraph)) + '(define-key LaTeX-mode-map (kbd "M-q") 'ales/fill-paragraph)) (windmove-default-keybindings) (setq windmove-wrap-around t) |