[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 125/299: Simplify LaTeX-env-figure function.
From: |
Stefan Monnier |
Subject: |
[elpa] 125/299: Simplify LaTeX-env-figure function. |
Date: |
Sun, 02 Nov 2014 03:10:49 +0000 |
monnier pushed a commit to branch externals/auctex
in repository elpa.
commit 8d79fea407043cd3950fda8aa7621a247f4a8480
Author: Mosè Giordano <address@hidden>
Date: Fri May 31 20:49:50 2013 +0200
Simplify LaTeX-env-figure function.
* latex.el (LaTeX-env-figure): Simplify using `save-excursion'
instead of regexp searches. Fill the caption when
`auto-fill-mode' is on.
---
ChangeLog | 6 +++++
latex.el | 66 +++++++++++++++++++++++++++---------------------------------
2 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2a12e48..12303f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-05-31 Mos� Giordano <address@hidden>
+
+ * latex.el (LaTeX-env-figure): Simplify using `save-excursion'
+ instead of regexp searches. Fill the caption when
+ `auto-fill-mode' is on.
+
2013-05-30 Mos� Giordano <address@hidden>
* tex.el (TeX-expand-list): Add new expander "%a", it returns the
diff --git a/latex.el b/latex.el
index 46acae0..5795307 100644
--- a/latex.el
+++ b/latex.el
@@ -965,46 +965,40 @@ job to this function."
(insert TeX-esc "centering")
(indent-according-to-mode)
(LaTeX-newline))
- (if (member environment LaTeX-top-caption-list)
- ;; top caption -- do nothing if user skips caption
- (unless (zerop (length caption))
- (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
+ ;; Insert caption and ask for a label, do nothing if user skips caption
+ (unless (zerop (length caption))
+ (if (member environment LaTeX-top-caption-list)
+ ;; top caption
+ (progn
+ (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
+ ;; If `auto-fill-mode' is active, fill the caption.
+ (if auto-fill-function (LaTeX-fill-paragraph))
+ (LaTeX-newline)
+ (indent-according-to-mode)
+ ;; ask for a label and insert a new line only if a label is
+ ;; actually inserted
+ (when (LaTeX-label environment)
+ (LaTeX-newline)
+ (indent-according-to-mode)))
+ ;; bottom caption (default)
+ (when active-mark (goto-char end-marker))
+ (save-excursion
(LaTeX-newline)
(indent-according-to-mode)
- ;; ask for a label and insert a new line only if a label is
- ;; actually inserted
- (when (LaTeX-label environment)
+ ;; If there is an active region point is before the backslash of
+ ;; "\end" macro, go one line upwards.
+ (when active-mark (forward-line -1) (indent-according-to-mode))
+ (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
+ ;; If `auto-fill-mode' is active, fill the caption.
+ (if auto-fill-function (LaTeX-fill-paragraph))
+ ;; ask for a label and if necessary insert a new line between caption
+ ;; and label
+ (when (save-excursion (LaTeX-label environment))
(LaTeX-newline)
(indent-according-to-mode)))
- ;; bottom caption (default) -- do nothing if user skips caption
- (unless (zerop (length caption))
- (when active-mark (goto-char end-marker))
- (LaTeX-newline)
- (indent-according-to-mode)
- (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
- (LaTeX-newline)
- (indent-according-to-mode)
- ;; ask for a label -- if user skips label, remove the last new
- ;; line again
- (if (LaTeX-label environment)
- (progn
- (unless (looking-at "[ \t]*$")
- (LaTeX-newline)
- (end-of-line 0)))
- (delete-blank-lines)
- (end-of-line 0))
- ;; if there is a caption or a label, move point upwards again
- ;; so that it is placed above the caption or the label (or
- ;; both) -- search the current line (even long captions are
- ;; inserted on a single line, even if auto-fill is turned on,
- ;; so it is enough to search the current line) for \label or
- ;; \caption and go one line upwards if any of them is found
- (while (re-search-backward
- (concat "^\\s-*" (regexp-quote TeX-esc)
- "\\(label\\|caption\\)")
- (line-beginning-position) t)
- (end-of-line 0)
- (indent-according-to-mode))))
+ ;; Insert an empty line between caption and marked region, if any.
+ (when active-mark (LaTeX-newline) (forward-line -1))
+ (indent-according-to-mode)))
(when (and (member environment '("table" "table*"))
;; Suppose an existing tabular environment should just
;; be wrapped into a table if there is an active region.
- [elpa] 114/299: Wrap dollars around active region typing `$'., (continued)
- [elpa] 114/299: Wrap dollars around active region typing `$'., Stefan Monnier, 2014/11/01
- [elpa] 119/299: Fixes to TeX-arg-index-tag, TeX-arg-cite, TeX-parse-arguments., Stefan Monnier, 2014/11/01
- [elpa] 117/299: Insert one $ when point is in a verbatim construct., Stefan Monnier, 2014/11/01
- [elpa] 109/299: Fix in TeX-arg-insert-braces., Stefan Monnier, 2014/11/01
- [elpa] 121/299: Silence some compilation warning., Stefan Monnier, 2014/11/01
- [elpa] 124/299: Make forward PDF search with Okular work., Stefan Monnier, 2014/11/01
- [elpa] 123/299: Fix docstring of `TeX-source-correlate-sync-source'., Stefan Monnier, 2014/11/01
- [elpa] 116/299: Temporary fix for font-latex-jit-lock-force-redisplay., Stefan Monnier, 2014/11/01
- [elpa] 126/299: Fix for autogen.sh., Stefan Monnier, 2014/11/01
- [elpa] 118/299: Add new style files fancyvrb.el and xparse.el., Stefan Monnier, 2014/11/01
- [elpa] 125/299: Simplify LaTeX-env-figure function.,
Stefan Monnier <=
- [elpa] 127/299: Execute TeX-run-compile in TeX-master-directory., Stefan Monnier, 2014/11/01
- [elpa] 120/299: Move remaining .cvsignore to .gitignore., Stefan Monnier, 2014/11/01
- [elpa] 122/299: Expand biblatex style file., Stefan Monnier, 2014/11/01
- [elpa] 129/299: Document LaTeX-find-matching-begin and LaTeX-find-matching-end., Stefan Monnier, 2014/11/01
- [elpa] 128/299: New variable TeX-electric-math., Stefan Monnier, 2014/11/01
- [elpa] 130/299: Add reference to Gmane thread in ChangeLog., Stefan Monnier, 2014/11/01
- [elpa] 133/299: Fix compile error with emacs bzr which assumes elisp files are UTF-8 encoded., Stefan Monnier, 2014/11/01
- [elpa] 132/299: Fix `TeX-next-error'., Stefan Monnier, 2014/11/01
- [elpa] 131/299: New hooks TeX-after-document-hook and LaTeX-after-usepackage-hook., Stefan Monnier, 2014/11/01
- [elpa] 136/299: Simplify TeX-doc-backend-alist., Stefan Monnier, 2014/11/01