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. e3c60cfa033546bf8c11d


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. e3c60cfa033546bf8c11dd9956a68de65ff7b38e
Date: Mon, 21 Nov 2016 20:00:20 +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  e3c60cfa033546bf8c11dd9956a68de65ff7b38e (commit)
       via  cb6bc118ee622257d0152ca8637b60fbf1d7c6ca (commit)
       via  b59075b4b6c1db93372b1a6f74e50a564ba2d18e (commit)
      from  94db238bb188d225264100a49ccbbcd43ade2140 (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 e3c60cfa033546bf8c11dd9956a68de65ff7b38e
Author: Arash Esbati <address@hidden>
Date:   Mon Nov 21 20:59:15 2016 +0100

    Add new style/bicaption.el
    
    * Makefile.in (STYLESRC): Add new style.
    
    * style/bicaption.el: New file.

diff --git a/Makefile.in b/Makefile.in
index ebc1906..a291ed2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -157,7 +157,8 @@ STYLESRC = style/prosper.el \
           style/splitidx.el  style/tikz.el      style/xcolor.el \
           style/pdflscape.el style/commath.el   style/empheq.el \
           style/framed.el    style/paracol.el   style/menukeys.el \
-          style/bidi.el      style/FiraMono.el  style/FiraSans.el
+          style/bidi.el      style/FiraMono.el  style/FiraSans.el \
+          style/bicaption.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
diff --git a/style/bicaption.el b/style/bicaption.el
new file mode 100644
index 0000000..b361393
--- /dev/null
+++ b/style/bicaption.el
@@ -0,0 +1,181 @@
+;;; bicaption.el --- AUCTeX style for `bicaption.sty' (v1.1-158)
+
+;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <arash.esbati'at'gmail.com>
+;; Maintainer: address@hidden
+;; Created: 2016-11-11
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `bicaption.sty' (v1.1-158) from
+;; 2016/03/27.  `bicaption.sty' is part of TeXLive.
+
+;; If things do not work or when in doubt, press `C-c C-n'.  Comments
+;; for improvement are welcome.
+
+;;; Code:
+
+(defvar LaTeX-bicaption-key-val-options
+  '(("bi-lang" ("first" "second" "both"))
+    ("bi-singlelinecheck" ("false" "no" "off" "0" "true" "yes" "on" "1"))
+    ("bi-slc" ("false" "no" "off" "0" "true" "yes" "on" "1"))
+    ("bi-swap" ("false" "no" "off" "0" "true" "yes" "on" "1"))
+    ("listtype+"))
+  "Key=value options for bicaption macros.")
+
+(defun LaTeX-arg-bicaption-bicaption (optional &optional prompt star cap-box 
label-inside)
+  "Query for the arguments of \"\\bicaption\" incl. a label and insert them.
+PROMPT replaces the standard one.  If STAR is non-nil, then do
+not query for a \\label and short captions, insert only captions.
+If CAP-BOX is non-nil, also query and include optional arguments
+for the box command.  If LABEL-INSIDE is non-nil, insert \\label
+inside the first mandatory argument, otherwise after all
+arguments."
+  (let* (;; \bisubcaption 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)))
+        (captionI (TeX-read-string
+                   (TeX-argument-prompt
+                    optional (when prompt
+                               (concat "1. " prompt "bicaption"))
+                    "1. bicaption")))
+        (short-captionI
+         (when (and (not star)
+                    (>= (length captionI) LaTeX-short-caption-prompt-length))
+           (TeX-read-string
+            (TeX-argument-prompt t (when prompt
+                                     (concat "Short 1. " prompt "bicaption"))
+                                 "Short 1. bicaption"))))
+        (captionII (TeX-read-string
+                    (TeX-argument-prompt
+                     optional (when prompt
+                                (concat "2. " prompt "bicaption"))
+                     "2. bicaption")))
+        (short-captionII
+         (when (and (not star)
+                    (>= (length captionII) LaTeX-short-caption-prompt-length))
+           (TeX-read-string
+            (TeX-argument-prompt t (when prompt
+                                     (concat "Short 2. " prompt "bicaption"))
+                                 "Short 2. bicaption")))))
+    (indent-according-to-mode)
+    ;; Insert short & regular 1. caption
+    (when (and short-captionI (not (string= short-captionI "")))
+      (insert LaTeX-optop short-captionI LaTeX-optcl))
+    (insert TeX-grop captionI)
+    ;; For \bi(sub)?captionbox, the label must be inserted here
+    (when (and label-inside (not star))
+      (LaTeX-label currenv 'environment))
+    (insert TeX-grcl)
+    (LaTeX-fill-paragraph)
+    (LaTeX-newline)
+    (indent-according-to-mode)
+    ;; Insert short & regular 2. caption
+    (when (and short-captionII (not (string= short-captionII "")))
+      (insert LaTeX-optop short-captionII LaTeX-optcl))
+    (insert TeX-grop captionII TeX-grcl)
+    ;; Insert width & pos in case of captionbox macros:
+    (when cap-box
+      (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 (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)))
+    (LaTeX-fill-paragraph)
+    ;; Insert label
+    (when (and (not label-inside) (not star))
+      (LaTeX-newline)
+      (indent-according-to-mode)
+      (LaTeX-label currenv 'environment))))
+
+(defun LaTeX-arg-bicaption-captionsetup (optional)
+  "Query for 2 arguments for \"\\captionsetup\" with bicaption.sty loaded.
+When OPTIONAL is non-nil, include both as optional arguments in
+square brackets."
+  (let* ((flttype (completing-read (TeX-argument-prompt optional nil "Float 
type")
+                                 LaTeX-caption-supported-float-types))
+        (biflt (if (and (not (or (string= flttype "bi")
+                                 (string= flttype "bi-first")
+                                 (string= flttype "bi-second")))
+                        flttype (not (string= flttype "")))
+                   (completing-read (TeX-argument-prompt optional nil 
"Bicaption type")
+                                    '("bi" "bi-first" "bi-second"))
+                 "")))
+    (TeX-argument-insert flttype optional)
+    (TeX-argument-insert biflt optional)))
+
+(TeX-add-style-hook
+ "bicaption"
+ (lambda ()
+
+   ;; Load caption.el:
+   (TeX-run-style-hooks "caption")
+
+   ;; Macros
+   (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    t   t)     t)
+    '("bisubcaption"     (LaTeX-arg-bicaption-bicaption "sub-"))
+    '("bisubcaption*"    (LaTeX-arg-bicaption-bicaption "sub-"  t))
+    '("bisubcaptionbox"  (LaTeX-arg-bicaption-bicaption "sub-" nil  t   t) t)
+    '("bisubcaptionbox*" (LaTeX-arg-bicaption-bicaption "sub-"  t   t   t) t))
+
+   ;; Everything starting with \bi(sub)?caption should get its own line
+   (LaTeX-paragraph-commands-add-locally '("bicaption" "bisubcaption"))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("bicaption"       "*[{[{")
+                               ("bicaptionbox"    "*[{[{[[")
+                               ("bisubcaption"    "*[{[{")
+                               ("bisubcaptionbox" "*[{[{[["))
+                             'textual)))
+ LaTeX-dialect)
+
+(defun LaTeX-bicaption-package-options ()
+  "Prompt for package options for the bicaption package."
+  (TeX-read-key-val t
+                   (append
+                    `(,(list "language"
+                             (cond ((and (member "babel" (TeX-style-list))
+                                         (LaTeX-babel-active-languages))
+                                    (butlast (LaTeX-babel-active-languages)))
+                                   ((and (member "polyglossia" 
(TeX-style-list))
+                                         (LaTeX-polyglossia-active-languages))
+                                    (butlast (LaTeX-babel-active-languages)))
+                                   (t nil))))
+                    LaTeX-bicaption-key-val-options
+                    LaTeX-caption-key-val-options)))
+
+;;; bicaption.el ends here

commit cb6bc118ee622257d0152ca8637b60fbf1d7c6ca
Author: Arash Esbati <address@hidden>
Date:   Mon Nov 21 20:55:45 2016 +0100

    Add support for style/bicaption.el to style/caption.el
    
    * style/caption.el (LaTeX-caption-supported-float-types): Add
    supported caption types available with bicaption.el.
    ("caption"): Append key=vals from bicaption.el to
    `LaTeX-caption-key-val-options-local'.
    ("caption"): Query for a second optional argument with
    \captionsetup*? if bicaption.el is loaded.  Same for
    fontification.

diff --git a/style/caption.el b/style/caption.el
index 87d9f82..a9fdec4 100644
--- a/style/caption.el
+++ b/style/caption.el
@@ -106,6 +106,7 @@
 (defvar LaTeX-caption-supported-float-types
   '("figure" "table" "ContinuedFloat"  ; Standard caption.sty
     "sub" "subtable" "subfigure"        ; subcaption.sty
+    "bi" "bi-first" "bi-second"         ; bicaption.sty
     "ruled" "boxed"                    ; float.sty
     "floatingfigure" "floatingtable"   ; floatflt.sty
     "lstlisting"                       ; listings.sty
@@ -213,8 +214,9 @@ suffix of the command."
 ;; entry to the list of figures or tables.
 
 ;; The first mandatory argument {<heading>} contains the caption text
-;; and the label.  We use `TeX-insert-macro' to do the job. (Thanks to
-;; M. Giordano for his valuable comments on this!)
+;; and the label.  We used to use `TeX-insert-macro' to do the job
+;; (Thanks to M. Giordano for his valuable comments on this!), but now
+;; moved to `LaTeX-label'.
 
 ;; Syntax:
 ;; \captionbox[<list entry>]{<heading>}[<width>][<inner-pos>]{<contents>}
@@ -266,6 +268,21 @@ caption, insert only a caption."
    (setq LaTeX-caption-key-val-options-local
         (copy-alist LaTeX-caption-key-val-options))
 
+   ;; Append key=vals from bicaption.sty if loaded: "language" key
+   ;; depends on the active languages, it is appended extra where main
+   ;; language is removed from the list:
+   (when (and (member "bicaption" (TeX-style-list))
+             ;; Make sure that one of these packages is loaded:
+             (or (fboundp 'LaTeX-babel-active-languages)
+                 (fboundp 'LaTeX-polyglossia-active-languages)))
+     (setq LaTeX-caption-key-val-options-local
+          (append
+           `(,(list "language"
+                    (or (butlast (LaTeX-babel-active-languages))
+                        (butlast (LaTeX-polyglossia-active-languages)))))
+           LaTeX-bicaption-key-val-options
+           LaTeX-caption-key-val-options-local)))
+
    ;; Caption commands:
    (TeX-add-symbols
     '("caption*" t)
@@ -286,13 +303,19 @@ caption, insert only a caption."
       t)
 
     '("captionsetup"
-      [TeX-arg-eval completing-read (TeX-argument-prompt t nil "Float type")
-                   LaTeX-caption-supported-float-types]
+      (TeX-arg-conditional (member "bicaption" (TeX-style-list))
+                          ([LaTeX-arg-bicaption-captionsetup])
+                        ([TeX-arg-eval completing-read
+                                       (TeX-argument-prompt t nil "Float type")
+                                       LaTeX-caption-supported-float-types]))
       (LaTeX-arg-caption-command))
 
     '("captionsetup*"
-      [TeX-arg-eval completing-read (TeX-argument-prompt t nil "Float type")
-                   LaTeX-caption-supported-float-types]
+      (TeX-arg-conditional (member "bicaption" (TeX-style-list))
+                          ([LaTeX-arg-bicaption-captionsetup])
+                        ([TeX-arg-eval completing-read
+                                       (TeX-argument-prompt t nil "Float type")
+                                       LaTeX-caption-supported-float-types]))
       (LaTeX-arg-caption-command))
 
     '("clearcaptionsetup"
@@ -362,7 +385,7 @@ caption, insert only a caption."
                                ("captionof"         "*{[{")
                                ("captionbox"        "*[{[["))
                              'textual)
-     (font-latex-add-keywords '(("captionsetup"                  "*[{")
+     (font-latex-add-keywords '(("captionsetup"                  "*[[{")
                                ("clearcaptionsetup"             "*[{")
                                ("DeclareCaptionFont"            "{{")
                                ("DeclareCaptionFormat"          "*{{")

commit b59075b4b6c1db93372b1a6f74e50a564ba2d18e
Author: Arash Esbati <address@hidden>
Date:   Mon Nov 21 20:46:03 2016 +0100

    Do not insert a new line if \label is omitted
    
    * style/subcaption.el (LaTeX-arg-subcaption-subcaption): Insert a
    new line only if \label is given.

diff --git a/style/subcaption.el b/style/subcaption.el
index 7a116c2..fc5fc63 100644
--- a/style/subcaption.el
+++ b/style/subcaption.el
@@ -60,9 +60,13 @@ caption, insert only a caption."
     ;; Fill the \subcaption paragraph before inserting the \label:
     (LaTeX-fill-paragraph)
     (unless star
-      (LaTeX-newline)
-      (indent-according-to-mode)
-      (LaTeX-label currenv 'environment))))
+      (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)))))
 
 (defun LaTeX-arg-subcaption-subcaptionbox (optional &optional star)
   "Query for the arguments of \"\\subcaptionbox\" incl. a label and insert 
them.

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

Summary of changes:
 Makefile.in         |    3 +-
 style/bicaption.el  |  181 +++++++++++++++++++++++++++++++++++++++++++++++++++
 style/caption.el    |   37 +++++++++--
 style/subcaption.el |   10 ++-
 4 files changed, 220 insertions(+), 11 deletions(-)
 create mode 100644 style/bicaption.el


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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