"Fossies" - the Fresh Open Source Software Archive

Member "auctex-12.3/style/algorithm.el" (18 Oct 2020, 2691 Bytes) of package /linux/misc/auctex-12.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lisp source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ;;; algorithm.el --- AUCTeX style for the (LaTeX) algorithm package
    2 
    3 ;; Copyright (C) 2020 Free Software Foundation, Inc.
    4 
    5 ;; Author: Uwe Brauer <oub@mat.ucm.es>
    6 ;; Created: 2020-01-26
    7 ;; Keywords: tex
    8 
    9 ;; This file is part of AUCTeX.
   10 
   11 ;; AUCTeX is free software; you can redistribute it and/or modify it
   12 ;; under the terms of the GNU General Public License as published by
   13 ;; the Free Software Foundation; either version 3, or (at your option)
   14 ;; any later version.
   15 
   16 ;; AUCTeX is distributed in the hope that it will be useful, but
   17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
   18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   19 ;; General Public License for more details.
   20 
   21 ;; You should have received a copy of the GNU General Public License
   22 ;; along with AUCTeX; see the file COPYING.  If not, write to the Free
   23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   24 ;; 02110-1301, USA.
   25 
   26 ;;; Commentary:
   27 ;; This file adds support for the algorithm package.
   28 
   29 ;;; Code:
   30 
   31 (defvar LaTeX-algorithm-package-options
   32   '("section")
   33   "Package options for the algorithm package.")
   34 
   35 
   36 (defun LaTeX-env-algorithm (environment)
   37   "Insert a algorithm-like ENVIRONMENT with caption and label."
   38   (let* ((pos (completing-read (TeX-argument-prompt t nil "Position")
   39                    '(("H"))))
   40      (caption (TeX-read-string "Caption: "))
   41      (short-caption (when (>= (length caption) LaTeX-short-caption-prompt-length)
   42               (TeX-read-string "(Optional) Short caption: "))))
   43     (LaTeX-insert-environment environment
   44                   (concat
   45                    (unless (zerop (length pos))
   46                  (concat LaTeX-optop pos LaTeX-optcl))))
   47     ;; top caption -- do nothing if user skips caption
   48     (unless (zerop (length caption))
   49       ;; insert `\caption[short-caption]{caption':
   50       (insert TeX-esc "caption")
   51       (when (and short-caption (not (string= short-caption "")))
   52     (insert LaTeX-optop short-caption LaTeX-optcl))
   53       (insert TeX-grop caption)
   54       ;; ask for a label and insert it
   55 ;      (LaTeX-label environment 'environment)
   56       ;; the longtable `\caption' is equivalent to a
   57       ;; `\multicolumn', so it needs a `\\' at the
   58       ;; end of the line.  Prior to that, add } to
   59       ;; close `\caption{'
   60       (insert TeX-grcl "")
   61       ;; fill the caption
   62       (LaTeX-fill-paragraph)
   63       ;; Insert a new line and indent
   64       (LaTeX-newline)
   65       (LaTeX-label environment 'environment)
   66       (LaTeX-newline)
   67       (indent-according-to-mode))))
   68 
   69 
   70 (TeX-add-style-hook
   71  "algorithm"
   72  (lambda ()
   73    (LaTeX-add-environments
   74     '("algorithm"  LaTeX-env-algorithm ))
   75    (TeX-add-symbols
   76     '("listofalgorithms" 0))
   77       LaTeX-dialect))
   78 
   79 
   80 ;;; algorithm.el ends here