branch: externals/auctex
commit 7390999883480bc80d2f065b65c896453d9d80c9
Author: Arash Esbati <ar...@gnu.org>
Commit: Arash Esbati <ar...@gnu.org>

    ; Simplify insertion of a newline after label
    
    * style/caption.el (LaTeX-arg-caption-captionof):
    * style/subcaption.el (LaTeX-arg-subcaption-subcaption): Simplify
    insertion of a newline after label.
---
 style/caption.el    | 38 +++++++++++++++++++-------------------
 style/subcaption.el | 12 +++++-------
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/style/caption.el b/style/caption.el
index ec1d36d..84809b9 100644
--- a/style/caption.el
+++ b/style/caption.el
@@ -293,25 +293,25 @@ STAR is non-nil, do not query for a short-caption and a 
label."
       (insert LaTeX-optop short-caption LaTeX-optcl))
     (TeX-argument-insert caption optional)
     (LaTeX-fill-paragraph)
-    (unless star
-      ;; 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.
-      (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)))))
+    (when (and (not star)
+              ;; 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.
+              (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))))
+      (LaTeX-newline)
+      (indent-according-to-mode)
+      (end-of-line))))
 
 (TeX-add-style-hook
  "caption"
diff --git a/style/subcaption.el b/style/subcaption.el
index 2893041..6c4405a 100644
--- a/style/subcaption.el
+++ b/style/subcaption.el
@@ -59,14 +59,12 @@ caption, insert only a caption."
     (insert TeX-grop caption TeX-grcl)
     ;; Fill the \subcaption paragraph before inserting the \label:
     (LaTeX-fill-paragraph)
-    (unless star
-      (save-excursion
-       (LaTeX-label currenv 'environment))
+    (when (and (not star)
+              (save-excursion (LaTeX-label currenv 'environment)))
       ;; Move \label into next line if we have one:
-      (when (looking-at (regexp-quote "\\label{"))
-       (LaTeX-newline)
-       (indent-according-to-mode)
-       (end-of-line)))))
+      (LaTeX-newline)
+      (indent-according-to-mode)
+      (end-of-line))))
 
 (defun LaTeX-arg-subcaption-subcaptionbox (optional &optional star)
   "Query for the arguments of \"\\subcaptionbox\" incl. a label and insert 
them.

Reply via email to