auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 94db238bb188d22526410


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 94db238bb188d225264100a49ccbbcd43ade2140
Date: Fri, 18 Nov 2016 22:28:25 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  94db238bb188d225264100a49ccbbcd43ade2140 (commit)
       via  d6890e8c7d2fd925855e30d861887b0cf417dbb2 (commit)
      from  25e4f335868962e6d1db8a6cc8a507f5c46c2e2e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 94db238bb188d225264100a49ccbbcd43ade2140
Author: Arash Esbati <address@hidden>
Date:   Fri Nov 18 23:25:42 2016 +0100

    Improve caption and label insertion in style/caption.el
    
    * style/caption.el (LaTeX-caption-key-val-options): Add key slc
    which is an abbrev for singlelinecheck.
    (LaTeX-arg-caption-captionbox): Delete unused prompt argument.
    Ask for short caption acc. to the value of
    `LaTeX-short-caption-prompt-length'.  Use `LaTeX-label' instead of
    `TeX-insert-macro' to insert a label.  Use `TeX-argument-insert'
    instead of conditional insert.
    ("caption"): Do not fontify the last argument of \captionbox.
    Fontification happens within \begin...\end{tabular} or
    \includegraphics.

diff --git a/style/caption.el b/style/caption.el
index 4e394f0..87d9f82 100644
--- a/style/caption.el
+++ b/style/caption.el
@@ -1,8 +1,8 @@
 ;;; caption.el --- AUCTeX style for `caption.sty' (v3.3-111)
 
-;; Copyright (C) 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2015, 2016 Free Software Foundation, Inc.
 
-;; Author: Arash Esbati <esbati'at'gmx.de>
+;; Author: Arash Esbati <arash.esbati'at'gmail.com>
 ;; Maintainer: address@hidden
 ;; Created: 2015-02-21
 ;; Keywords: tex
@@ -80,6 +80,7 @@
     ("parskip")
     ("position"        ("top" "above" "bottom" "below" "auto"))
     ("singlelinecheck" ("false" "no" "off" "0" "true" "yes" "on" "1"))
+    ("slc"             ("false" "no" "off" "0" "true" "yes" "on" "1"))
     ("skip")
     ("strut"      ("false" "no" "off" "0" "true" "yes" "on" "1"))
     ("style"      ("base" "default"))
@@ -219,32 +220,40 @@ suffix of the command."
 ;; \captionbox[<list entry>]{<heading>}[<width>][<inner-pos>]{<contents>}
 ;; \captionbox*{<heading>}[<width>][<inner-pos>]{<contents>}
 
-(defun LaTeX-arg-caption-captionbox (optional &optional star prompt)
-  "Query for the arguments of `\\captionbox' incl. a label and
-insert them.  If STAR is non-nil, then do not query for a `\\label' and
-insert only a caption."
-  (let ((caption (TeX-read-string
-                 (TeX-argument-prompt optional prompt "Caption"))))
-    (LaTeX-indent-line)
+(defun LaTeX-arg-caption-captionbox (optional &optional star)
+  "Query for the arguments of \"\\captionbox\" incl. a label and insert them.
+If STAR is non-nil, then do not query for a \\label and a short
+caption, insert only a caption."
+  (let* ((currenv (LaTeX-current-environment))
+        (caption (TeX-read-string
+                  (TeX-argument-prompt optional nil "Caption")))
+        (short-caption
+         (when (and (not star)
+                    (>= (length caption) LaTeX-short-caption-prompt-length))
+           (TeX-read-string
+            (TeX-argument-prompt t nil "Short caption")))))
+    (indent-according-to-mode)
+    (when (and short-caption (not (string= short-caption "")))
+      (insert LaTeX-optop short-caption LaTeX-optcl))
     (insert TeX-grop caption)
-    (unless star (TeX-insert-macro "label"))
+    (unless star (LaTeX-label currenv 'environment))
     (insert TeX-grcl))
-  (let* ((width (completing-read (TeX-argument-prompt t prompt "Width")
-                                (mapcar (lambda(elt) (concat TeX-esc (car 
elt)))
+  (let* ((TeX-arg-opening-brace "[")
+        (TeX-arg-closing-brace "]")
+        (width (completing-read (TeX-argument-prompt t nil "Width")
+                                (mapcar (lambda (elt) (concat TeX-esc (car 
elt)))
                                         (LaTeX-length-list))))
-        (inpos (when (and width (not (string-equal width "")))
-                 (completing-read (TeX-argument-prompt t prompt "Inner 
position")
-                                  '("c" "l" "r" "s")))))
-    (cond (;; 2 optional args
-          (and width (not (string-equal width ""))
-               inpos (not (string-equal inpos "")))
-          (insert (format "[%s][%s]" width inpos)))
-         (;; 1st opt. arg, 2nd empty opt. arg
-          (and width (not (string-equal width ""))
-               (string-equal inpos ""))
-          (insert (format "[%s]" width)))
-         (t ; Do nothing if both empty
-          (ignore)))))
+        (inpos (if (and width (not (string-equal width "")))
+                   (completing-read (TeX-argument-prompt t nil "Inner 
position")
+                                    '("c" "l" "r" "s"))
+                 "")))
+    (TeX-argument-insert width t)
+    (TeX-argument-insert inpos t))
+  ;; Fill the paragraph before inserting {}.  We can use
+  ;; `LaTeX-fill-paragraph' without messing up the code since
+  ;; \caption starts a new paragraph with AUCTeX
+  ;; (cf. `paragraph-start').
+  (LaTeX-fill-paragraph))
 
 (TeX-add-style-hook
  "caption"
@@ -269,12 +278,12 @@ insert only a caption."
     '("captionof"
       (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type")
                    LaTeX-caption-supported-float-types)
-      ["List entry"] t)
+      ["Short caption"] t)
 
     '("captionof*"
       (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type")
                    LaTeX-caption-supported-float-types)
-      ["List entry"] t)
+      t)
 
     '("captionsetup"
       [TeX-arg-eval completing-read (TeX-argument-prompt t nil "Float type")
@@ -296,7 +305,7 @@ insert only a caption."
       (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type")
                    LaTeX-caption-supported-float-types))
 
-    '("captionbox"  ["List entry"] (LaTeX-arg-caption-captionbox) t)
+    '("captionbox"  (LaTeX-arg-caption-captionbox) t)
 
     '("captionbox*" (LaTeX-arg-caption-captionbox t) t)
 
@@ -351,7 +360,7 @@ insert only a caption."
      (font-latex-add-keywords '(("caption"           "*[{")
                                ("captionlistentry"  "[{")
                                ("captionof"         "*{[{")
-                               ("captionbox"        "*[{[[{"))
+                               ("captionbox"        "*[{[["))
                              'textual)
      (font-latex-add-keywords '(("captionsetup"                  "*[{")
                                ("clearcaptionsetup"             "*[{")

commit d6890e8c7d2fd925855e30d861887b0cf417dbb2
Author: Arash Esbati <address@hidden>
Date:   Fri Nov 18 23:18:18 2016 +0100

    Improve caption and label insertion in style/subcaption.el
    
    * style/subcaption.el (LaTeX-arg-subcaption-subcaption): Delete
    unused prompt argument.  Ask for short caption acc. to the value
    of `LaTeX-short-caption-prompt-length'.  Fill the inserted
    sub-caption before using `LaTeX-label' to insert the label.
    (LaTeX-arg-subcaption-subcaptionbox): Delete unused prompt
    argument.  Ask for short caption acc. to the value of
    `LaTeX-short-caption-prompt-length'.  Use `LaTeX-label' to insert
    the label.  Use `TeX-argument-insert' instead of conditional
    insert.
    ("subcaption"): Append package environments to `LaTeX-label-alist'.
    ("subcaption"): Do not fontify the last argument of
    \subcaptionbox.  Fontification happens within
    \begin...\end{tabular} or \includegraphics.

diff --git a/style/subcaption.el b/style/subcaption.el
index 6205366..7a116c2 100644
--- a/style/subcaption.el
+++ b/style/subcaption.el
@@ -36,50 +36,67 @@
   "Key=value options for subcaption package.  This key takes the
 same values as \"labelformat\" from caption package.")
 
