[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex cfa82d8 65/69: Prompt for optional short caption
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex cfa82d8 65/69: Prompt for optional short caption parameter. |
Date: |
Sat, 26 Mar 2016 21:36:37 +0000 |
branch: externals/auctex
commit cfa82d807cb2d2f9cdcd2f7816030485505e2eb4
Author: Matthew Leach <address@hidden>
Commit: Mosè Giordano <address@hidden>
Prompt for optional short caption parameter.
* latex.el (LaTeX-compose-caption-macro): New.
(LaTeX-short-caption-prompt-length): New.
(LaTeX-env-figure): Prompt for optional short caption parameter, when
the caption length is >= `LaTeX-short-caption-prompt-length', and pass
to `LaTeX-compose-caption-macro'.
* style/longtable.el ("longtable"): Likewise.
* style/psfig.el (LaTeX-env-psfigure): Likewise.
* doc/auctex.texi (Floats): Document short-caption prompting and
`LaTeX-short-caption-prompt-length'.
* doc/changes.texi: Likewise.
Signed-off-by: Mosè Giordano <address@hidden>
---
doc/auctex.texi | 13 +++++++++++++
doc/changes.texi | 6 ++++++
latex.el | 37 ++++++++++++++++++++++++++++---------
style/longtable.el | 12 +++++++-----
style/psfig.el | 20 +++++++++++---------
5 files changed, 65 insertions(+), 23 deletions(-)
diff --git a/doc/auctex.texi b/doc/auctex.texi
index d0d0673..8c5218a 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -1005,6 +1005,14 @@ at the bottom of the float. You can specify floats
where the caption
should be placed at the top with @code{LaTeX-top-caption-list}.
@vindex LaTeX-top-caption-list
address@hidden short caption
+If the specified caption is greater than a specific length, then a short
+caption is prompted for and it is inserted as an optional argument to
+the @samp{\caption} macro. The length that a caption needs to be before
+prompting for a short version is controlled by
address@hidden
address@hidden LaTeX-short-caption-prompt-length
+
@item label
The label of this float. The label will have a default prefix, which is
controlled by the variables @code{LaTeX-figure-label} and
@@ -1037,6 +1045,11 @@ Prefix to use for table labels.
List of float environments with top caption.
@end defopt
address@hidden LaTeX-short-caption-prompt-length
+Number of chars a caption should be before prompting for a short
+caption.
address@hidden defopt
+
@node Itemize-like
@subsection Itemize-like Environments
@cindex Itemize
diff --git a/doc/changes.texi b/doc/changes.texi
index 141f765..9d39db2 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -12,6 +12,12 @@
@itemize @bullet
@item
+When inserting a new float, @AUCTeX{} will now prompt for a
+short-caption if the length of the caption provided is greater than a
+certain size. This size is controlled via a new user option
address@hidden
+
address@hidden
Parsing of the compilation log has been reworked. You should encounter
fewer mistaken files while navigating through errors and warnings.
diff --git a/latex.el b/latex.el
index 64c0f58..c0b0baf 100644
--- a/latex.el
+++ b/latex.el
@@ -1032,16 +1032,35 @@ The inserted label is returned, nil if it is empty."
label)
nil)))))
+(defcustom LaTeX-short-caption-prompt-length 40
+ "The length that the caption of a figure should be before
+ propting for \\caption's optional short-version."
+ :group 'LaTeX-environment
+ :type 'integer)
+
+(defun LaTeX-compose-caption-macro (caption &optional short-caption)
+ "Return a \\caption macro for a given CAPTION as a string.
+If SHORT-CAPTION is non-nil pass it as an optional argument to
+\\caption."
+ (let ((short-caption-string
+ (if (and short-caption
+ (not (string= short-caption "")))
+ (concat LaTeX-optop short-caption LaTeX-optcl))))
+ (concat TeX-esc "caption" short-caption-string
+ TeX-grop caption TeX-grcl)))
+
(defun LaTeX-env-figure (environment)
"Create ENVIRONMENT with \\caption and \\label commands."
- (let ((float (and LaTeX-float ; LaTeX-float can be nil, i.e.
+ (let* ((float (and LaTeX-float ; LaTeX-float can be nil, i.e.
; do not prompt
- (TeX-read-string "(Optional) Float position: "
LaTeX-float)))
- (caption (TeX-read-string "Caption: "))
- (center (y-or-n-p "Center? "))
- (active-mark (and (TeX-active-mark)
- (not (eq (mark) (point)))))
- start-marker end-marker)
+ (TeX-read-string "(Optional) Float position: "
LaTeX-float)))
+ (caption (TeX-read-string "Caption: "))
+ (short-caption (when (>= (length caption)
LaTeX-short-caption-prompt-length)
+ (TeX-read-string "(Optional) Short caption: ")))
+ (center (y-or-n-p "Center? "))
+ (active-mark (and (TeX-active-mark)
+ (not (eq (mark) (point)))))
+ start-marker end-marker)
(when active-mark
(if (< (mark) (point))
(exchange-point-and-mark))
@@ -1064,7 +1083,7 @@ The inserted label is returned, nil if it is empty."
(if (member environment LaTeX-top-caption-list)
;; top caption
(progn
- (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
+ (insert (LaTeX-compose-caption-macro caption short-caption))
;; If `auto-fill-mode' is active, fill the caption.
(if auto-fill-function (LaTeX-fill-paragraph))
(LaTeX-newline)
@@ -1082,7 +1101,7 @@ The inserted label is returned, nil if it is empty."
;; If there is an active region point is before the backslash of
;; "\end" macro, go one line upwards.
(when active-mark (forward-line -1) (indent-according-to-mode))
- (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
+ (insert (LaTeX-compose-caption-macro caption short-caption))
;; If `auto-fill-mode' is active, fill the caption.
(if auto-fill-function (LaTeX-fill-paragraph))
;; ask for a label and if necessary insert a new line between caption
diff --git a/style/longtable.el b/style/longtable.el
index 6c9aeaf..7401c8d 100644
--- a/style/longtable.el
+++ b/style/longtable.el
@@ -34,10 +34,12 @@
(lambda ()
(LaTeX-add-environments
'("longtable" (lambda (environment)
- (let ((pos (completing-read (TeX-argument-prompt t nil
"Position")
- '(("l") ("r") ("c"))))
- (fmt (TeX-read-string "Format: "
LaTeX-default-format))
- (caption (TeX-read-string "Caption: ")))
+ (let* ((pos (completing-read (TeX-argument-prompt t nil
"Position")
+ '(("l") ("r") ("c"))))
+ (fmt (TeX-read-string "Format: "
LaTeX-default-format))
+ (caption (TeX-read-string "Caption: "))
+ (short-caption (when (>= (length caption)
LaTeX-short-caption-prompt-length)
+ (TeX-read-string "(Optional) Short
caption: "))))
(setq LaTeX-default-format fmt)
(LaTeX-insert-environment environment
(concat
@@ -49,7 +51,7 @@
;; the longtable `\caption' is equivalent to a
;; `\multicolumn', so it needs a `\\' at the
;; end of the line
- (insert TeX-esc "caption" TeX-grop caption TeX-grcl "
\\\\")
+ (insert (LaTeX-compose-caption-macro caption
short-caption) "\\\\")
(LaTeX-newline)
(indent-according-to-mode)
;; ask for a label and insert a new line only
diff --git a/style/psfig.el b/style/psfig.el
index f829ef8..e471379 100644
--- a/style/psfig.el
+++ b/style/psfig.el
@@ -45,14 +45,16 @@
(defun LaTeX-env-psfigure (_environment)
"Create with \\label and \\caption and \\psfig commands."
- (let ((float (TeX-read-string "Float to: " LaTeX-float))
- (caption (TeX-read-string "Caption: "))
- (label (TeX-read-string "Label: " LaTeX-figure-label))
- ; gf: ask if this should be centered
- (psfile (read-file-name "PS-file: " "" "" nil))
- (figwidth (TeX-read-string "Figure width: "))
- (figheight (TeX-read-string "Figure height: "))
- )
+ (let* ((float (TeX-read-string "Float to: " LaTeX-float))
+ (caption (TeX-read-string "Caption: "))
+ (short-caption (when (>= (length caption)
LaTeX-short-caption-prompt-length)
+ (TeX-read-string "(Optional) Short caption: ")))
+ (label (TeX-read-string "Label: " LaTeX-figure-label))
+ ; gf: ask if this should be centered
+ (psfile (read-file-name "PS-file: " "" "" nil))
+ (figwidth (TeX-read-string "Figure width: "))
+ (figheight (TeX-read-string "Figure height: "))
+ )
(setq LaTeX-float (if (zerop (length float))
LaTeX-float
@@ -71,7 +73,7 @@
(if (zerop (length caption))
()
(newline-and-indent)
- (insert TeX-esc "caption" TeX-grop caption TeX-grcl))
+ (insert (LaTeX-compose-caption-macro caption short-caption)))
(if (or (zerop (length label))
(equal LaTeX-figure-label label))
()
- [elpa] externals/auctex 2888571 52/69: Allow ignoring certain warnings, (continued)
- [elpa] externals/auctex 2888571 52/69: Allow ignoring certain warnings, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex a33be07 62/69: Remove "table" and "table*" from LaTeX-indent-environment-list, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex e4cad1c 46/69: Add support for Atril viewer, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex 464bef6 39/69: Fix TeX-parse-error, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex 00d9438 45/69: Add support for dviout viewer, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex d4b0d5f 67/69: Fix forward sync bug with multi-file documents, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex b88dc70 64/69: Improve prompts when defining LaTeX macros., Tassilo Horn, 2016/03/26
- [elpa] externals/auctex 70e62a9 57/69: Catch more bad box warnings, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex 16f3dd4 43/69: Add support for Zathura viewer, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex bfd5f18 09/69: Merge master branch., Tassilo Horn, 2016/03/26
- [elpa] externals/auctex cfa82d8 65/69: Prompt for optional short caption parameter.,
Tassilo Horn <=
- [elpa] externals/auctex 550e058 49/69: Add new style/splitidx.el, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex f1abcf8 69/69: Upgrade docs for release, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex 8683935 27/69: Merge branch 'master' into simplify-TeX-parse-error, Tassilo Horn, 2016/03/26
- [elpa] externals/auctex 4357488 68/69: Merge branch 'master' into elpa, Tassilo Horn, 2016/03/26