1. xemacs
  2. auctex


auctex / etc / scrbase.el

;;; scrbase.el --- AUCTeX style for the KOMA-Script bundle.

;; Copyright (C) 2002 Mark Trettin
;; Copyright (C) 2004 Free Software Foundation, Inc.

;; Author: Mark Trettin <Mark.Trettin@gmx.de>
;; Created: 2002-09-26
;; Version: $Id$
;; Keywords: tex
;; License: GPL, see the file COPYING in the base directory of AUCTeX

;;; Commentary:

;; This file adds support for the KOMA-Script bundle.  This file
;; contains the base definitions that work with all KOMA-Script
;; classes (scrarctl.cls, scrreprt.cls, scrbook.cls and scrlttr2.cls).
;; You need this file since it's loaded from the class-styles.

;;; Code:
(TeX-add-style-hook "scrbase"
  (lambda ()
     '("addtokomafont" TeX-arg-KOMA-fontelements t)
     '("areaset" [ "BCOR" ] "Width" "Height")
     '("captionabove" [ "Lof entry" ] "Caption")
     '("captionbelow" [ "Lof entry" ] "Caption")
     '("dedication" t)
     '("deffootnote" [ "Mark width" ] "Indent" "Parindent" "Definition")
     '("deffootnotemark" "Definition")
     '("extratitle" t)
     '("ifpdfoutput" t nil)
     '("ifthispageodd" t nil)
     '("lowertitleback" t)
     '("maketitle" [ "Pagenumber" ])
     '("marginline" t)
     '("publishers" "Publishers")
     '("sectionmark" "Running head")
     '("setbibpreamble" "Preamble")
     '("setcapindent" "Indent")
     '("setcapindent*" "X-Indent")
     '("setcapmargin" [ "Margin left" ] "Margin")
     '("setcapmargin*" [ "Margin inside" ] "Margin")
     '("setcapwidth" [ TeX-arg-KOMA-capjust ] "Width")
     '("setindexpreamble" "Preamble")
     '("setkomafont" TeX-arg-KOMA-fontelements t)
     '("subject" "Subject")
     '("subsectionmark" "Running head")
     '("textsubscript" "Text")
     '("thanks" "Footnote")
     '("titlehead" t)
     '("uppertitleback" t)
     '("usekomafont" TeX-arg-KOMA-fontelements))
     '("labeling" (lambda (env &rest ignore)
		     (let ((delim (read-string "(Optional) Delimiter: "))
			   (width (read-string "Longest item: ")))
			(if (not (zerop (length delim)))
			    (format "[%s]" delim))
			(format "{%s}" width))))
		    (end-of-line 1)
     '("addmargin" (lambda (env &rest ignore)
		      (let ((leftin (read-string "(Optional) Left Indentation: "))
			    (indent (read-string "Indentation: ")))
			 (if (not (zerop (length leftin)))
			     (format "[%s]" leftin))
			 (format "{%s}" indent))))))
     '("addmargin*" (lambda (env &rest ignore)
		       (let ((innin (read-string "(Optional) Innner Indentation: "))
			     (indent (read-string "Indentation: ")))
			  (if (not (zerop (length innin)))
			      (format "[%s]" innin))
			  (format "{%s}" indent))))))
     '("captionbeside" (lambda (env &rest ignore)
			  (let ((lofent (read-string "(Optional) Lof Entry: "))
				(title (read-string "Caption: "))
				(place (read-string "(Optional) Placement (l,r,o,i): "))
				(width (read-string "(Optional) Width: "))
				(offset (read-string "(Optional) Offset: ")))
			     (if (not (zerop (length lofent)))
				 (format "[%s]" lofent))
			     (format "{%s}" title)
			     (if (not (zerop (length place)))
				 (format "[%s]" place))
			     (if (not (zerop (length width)))
				 (format "[%s]" width))
			      (not (zerop (length place)))
			      (not (zerop (length offset)))
			      (format "[%s]%s" offset
				      (if (y-or-n-p "Starred? ")
					  "*" "")))))))))
    (make-local-variable 'LaTeX-section-list)
    (setq LaTeX-section-list (append
			      '(("addpart" 0)
				("addsec" 2)
				("minisec" 7))))
    ;; This doesn't work. Maybe it's refTeX's label insertion?
    (make-local-variable 'LaTeX-section-label)
    (setq LaTeX-section-label (append
			       '(("addpart" . nil)
				 ("addsec" . nil)
				 ("minisec" . nil))))
    ;; Definitions for font-latex
    (when (and (featurep 'font-latex)
	       (eq TeX-install-font-lock 'font-latex-setup))
      ;; Textual keywords
      (setq font-latex-match-textual-keywords-local
	    (append font-latex-match-textual-keywords-local
      ;; Function keywords
      (setq font-latex-match-function-keywords-local
	    (append font-latex-match-function-keywords-local
      ;; Variable keywords
      (setq font-latex-match-variable-keywords-local
	    (append font-latex-match-variable-keywords-local
      ;; Warning keywords
      (setq font-latex-match-warning-keywords-local
	    (append font-latex-match-warning-keywords-local
      ;; Title keywords
      (add-to-list 'font-latex-match-title-1-keywords-local "addpart")
      (add-to-list 'font-latex-match-title-2-keywords-local "addsec")
      (add-to-list 'font-latex-match-title-4-keywords-local "minisec")

(defun TeX-arg-KOMA-setpreamble (optional &optional prompt)
  "Prompt for KOMA-Script's \\set*preamble position with completion."
    (TeX-argument-prompt optional prompt "Position")
    '(("") ("l") ("r") ("c") ("o") ("u")
      ("lo") ("lu") ("ro") ("ru") ("co") ("cu"))
    nil t)

(defun TeX-arg-KOMA-capjust (optional &optional prompt)
  "Prompt for KOMA-Script's \\setcapwidth justification with completion."
    (TeX-argument-prompt optional prompt "Justification")
    '(("") ("l") ("r") ("c") ("i") ("o"))
    nil t)

(defun TeX-arg-KOMA-fontelements (optional &optional prompt)
  "Prompt for KOMA-Script's fontelements with completion."
    (TeX-argument-prompt optional prompt "Element")
      ("caption") ("captionlabel")
      ("descriptionlabel") ("dictumauthor") ("dictumtext")
      ("footnote") ("footnotelabel") ("footnotereference")
      ("pagefoot") ("pagehead") ("pagenumber")
      ("sectioning") ("part") ("partnumber") ("chapter") ("section")
      ("subsection") ("subsubsection") ("paragraph") ("subparagraph")
    nil t)
(add-to-list 'LaTeX-item-list '("labeling" . LaTeX-item-argument))

;;; scrbase.el ends here