-(defun LaTeX-arg-subcaption-subcaption (optional &optional star prompt)
-  "Query for the arguments of \\subcaption incl. a label and
-insert them.  If STAR is non-nil, then do not query for the lof entry
-and \\label and insert only a caption."
-  (let ((lof (unless star
-              (TeX-read-string
-               (TeX-argument-prompt t prompt "List entry"))))
-       (caption (TeX-read-string
-                 (TeX-argument-prompt optional prompt "Sub-caption"))))
-    (LaTeX-indent-line)
-    (when (and lof (not (string-equal lof "")))
-      (insert LaTeX-optop lof LaTeX-optcl))
+(defun LaTeX-arg-subcaption-subcaption (optional &optional star)
+  "Query for the arguments of \"\\subcaption\" incl. a label and insert them.
+If STAR is non-nil, then do not query for a \\label and a short
+caption, insert only a caption."
+  (let* (;; \subcaption needs an environment, "minipage" will be
+        ;; popular.  If so, check next higher environment to find out
+        ;; where we are
+        (currenv (if (string= (LaTeX-current-environment) "minipage")
+                     (LaTeX-current-environment 2)
+                   (LaTeX-current-environment)))
+        (caption (TeX-read-string
+                  (TeX-argument-prompt optional nil "Sub-caption")))
+        (short-caption
+         (when (and (not star)
+                    (>= (length caption) LaTeX-short-caption-prompt-length))
+           (TeX-read-string
+            (TeX-argument-prompt t nil "Short caption")))))
+    (indent-according-to-mode)
+    (when (and short-caption (not (string= short-caption "")))
+      (insert LaTeX-optop short-caption LaTeX-optcl))
     (insert TeX-grop caption TeX-grcl)
+    ;; Fill the \subcaption paragraph before inserting the \label:
+    (LaTeX-fill-paragraph)
     (unless star
       (LaTeX-newline)
-      (LaTeX-indent-line)
-      (TeX-insert-macro "label"))))
-
-(defun LaTeX-arg-subcaption-subcaptionbox (optional &optional star prompt)
-  "Query for the arguments of \\subcaptionbox incl. a label and
-insert them.  If STAR is non-nil, then do not query for a \\label and
-insert only a caption."
-  (let ((caption (TeX-read-string
-                 (TeX-argument-prompt optional prompt "Sub-caption"))))
-    (LaTeX-indent-line)
+      (indent-according-to-mode)
+      (LaTeX-label currenv 'environment))))
+
+(defun LaTeX-arg-subcaption-subcaptionbox (optional &optional star)
+  "Query for the arguments of \"\\subcaptionbox\" incl. a label and insert 
them.
+If STAR is non-nil, then do not query for a \\label and a short
+caption, insert only a caption."
+  (let* ((currenv (LaTeX-current-environment))
+        (caption (TeX-read-string
+                  (TeX-argument-prompt optional nil "Sub-caption")))
+        (short-caption
+         (when (and (not star)
+                    (>= (length caption) LaTeX-short-caption-prompt-length))
+           (TeX-read-string
+            (TeX-argument-prompt t nil "Short Sub-caption")))))
+    (indent-according-to-mode)
+    (when (and short-caption (not (string= short-caption "")))
+      (insert LaTeX-optop short-caption LaTeX-optcl))
     (insert TeX-grop caption)
-    (unless star (TeX-insert-macro "label"))
+    (unless star (LaTeX-label currenv 'environment))
     (insert TeX-grcl))
-  (let* ((width (completing-read (TeX-argument-prompt t prompt "Width")
+  (let* ((TeX-arg-opening-brace "[")
+        (TeX-arg-closing-brace "]")
+        (width (completing-read (TeX-argument-prompt t nil "Width")
                                 (mapcar (lambda (elt) (concat TeX-esc (car 
elt)))
                                         (LaTeX-length-list))))
-        (inpos (when (and width (not (string-equal width "")))
-                 (completing-read (TeX-argument-prompt t prompt "Inner 
position")
-                                  '("c" "l" "r" "s")))))
-    (cond (;; 2 optional args
-          (and width (not (string-equal width ""))
-               inpos (not (string-equal inpos "")))
-          (insert (format "[%s][%s]" width inpos)))
-         (;; 1st opt. arg, 2nd empty opt. arg
-          (and width (not (string-equal width ""))
-               (string-equal inpos ""))
-          (insert (format "[%s]" width)))
-         (t ; Do nothing if both empty
-          (ignore)))))
+        (inpos (if (and width (not (string-equal width "")))
+                   (completing-read (TeX-argument-prompt t nil "Inner 
position")
+                                    '("c" "l" "r" "s"))
+                 "")))
+    (TeX-argument-insert width t)
+    (TeX-argument-insert inpos t))
+  ;; Fill the paragraph before inserting {}.  We use this function
+  ;; since we add \subcaption to `paragraph-start' in the style hook
+  ;; below.
+  (LaTeX-fill-paragraph))
 
 (TeX-add-style-hook
  "subcaption"
@@ -96,7 +113,7 @@ insert only a caption."
     ;; Basic commands
     '("subcaption"     (LaTeX-arg-subcaption-subcaption))
     '("subcaption*"    (LaTeX-arg-subcaption-subcaption t))
-    '("subcaptionbox"  ["List entry"] (LaTeX-arg-subcaption-subcaptionbox) t)
+    '("subcaptionbox"  (LaTeX-arg-subcaption-subcaptionbox) t)
     '("subcaptionbox*" (LaTeX-arg-subcaption-subcaptionbox t) t)
     '("subref"         TeX-arg-ref)
     ;; \subref* is only available with hyperref.sty loaded, we don't
@@ -124,11 +141,18 @@ insert only a caption."
                    (TeX-argument-prompt nil nil "Type")
                    '("figure" "table"))))
 
+   ;; Everything starting with \subcaption should get its own line
+   (LaTeX-paragraph-commands-add-locally "subcaption")
+
    ;; The subfigure & subtable environments
    (LaTeX-add-environments
     '("subfigure" LaTeX-env-minipage)
     '("subtable"  LaTeX-env-minipage))
 
+   ;; Append them to `LaTeX-label-alist':
+   (add-to-list 'LaTeX-label-alist '("subfigure" . LaTeX-figure-label) t)
+   (add-to-list 'LaTeX-label-alist '("subtable" . LaTeX-table-label) t)
+
    ;; Introduce env's to RefTeX if loaded
    (when (fboundp 'reftex-add-label-environments)
      (reftex-add-label-environments
@@ -139,7 +163,7 @@ insert only a caption."
    (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("subcaption"            "*[{")
-                               ("subcaptionbox"         "*[{[[{")
+                               ("subcaptionbox"         "*[{[[")
                                ("phantomcaption"        "")
                                ("phantomsubcaption"     ""))
                              'textual)

-----------------------------------------------------------------------

Summary of changes:
 style/caption.el    |   67 ++++++++++++++++++---------------
 style/subcaption.el |  102 +++++++++++++++++++++++++++++++--------------------
 2 files changed, 101 insertions(+), 68 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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