emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex f0145f4 30/42: Add new function `LaTeX-env-longt


From: Tassilo Horn
Subject: [elpa] externals/auctex f0145f4 30/42: Add new function `LaTeX-env-longtable'
Date: Thu, 23 Nov 2017 06:06:13 -0500 (EST)

branch: externals/auctex
commit f0145f462bb2253627138d98d39da49842bd2178
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>

    Add new function `LaTeX-env-longtable'
    
    * style/longtable.el (LaTeX-env-longtable): Add new function.
    Move the body of the anonymous function into this in order to make
    it available for other styles loading longtable.
---
 style/longtable.el | 73 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 38 insertions(+), 35 deletions(-)

diff --git a/style/longtable.el b/style/longtable.el
index aeb275e..b57833b 100644
--- a/style/longtable.el
+++ b/style/longtable.el
@@ -1,6 +1,6 @@
 ;;; longtable.el --- AUCTeX style for `longtable.sty'.
 
-;; Copyright (C) 2013--2016  Free Software Foundation, Inc.
+;; Copyright (C) 2013--2017  Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Author: Mosè Giordano <address@hidden>
@@ -46,44 +46,47 @@ insert line break macro."
   (LaTeX-insert-ampersands
    LaTeX-longtable-skipping-regexp #'LaTeX-array-count-columns))
 
+(defun LaTeX-env-longtable (environment)
+  "Insert a longtable-like ENVIRONMENT with caption and label."
+  (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
+                              (unless (zerop (length pos))
+                                (concat LaTeX-optop pos LaTeX-optcl))
+                              (concat TeX-grop fmt TeX-grcl)))
+    ;; top caption -- do nothing if user skips caption
+    (unless (zerop (length caption))
+      ;; insert `\caption[short-caption]{caption':
+      (insert TeX-esc "caption")
+      (when (and short-caption (not (string= short-caption "")))
+       (insert LaTeX-optop short-caption LaTeX-optcl))
+      (insert TeX-grop caption)
+      ;; ask for a label and insert it
+      (LaTeX-label environment 'environment)
+      ;; the longtable `\caption' is equivalent to a
+      ;; `\multicolumn', so it needs a `\\' at the
+      ;; end of the line.  Prior to that, add } to
+      ;; close `\caption{'
+      (insert TeX-grcl "\\\\")
+      ;; fill the caption
+      (LaTeX-fill-paragraph)
+      ;; Insert a new line and indent
+      (LaTeX-newline)
+      (indent-according-to-mode))
+    ;; Insert suitable number of &'s, suppress line break
+    (LaTeX-item-longtable t)))
+
 (TeX-add-style-hook
  "longtable"
  (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: "))
-                          (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
-                                                (unless (zerop (length pos))
-                                                  (concat LaTeX-optop pos 
LaTeX-optcl))
-                                                (concat TeX-grop fmt 
TeX-grcl)))
-                     ;; top caption -- do nothing if user skips caption
-                     (unless (zerop (length caption))
-                       ;; insert `\caption[short-caption]{caption':
-                       (insert TeX-esc "caption")
-                       (when (and short-caption (not (string= short-caption 
"")))
-                         (insert LaTeX-optop short-caption LaTeX-optcl))
-                       (insert TeX-grop caption)
-                       ;; ask for a label and insert it
-                       (LaTeX-label environment 'environment)
-                       ;; the longtable `\caption' is equivalent to a
-                       ;; `\multicolumn', so it needs a `\\' at the
-                       ;; end of the line.  Prior to that, add } to
-                       ;; close `\caption{'
-                       (insert TeX-grcl "\\\\")
-                       ;; fill the caption
-                       (LaTeX-fill-paragraph)
-                       ;; Insert a new line and indent
-                       (LaTeX-newline)
-                       (indent-according-to-mode))
-                     ;; Insert suitable number of &'s, suppress line break
-                     (LaTeX-item-longtable t)))))
+    '("longtable" LaTeX-env-longtable))
 
    (TeX-add-symbols
     ;; Commands to end table rows



reply via email to

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