[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 94db238 05/36: Improve caption and label inserti
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 94db238 05/36: Improve caption and label insertion in style/caption.el |
Date: |
Thu, 22 Dec 2016 13:08:11 +0000 (UTC) |
branch: externals/auctex
commit 94db238bb188d225264100a49ccbbcd43ade2140
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
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.
---
style/caption.el | 67 +++++++++++++++++++++++++++++++-----------------------
1 file changed, 38 insertions(+), 29 deletions(-)
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" "*[{")
- [elpa] externals/auctex updated (1b5875c -> 2e7ca50), Tassilo Horn, 2016/12/22
- [elpa] externals/auctex b59075b 06/36: Do not insert a new line if \label is omitted, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex cb6bc11 07/36: Add support for style/bicaption.el to style/caption.el, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex c5d1d02 13/36: Append entry to `LaTeX-label-alist' for new "verbatim" floats, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex c265fc9 02/36: Add new style/FiraMono.el, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex 2f75f51 17/36: Add support for LaTeX core command \textsubscript, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex 6ec185e 16/36: Do not spell-check arguments of \LTXtable, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex 94db238 05/36: Improve caption and label insertion in style/caption.el,
Tassilo Horn <=
- [elpa] externals/auctex eb748ea 18/36: Fix query for defined colors in style/ntheorem.el, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex 8a14439 11/36: Add style file for subfiles package., Tassilo Horn, 2016/12/22
- [elpa] externals/auctex d6890e8 04/36: Improve caption and label insertion in style/subcaption.el, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex 42dd1f1 22/36: Support RefTeX with `reftex-add-index-macros' in style/splitidx.el, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex 945035c 24/36: Append tabular[xy] to `LaTeX-item-list', Tassilo Horn, 2016/12/22
- [elpa] externals/auctex e4aba95 21/36: Support RefTeX with `reftex-add-label-environments' in style/mathtools.el, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex f04e5f7 09/36: Add style file for amsfonts package, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex c4cb166 33/36: Add style/ directory to TeX-style-path for tests, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex 25e4f33 03/36: Add new style/FiraSans.el, Tassilo Horn, 2016/12/22
- [elpa] externals/auctex c073d3e 12/36: Insert \label inside the mandatory argument of \caption, Tassilo Horn, 2016/12/22