branch: master commit d2f4269e6a5e2b23f328ee0a861a94cdd51ccea9 Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Add new style/standalone.el * Makefile.in (STYLESRC): Add new style. * style/standalone.el: New file. --- Makefile.in | 2 +- style/standalone.el | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 9dcb3d7b..93405c56 100644 --- a/Makefile.in +++ b/Makefile.in @@ -198,7 +198,7 @@ STYLESRC = style/prosper.el \ style/amsaddr.el style/parskip.el style/catchfilebetweentags.el \ style/physics.el style/soul.el style/algpseudocodex.el \ style/wasysym.el style/refcount.el style/simpleicons.el \ - style/changebar.el style/amsrefs.el + style/changebar.el style/amsrefs.el style/standalone.el STYLEELC = $(STYLESRC:.el=.elc) diff --git a/style/standalone.el b/style/standalone.el new file mode 100644 index 00000000..12b1d686 --- /dev/null +++ b/style/standalone.el @@ -0,0 +1,153 @@ +;;; standalone.el --- AUCTeX style for `standalone.cls|sty' -*- lexical-binding: t; -*- + +;; Copyright (C) 2024 Free Software Foundation, Inc. + +;; Author: Arash Esbati <ar...@gnu.org> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2024-02-18 +;; Keywords: tex + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Commentary: + +;; This file adds support for `standalone.sty' and `standalone.cls' +;; v1.3b from 2022/10/10. + +;;; Code: + +(TeX-add-style-hook + "standalone" + (lambda () + + ;; General macros/env's provided by the class and the package: + (TeX-add-symbols + '("ifstandalonebeamer" 0) + '("ifstandalone" 0)) + + ;; Fontification: + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("standaloneconfig" "{")) + 'function)) + + ;; standalone.cls: + (when (assoc "standalone" LaTeX-provided-class-options) + (TeX-add-symbols + '("standaloneconfig" + (TeX-arg-key-val (lambda () + (append + `(("class" ,LaTeX-global-class-files) + ("multi" ,(append '("true" "false") + (mapcar #'car (LaTeX-environment-list))))) + LaTeX-standalone-class-options-list)))) + '("standaloneignore" 0) ) + + (LaTeX-add-environments "standalone") + + ;; \standaloneenv is relevant in conjunction with option multi: + (when (or (LaTeX-provided-class-options "standalone" "multi") + (LaTeX-provided-class-options "standalone" "multi=true")) + (TeX-add-symbols + '("standaloneenv" + (TeX-arg-completing-read-multiple (LaTeX-environment-list) + "Enviroment(s)"))) + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("standaloneenv" "{")) + 'function))) + + ;; standaloneframe env is relevant in conjunction with option beamer: + (when (or (LaTeX-provided-class-options "standalone" "beamer") + (LaTeX-provided-class-options "standalone" "beamer=true")) + (TeX-run-style-hooks "beamer") + (LaTeX-add-environments '("standaloneframe"))) + + ;; TikZ class option: + (when (or (LaTeX-provided-class-options "standalone" "tikz") + (LaTeX-provided-class-options "standalone" "tikz=true")) + (TeX-run-style-hooks "tikz"))) + + ;; standalone.sty + (when (assoc "standalone" LaTeX-provided-package-options) + (TeX-load-style "graphicx") + (TeX-add-symbols + '("standaloneconfig" + (TeX-arg-key-val (("group" ("true" "false")) + ("mode" ("tex" "image" "tex|image" "build" + "buildmissing" "buildnew")) + ("extension") + ("build")))) + '("includestandalone" + [TeX-arg-key-val (lambda () + (append (LaTeX-graphicx-key-val-options) + '(("group" ("true" "false")) + ("mode" ("tex" "image" "tex|image" "build" + "buildmissing" "buildnew")) + ("extension") + ("build"))))] + TeX-arg-file-name-sans-extension)) + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("includestandalone" "{")) + 'reference))) ) + TeX-dialect) + +(defun LaTeX-standalone-class-options-list () + "Class options for the standalone class." + `(("class" ,LaTeX-global-class-files) + ("multi" ,(append '("true" "false") + (mapcar #'car (LaTeX-environment-list)))) + ("crop" ("true" "false")) + ("preview" ("true" "false")) + ("border" ("{}")) + ("ignorerest" ("true" "false")) + ("multido" ("true" "false")) + ("varwidth" ("true" "false")) + ("tikz" ("true" "false")) + ("pstricks" ("true" "false")) + ("beamer" ("true" "false")) + ("float" ("true" "false")) + ("convert" ("true" "false")) + ("png"))) + +(defun LaTeX-standalone-class-options () + "Prompt for the class options for the standalone class." + (TeX-read-key-val t (LaTeX-standalone-class-options-list))) + +(defvar LaTeX-standalone-package-options-list + '(("subpreambles" ("true" "false")) + ("sort" ("true" "false")) + ("print" ("true" "false")) + ("comments" ("true" "false")) + ("nocomments") + ("group" ("true" "false")) + ("mode" ("tex" "image" "tex|image" "build" "buildmissing" "buildnew")) + ("obeyclassoptions" ("true" "false")) + ("extension") + ("build")) + "Package options for the standalone package.") + +(defun LaTeX-standalone-package-options () + "Prompt for options of the standalone package." + (TeX-arg-key-val t LaTeX-standalone-package-options-list)) + +;;; standalone.el ends here