auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] [elpa] externals/auctex a833aff 26/36: Use `LaTeX-item-lo


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex a833aff 26/36: Use `LaTeX-item-longtable' while inserting longtable's
Date: Thu, 22 Dec 2016 13:08:12 +0000 (UTC)

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

    Use `LaTeX-item-longtable' while inserting longtable's
    
    * style/longtable.el (LaTeX-longtable-skipping-regexp): New variable.
    (LaTeX-item-longtable): New function.  This function is a
    variation of `LaTeX-item-array' which uses
    `LaTeX-longtable-skipping-regexp' when inserting ampersands.
    ("longtable"): Append longtable to `LaTeX-item-list'.
---
 style/longtable.el |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/style/longtable.el b/style/longtable.el
index 76c397b..aeb275e 100644
--- a/style/longtable.el
+++ b/style/longtable.el
@@ -29,6 +29,23 @@
 
 ;;; Code:
 
+(defvar LaTeX-longtable-skipping-regexp
+  (regexp-opt '("[l]" "[r]" "[c]" ""))
+  "Regexp matching between \begin{longtable} and column specification.
+For longtable environments only.")
+
+(defun LaTeX-item-longtable (&optional suppress)
+  "Insert line break macro on the last line and suitable number of &'s.
+For longtable environments.  If SUPPRESS is non-nil, do not
+insert line break macro."
+  (unless suppress
+    (save-excursion
+      (end-of-line 0)
+      (just-one-space)
+      (TeX-insert-macro "\")))
+  (LaTeX-insert-ampersands
+   LaTeX-longtable-skipping-regexp #'LaTeX-array-count-columns))
+
 (TeX-add-style-hook
  "longtable"
  (lambda ()
@@ -64,7 +81,9 @@
                        (LaTeX-fill-paragraph)
                        ;; Insert a new line and indent
                        (LaTeX-newline)
-                       (indent-according-to-mode))))))
+                       (indent-according-to-mode))
+                     ;; Insert suitable number of &'s, suppress line break
+                     (LaTeX-item-longtable t)))))
 
    (TeX-add-symbols
     ;; Commands to end table rows
@@ -91,6 +110,9 @@
    ;; custome values.
    (add-to-list 'LaTeX-label-alist '("longtable" . LaTeX-table-label) t)
 
+   ;; Append longtable to `LaTeX-item-list' with `LaTeX-item-longtable'
+   (add-to-list 'LaTeX-item-list '("longtable" . LaTeX-item-longtable) t)
+
    ;; Fontification
    (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))



reply via email to

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