auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] [elpa] externals/auctex 69fc320 27/57: Add a newline only


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex 69fc320 27/57: Add a newline only if \label is inserted
Date: Wed, 11 Jan 2017 18:01:39 +0000 (UTC)

branch: externals/auctex
commit 69fc320c6f713806616b9722adcb12fa8fc4b297
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>

    Add a newline only if \label is inserted
    
    * style/caption.el (LaTeX-arg-caption-captionof):
    * style/bicaption.el (LaTeX-arg-bicaption-bicaption): Save the
    position before asking for a label.  Add a newline only if a label
    is inserted.
---
 style/bicaption.el |    9 +++++----
 style/caption.el   |   27 +++++++++++++++------------
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/style/bicaption.el b/style/bicaption.el
index b361393..ad3b0ca 100644
--- a/style/bicaption.el
+++ b/style/bicaption.el
@@ -110,11 +110,12 @@ arguments."
        (TeX-argument-insert width t)
        (TeX-argument-insert inpos t)))
     (LaTeX-fill-paragraph)
-    ;; Insert label
-    (when (and (not label-inside) (not star))
+    ;; Insert label -- a new line is inserted only if label is there:
+    (when (and (not label-inside) (not star)
+              (save-excursion (LaTeX-label currenv 'environment)))
       (LaTeX-newline)
       (indent-according-to-mode)
-      (LaTeX-label currenv 'environment))))
+      (end-of-line))))
 
 (defun LaTeX-arg-bicaption-captionsetup (optional)
   "Query for 2 arguments for \"\captionsetup\" with bicaption.sty loaded.
@@ -143,7 +144,7 @@ square brackets."
    (TeX-add-symbols
     '("bicaption"        (LaTeX-arg-bicaption-bicaption))
     '("bicaption*"       (LaTeX-arg-bicaption-bicaption  nil    t))
-    '("bicaptionbox"     (LaTeX-arg-bicaption-bicaption  nil   nil  t t)   t)
+    '("bicaptionbox"     (LaTeX-arg-bicaption-bicaption  nil   nil  t   t) t)
     '("bicaptionbox*"    (LaTeX-arg-bicaption-bicaption  nil    t   t)     t)
     '("bisubcaption"     (LaTeX-arg-bicaption-bicaption "sub-"))
     '("bisubcaption*"    (LaTeX-arg-bicaption-bicaption "sub-"  t))
diff --git a/style/caption.el b/style/caption.el
index f4b2ab0..f955c27 100644
--- a/style/caption.el
+++ b/style/caption.el
@@ -294,21 +294,24 @@ STAR is non-nil, do not query for a short-caption and a 
label."
     (TeX-argument-insert caption optional)
     (LaTeX-fill-paragraph)
     (unless star
-      (LaTeX-newline)
-      (indent-according-to-mode)
       ;; Check if `envtype' is a figure or a table, also consult
       ;; `LaTeX-label-alist' for additions from user or newfloat.el,
       ;; then run `LaTeX-label' w/ 'environment arg, otherwise w/o.
-      (if (or (member envtype figtypes)
-             (member envtype tabtypes)
-             (assoc envtype LaTeX-label-alist))
-         (LaTeX-label (cond ((member envtype figtypes)
-                             "figure")
-                            ((member envtype tabtypes)
-                             "table")
-                            (t envtype))
-                      'environment)
-       (LaTeX-label envtype)))))
+      (save-excursion
+       (if (or (member envtype figtypes)
+               (member envtype tabtypes)
+               (assoc envtype LaTeX-label-alist))
+           (LaTeX-label (cond ((member envtype figtypes)
+                               "figure")
+                              ((member envtype tabtypes)
+                               "table")
+                              (t envtype))
+                        'environment)
+         (LaTeX-label envtype)))
+      (when (looking-at-p "\\label{")
+       (LaTeX-newline)
+       (indent-according-to-mode)
+       (end-of-line)))))
 
 (TeX-add-style-hook
  "caption"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]