auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] [elpa] externals/auctex 8990190 16/34: Improve style/algo


From: Tassilo Horn
Subject: [AUCTeX-diffs] [elpa] externals/auctex 8990190 16/34: Improve style/algorithm.el
Date: Sun, 6 Jun 2021 11:40:03 -0400 (EDT)

branch: externals/auctex
commit 89901901576b1534b5c9d6979ff1648f908bb6b6
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    Improve style/algorithm.el
    
    * style/algorithm.el (LaTeX-algorithm-package-options): Add
    missing options.
    (LaTeX-env-algorithm): Insert a newline only when a label is
    really added.  Remove unnecessary comments.
    ("algorithm"): Move `TeX-dialect' to be the third argument of the
    hook.
---
 style/algorithm.el | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/style/algorithm.el b/style/algorithm.el
index c493c82..e18e19d 100644
--- a/style/algorithm.el
+++ b/style/algorithm.el
@@ -32,10 +32,12 @@
 (require 'latex)
 
 (defvar LaTeX-algorithm-package-options
-  '("section")
+  '(;; Appearance options:
+    "plain" "ruled" "boxed"
+    ;; Numbering convention:
+    "part" "chapter" "section" "subsection" "subsubsection" "nothing")
   "Package options for the algorithm package.")
 
-
 (defun LaTeX-env-algorithm (environment)
   "Insert a algorithm-like ENVIRONMENT with caption and label."
   (let* ((pos (completing-read (TeX-argument-prompt t nil "Position")
@@ -54,30 +56,25 @@
       (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 "")
+      ;; Add } to close `\caption{'
+      (insert TeX-grcl)
       ;; fill the caption
       (LaTeX-fill-paragraph)
       ;; Insert a new line and indent
       (LaTeX-newline)
-      (LaTeX-label environment 'environment)
-      (LaTeX-newline)
-      (indent-according-to-mode))))
-
+      (indent-according-to-mode)
+      ;; Finally add a \label:
+      (when (LaTeX-label environment 'environment)
+        (LaTeX-newline)
+        (indent-according-to-mode)))))
 
 (TeX-add-style-hook
  "algorithm"
  (lambda ()
    (LaTeX-add-environments
-    '("algorithm"  LaTeX-env-algorithm ))
+    '("algorithm" LaTeX-env-algorithm))
    (TeX-add-symbols
-    '("listofalgorithms" 0))
-      TeX-dialect))
-
+    '("listofalgorithms" 0)))
+ TeX-dialect)
 
 ;;; algorithm.el ends here




reply via email to

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