Index: amsthm.el =================================================================== RCS file: /sources/auctex/auctex/style/amsthm.el,v retrieving revision 1.3 diff -u -u -r1.3 amsthm.el --- amsthm.el 3 Feb 2008 14:53:30 -0000 1.3 +++ amsthm.el 6 Mar 2013 10:41:39 -0000 @@ -1,6 +1,6 @@ ;;; amsthm.el --- Style hook for the AMS-LaTeX amsthm package. -;; Copyright (C) 1997 Free Software Foundation, Inc. +;; Copyright (C) 1997, 2013 Free Software Foundation, Inc. ;; Author: Carsten Dominik ;; Maintainer: address@hidden @@ -27,27 +27,53 @@ (TeX-add-style-hook "amsthm" (function (lambda () + (TeX-auto-add-type "amsthmstyle" "LaTeX") + (LaTeX-add-amsthmstyles "plain" "definition" "remark") + + (defvar LaTeX-auto-savebox-regexp-list + '(("\\\\newtheoremstyle{\\\\([A-Za-z]+\\)}?" 1 LaTeX-auto-amsthmstyle)) + "List of regular expressions matching AMS-LaTeX theoremstyles only.") + + (setq TeX-complete-list + (append '(("\\\\newtheoremstyle{\\([A-Za-z]*\\)" 1 + LaTeX-amsthmstyle-list "}")) + TeX-complete-list)) + (LaTeX-add-environments '("proof" (lambda (env &rest ignore) - (LaTeX-insert-environment + (LaTeX-insert-environment env (let ((heading (read-string "(optional) Heading: "))) (if (string= heading "") "" - (format "[%s]" heading)))))) - ) + (format "[%s]" heading))))))) + (TeX-add-symbols '("newtheorem" "Environment name" ["Share numbering with"] "Heading" ["Number subordinated in each"]) '("newtheorem*" "Environment name" "Heading") - '("theoremstyle" LaTeX-amsthm-complete-theoremstyle) - )))) - -(defun LaTeX-amsthm-complete-theoremstyle (&rest ignore) - (insert TeX-grop - (completing-read "Style: " '(("plain" . nil) - ("definition" . nil) - ("remark" . nil))) - TeX-grcl)) + '("theoremstyle" TeX-arg-theoremstyle) + '("newtheoremstyle" TeX-arg-define-theoremstyle) + '("swapnumbers" 0))))) + +(defun TeX-arg-theoremstyle (optional &optional prompt definition) + "Prompt for an AMS-LaTeX theoremstyle with completion. +If OPTIONAL is non-nil, insert the resulting value as an optional +argument, otherwise as a mandatory one. Use PROMPT as the prompt +string. If DEFINITION is non-nil, add the chosen theoremstyle to +the list of defined theoremstyles." + (let ((amsthmstyle (completing-read (TeX-argument-prompt optional prompt + "Theorem style") + (LaTeX-amsthmstyle-list)))) + (if (and definition (not (string-equal "" amsthmstyle))) + (LaTeX-add-amsthmstyles amsthmstyle)) + (TeX-argument-insert amsthmstyle optional))) + +(defun TeX-arg-define-theoremstyle (optional &optional prompt) + "Prompt for a label completing with known labels. +If OPTIONAL is non-nil, insert the resulting value as an optional +argument, otherwise as a mandatory one. Use PROMPT as the prompt +string." + (TeX-arg-theoremstyle optional prompt t)) ;;; amsthm.el ends here