[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 52275f9 03/26: Improve style.
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 52275f9 03/26: Improve style. |
Date: |
Fri, 13 Nov 2015 17:00:31 +0000 |
branch: externals/auctex
commit 52275f915c0f8508ad244bfcd1eb6024b96f7ba6
Author: Arash Esbati <address@hidden>
Commit: Tassilo Horn <address@hidden>
Improve style.
* style/amsthm.el (LaTeX-amsthm-theoremstyle-list): New variable
replacing the deleted function
`LaTeX-amsthm-complete-theoremstyle'.
(LaTeX-amsthm-env-label): New function to insert user defined
environments.
("amsthm"): Improve handling of "newtheorem*" and
"newtheoremstyle".
---
ChangeLog | 8 +++
style/amsthm.el | 144 +++++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 126 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index df6b60e..4178918 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2015-10-24 Arash Esbati <address@hidden>
+ * style/amsthm.el (LaTeX-amsthm-theoremstyle-list): New variable
+ replacing the deleted function
+ `LaTeX-amsthm-complete-theoremstyle'.
+ (LaTeX-amsthm-env-label): New function to insert user defined
+ environments.
+ ("amsthm"): Improve handling of "newtheorem*" and
+ "newtheoremstyle".
+
* style/AlegreyaSans.el ("AlegreyaSans"): Remove SmallCaps
font declaration command.
diff --git a/style/amsthm.el b/style/amsthm.el
index 57f2315..8bc33d4 100644
--- a/style/amsthm.el
+++ b/style/amsthm.el
@@ -1,6 +1,6 @@
;;; amsthm.el --- Style hook for the AMS-LaTeX amsthm package.
-;; Copyright (C) 1997, 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2013--2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <address@hidden>
;; Maintainer: address@hidden
@@ -22,51 +22,143 @@
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301, USA.
+;;; Commentary:
+
+;; The style provides the function `LaTeX-amsthm-env-label' which
+;; enables new defined environments with "\newtheoreom" to interact
+;; with AUCTeX and RefTeX mechanisms for inserting labels. Check
+;; docstring of `LaTeX-amsthm-env-label' for instructions.
+
;;; Code:
(defvar LaTeX-amsthm-package-options nil
"Package options for the amsthm package.")
+(defvar LaTeX-amsthm-theoremstyle-list
+ '(("plain") ("definition") ("remark"))
+ "List of theorem styles provided by `amsthm.el' and new ones
+defined with \"\\newtheoremstyle\".")
+
+(defvar LaTeX-amsthm-fontdecl
+ (mapcar (lambda (elt) (concat TeX-esc elt))
+ '("itshape" "bfseries" "scshape"
+ "ttfamily" "upshape" "mdseries"
+ "rmfamily" "sffamily" "slshape"))
+ "List of font declaration commands for \"\\newtheoremstyle\".")
+
+(defun LaTeX-amsthm-env-label (environment)
+ "Insert ENVIRONMENT, query for an optional argument and prompt
+for label. AUCTeX users should add ENVIRONMENT to
+`LaTeX-label-alist' via customize or in init-file with:
+
+ (add-to-list 'LaTeX-label-alist '(\"lemma\" . \"lem:\"))
+
+RefTeX users should customize or add ENVIRONMENT to
+`LaTeX-label-alist' and `reftex-label-alist', e.g.
+
+ (add-to-list 'LaTeX-label-alist '(\"lemma\" . \"lem:\"))
+ (add-to-list 'reftex-label-alist
+ '(\"lemma\" ?m \"lem:\" \"~\\ref{%s}\"
+ nil (\"Lemma\" \"lemma\") nil))"
+ (let ((opthead (TeX-read-string
+ (TeX-argument-prompt t nil "Heading"))))
+ (LaTeX-insert-environment environment
+ (when (and opthead
+ (not (string= opthead "")))
+ (format "[%s]" opthead))))
+ (when (LaTeX-label environment 'environment)
+ (LaTeX-newline)
+ (indent-according-to-mode)))
+
+;; Needed for auto-parsing
+(require 'tex)
+
+;; Setup parsing for \newtheorem
+(TeX-auto-add-type "amsthm-newtheorem" "LaTeX")
+
+;; Setup parsing for \newtheoremstyle
+(TeX-auto-add-type "amsthm-newtheoremstyle" "LaTeX")
+
+(defun LaTeX-amsthm-auto-prepare ()
+ "Clear `LaTeX-auto-amsthm-newtheorem' and
+`LaTeX-auto-amsthm-newtheoremstyle' before parsing."
+ (setq LaTeX-auto-amsthm-newtheorem nil)
+ (setq LaTeX-auto-amsthm-newtheoremstyle nil))
+
+(defun LaTeX-amsthm-auto-cleanup ()
+ "Move parsed results from `LaTeX-auto-amsthm-newtheorem' and
+make them available as new environments. Update
+`LaTeX-amsthm-theoremstyle-list' with styles defined with
+\"\\newtheoremstyle\"."
+ (dolist (newthm (mapcar 'car (LaTeX-amsthm-newtheorem-list)))
+ (LaTeX-add-environments (list newthm 'LaTeX-amsthm-env-label)))
+ (dolist (newthmstyle (LaTeX-amsthm-newtheoremstyle-list))
+ (add-to-list (make-local-variable 'LaTeX-amsthm-theoremstyle-list)
+ newthmstyle)))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-amsthm-auto-prepare t)
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-amsthm-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
(TeX-add-style-hook
"amsthm"
(lambda ()
(LaTeX-add-environments
- '("proof" (lambda (env &rest ignore)
- (LaTeX-insert-environment
- env
- (let ((heading (TeX-read-string "(optional) Heading: ")))
- (if (string= heading "")
- ""
- (format "[%s]" heading))))))
- )
+ '("proof" LaTeX-amsthm-env-label))
(TeX-add-symbols
- '("newtheorem*" TeX-arg-define-environment "Heading")
- '("theoremstyle" LaTeX-amsthm-complete-theoremstyle)
+ '("newtheorem*"
+ (TeX-arg-eval
+ (lambda ()
+ (let ((nthm (TeX-read-string
+ (TeX-argument-prompt nil nil "Environment")))
+ (heading (TeX-read-string
+ (TeX-argument-prompt nil nil "Heading"))))
+ (LaTeX-add-amsthm-newtheorems nthm)
+ (LaTeX-add-environments (list nthm 'LaTeX-amsthm-env-label))
+ (insert (concat TeX-grop nthm TeX-grcl))
+ (format "%s" heading)))))
+
+ '("theoremstyle"
+ (TeX-arg-eval completing-read
+ "Style: "
+ LaTeX-amsthm-theoremstyle-list))
"qedhere"
"swapnumbers"
- '("newtheoremstyle" "Style name" (TeX-arg-length nil "Space above")
- (TeX-arg-length nil "Space below") "Body font" "Indent amount"
- "Theorem head font" "Punctuation after head"
- (TeX-arg-length nil "Space after head") "Theorem head spec"))
+
+ '("newtheoremstyle"
+ (TeX-arg-eval
+ (lambda ()
+ (let ((nthmstyle (TeX-read-string
+ (TeX-argument-prompt nil nil "Style name"))))
+ (LaTeX-add-amsthm-newtheoremstyles nthmstyle)
+ (add-to-list (make-local-variable 'LaTeX-amsthm-theoremstyle-list)
+ (list nthmstyle))
+ (format "%s" nthmstyle))))
+ (TeX-arg-length "Space above")
+ (TeX-arg-length "Space below")
+ (TeX-arg-eval completing-read
+ "Body font: " LaTeX-amsthm-fontdecl)
+ "Indent amount"
+ (TeX-arg-eval completing-read
+ "Theorem head font: " LaTeX-amsthm-fontdecl)
+ "Punctuation after head"
+ (TeX-arg-length "Space after head")
+ "Theorem head spec"))
(TeX-auto-add-regexp
- `(,(concat "\\\\newtheorem\\*{\\(" TeX-token-char "+\\)}")
- 1 LaTeX-auto-environment))
+ `(,(concat "\\\\newtheorem\\*?{\\(" TeX-token-char "+\\)}")
+ 1 LaTeX-auto-amsthm-newtheorem))
+ (TeX-auto-add-regexp
+ `(,(concat "\\\\newtheoremstyle{\\(" TeX-token-char "+\\)}")
+ 1 LaTeX-auto-amsthm-newtheoremstyle))
;; Fontification
(when (and (featurep 'font-latex)
(eq TeX-install-font-lock 'font-latex-setup))
- (font-latex-add-keywords '(("newtheorem" "*{[{[")
- ("theoremstyle" "{")
+ (font-latex-add-keywords '(("newtheorem" "*{[{[")
+ ("theoremstyle" "{")
("newtheoremstyle" "{{{{{{{{{"))
'function)))
LaTeX-dialect)
-(defun LaTeX-amsthm-complete-theoremstyle (&rest ignore)
- (insert TeX-grop
- (completing-read "Style: " '(("plain" . nil)
- ("definition" . nil)
- ("remark" . nil)))
- TeX-grcl))
-
;;; amsthm.el ends here
- [elpa] externals/auctex updated (35a4cfc -> 7363de1), Tassilo Horn, 2015/11/13
- [elpa] externals/auctex b10ca71 01/26: Fix docstring., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 90ea1a0 02/26: Remove SmallCaps font declaration command., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex dbeb71f 04/26: Improve style., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex b4f95f9 07/26: Disable special filling of math constructs, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 6351078 09/26: Use LaTeX-style-list for default classes completion., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 9dba8fd 15/26: Make View command work no matter how emacs started, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex c39c63f 13/26: Add new style hologo.el., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex d56502e 05/26: Support node name completion in texinfo, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex a2f8bc6 08/26: Fix Texinfo-make-node-list, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 52275f9 03/26: Improve style.,
Tassilo Horn <=
- [elpa] externals/auctex b3153ec 16/26: Add function for reverting document buffer, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 4527e8a 10/26: Update documentation., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex f52479b 11/26: Improve checking of a TeX distribution and make it optional, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex fb09c26 06/26: Warn about duplicate texinfo nodes, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex a4c6a19 21/26: Update release-related Makefile rules, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex cb4e33e 12/26: Set output extension for Texinfo files, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex d465076 22/26: Update for upcoming release, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 5179308 18/26: Change default value of LaTeX-fill-break-at-separators, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex cc72777 19/26: More ERT tests, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex df7dbbd 23/26: Release_11.89, Tassilo Horn, 2015/11/13