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


From: Mosè Giordano
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. cfa82d807cb2d2f9cdcd2f7816030485505e2eb4
Date: Thu, 17 Mar 2016 09:51:54 +0000

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  cfa82d807cb2d2f9cdcd2f7816030485505e2eb4 (commit)
      from  b88dc700c29d1cc36f6a3b9d54b7d56b4182c15e (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 cfa82d807cb2d2f9cdcd2f7816030485505e2eb4
Author: Matthew Leach <address@hidden>
Date:   Tue Mar 15 23:26:29 2016 +0000

    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>

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))
        ()

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

Summary of changes:
 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(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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