monnier pushed a commit to branch externals/auctex in repository elpa. commit bd1ef546da99535e8005af74a0feddb94895106e Author: Mosè Giordano <giordano.m...@libero.it> Date: Fri Apr 12 00:53:40 2013 +0200
Add new style files acro.el and acronym.el. * Makefile.in (STYLESRC): Add style/acro.el and style/acronym.el. * style/acro.el: New style. * style/acronym.el: Ditto. --- ChangeLog | 8 ++ Makefile.in | 3 +- style/acro.el | 294 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ style/acronym.el | 172 +++++++++++++++++++++++++++++++ 4 files changed, 476 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index 125f583..bb2b0c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-04-12 Mos� Giordano <giordano.m...@libero.it> + + * Makefile.in (STYLESRC): Add style/acro.el and style/acronym.el. + + * style/acro.el: New style. + + * style/acronym.el: Ditto. + 2013-04-10 Tassilo Horn <t...@gnu.org> * tex.el (TeX-evince-sync-view): URL-escape pdf file path when diff --git a/Makefile.in b/Makefile.in index 8eca7f3..4944b42 100644 --- a/Makefile.in +++ b/Makefile.in @@ -130,7 +130,8 @@ STYLESRC = style/prosper.el \ style/longtable.el style/lipsum.el style/kantlipsum.el \ style/memoir.el style/placeins.el style/nameref.el \ style/fancynum.el style/fancyhdr.el style/filecontents.el \ - style/array.el style/kpfonts.el + style/array.el style/kpfonts.el style/acro.el \ + style/acronym.el STYLEELC = $(STYLESRC:.el=.elc) CLEANFILES = $(AUCELC) $(STYLEELC) $(MULEELC) diff --git a/style/acro.el b/style/acro.el new file mode 100644 index 0000000..61b57a0 --- /dev/null +++ b/style/acro.el @@ -0,0 +1,294 @@ +;;; acro.el --- AUCTeX style for `acro.sty' version 1.2a. + +;; Copyright (C) 2013 Free Software Foundation, Inc. + +;; Maintainer: auctex-de...@gnu.org +;; Author: Mosè Giordano <giordano.m...@libero.it> +;; 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 `acro.sty' version 1.2a. + +;;; Code: + +(defvar LaTeX-acro-package-options-list + '(;; General Options + ("version" ("0" "1")) + ("single" ("true" "false")) + ("hyperref" ("true" "false")) + ("record-pages" ("true" "false")) + ("only-used" ("true" "false")) + ("mark-as-used" ("first" "any")) + ("macros" ("true" "false")) + ("xspace" ("true" "false")) + ("strict" ("true" "false")) + ("sort" ("true" "false")) + ("cite" ("all" "first" "none")) + ("cite-cmd") + ("cite-space") + ("index-cmd") + ("accsupp" ("true" "false")) + ("uc-cmd") + ;; Options Regarding Acronyms + ("short-format") + ("long-format") + ("first-long-format") + ("list-short-format") + ("list-long-format") + ("extra-format") + ("first-style" ("default" "plain" "empty" "square" "short" "reversed" + "plain-reversed" "footnote" "sidenote")) + ("extra-style" ("default" "plain" "comma" "paren" "bracket")) + ("plural-ending") + ;; Options Regarding the List + ("page-ref" ("none" "plain" "comma" "paren")) + ("page-name") + ("pages-name") + ("page-ranges" ("true" "false")) + ("next-page") + ("next-pages") + ("list-type" ("table" "itemize" "description")) + ("list-style" ("list" "tabular" "longtable" "extra-tabular" "extra-longtable" + "extra-tabular-rev" "extra-longtable-rev")) + ("list-header" ("chapter" "chapter*" "section" "section*" "subsection" + "subsection*" "addchap" "addsec")) + ("list-name") + ("list-table-width") + ("list-caps" ("true" "false"))) + "Package options for the acro package.") + +(TeX-auto-add-type "acro-acronym" "LaTeX") + +;; Self Parsing -- see (info "(auctex)Hacking the Parser"). +(defvar LaTeX-acro-regexp + (concat "\\\\DeclareAcronym" "{\\([^\n\r%\\{}]+\\)}") + "Matches `acro' acronym definitions.") + +(defvar LaTeX-auto-acro-acronym nil + "Temporary for parsing `acro' acronym definitions.") + +(defun LaTeX-acro-prepare () + "Clear `LaTex-auto-acro-acronym' before use." + (setq LaTeX-auto-acro-acronym nil)) + +(defun LaTeX-acro-cleanup () + "Move acronyms from `LaTeX-auto-acro-acronym' to +`LaTeX-acro-list' and to `TeX-auto-symbol' if option `macros' is +set to `true'." + (mapc (lambda (acronym) + (add-to-list 'LaTeX-acro-acronym-list (list acronym))) + LaTeX-auto-acro-acronym) + (when (or (LaTeX-provided-package-options-member "acro" "macros") + (LaTeX-provided-package-options-member "acro" "macros=true")) + (add-to-list 'TeX-auto-symbol LaTeX-auto-acro-acronym))) + +;; FIXME: This does not seem to work unless one does a manual reparse. +(add-hook 'TeX-auto-prepare-hook 'LaTeX-acro-prepare) +(add-hook 'TeX-auto-cleanup-hook 'LaTeX-acro-cleanup) + +(defun LaTeX-arg-acro-acronym (optional &optional prompt definition) + "Prompt for an acronym completing with known acronyms. +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 acronym to the +list of defined acronyms." + (let ((acronym (completing-read (TeX-argument-prompt optional prompt "Acronym") + (LaTeX-acro-acronym-list)))) + (if (and definition (not (string-equal "" acronym))) + (LaTeX-add-acro-acronyms acronym)) + (TeX-argument-insert acronym optional optional))) + +(defun LaTeX-arg-define-acro-acronym (optional &optional prompt) + "Prompt for an acronym completing with known acronyms. +If OPTIONAL is non-nil, insert the resulting value as an optional +argument, otherwise as a mandatory one. Use PROMPT as the prompt +string." + (LaTeX-arg-acro-acronym optional prompt t)) + +(defvar LaTeX-acro-declareacronym-keys + '(("short") ("long") ("short-plural") ("long-plural") ("long-plural-form") + ("short-indefinite") ("long-indefinite") ("long-pre") ("long-post") ("alt") + ("alt-indefinite") ("extra") ("sort") ("class") ("cite") ("short-format") + ("long-format") ("first-long-format") ("pdfstring") ("accsupp") + ("index-sort") ("index") ("index-cmd")) + "List of keys accepted by `\DeclareAcronym' macro of `acro' package +in its second mandatory argument.") + +(defvar LaTeX-acro-printacronyms-keys + '(("include-classes") ("exclude-classes") ("name") ("header")) + "List of keys accepted by `\printacronyms' macro of `acro' package +in its optional argument.") + +(defun LaTeX-arg-acro-key-val (optional prompt key-val-alist) + "Prompt for keys and values in KEY-VAL-ALIST. +<SPC> key bindings in minibuffer are removed temporarily. Insert +the given value as a TeX macro argument. If OPTIONAL is non-nil, +insert it as an optional argument. Use PROMPT as the prompt +string. KEY-VAL-ALIST is an alist. The car of each element +should be a string representing a key and the optional cdr should +be a list with strings to be used as values for the key." + ;; Remove <SPC> key bindings in minibuffer. + (let ((space-completion (lookup-key minibuffer-local-completion-map " ")) + (space-must-match (lookup-key minibuffer-local-must-match-map " "))) + (define-key minibuffer-local-completion-map " " nil) + (define-key minibuffer-local-must-match-map " " nil) + (let ((var (multi-prompt-key-value + (TeX-argument-prompt optional "Options (k=v)" prompt) + (eval key-val-alist)))) + (TeX-argument-insert var optional)) + ;; Restore <SPC> key bindings in minibuffer. + (define-key minibuffer-local-completion-map " " space-completion) + (define-key minibuffer-local-must-match-map " " space-must-match))) + +(TeX-add-style-hook + "acro" + (lambda () + (TeX-auto-add-regexp `(,LaTeX-acro-regexp 1 LaTeX-auto-acro-acronym)) + (TeX-add-symbols + ;; Creating New Acronyms + '("DeclareAcronym" LaTeX-arg-define-acro-acronym + (LaTeX-arg-acro-key-val "Definition of acronym (k=v)" + LaTeX-acro-declareacronym-keys)) + ;; Using the Acronyms + '("ac" LaTeX-arg-acro-acronym) + '("ac*" LaTeX-arg-acro-acronym) + '("Ac" LaTeX-arg-acro-acronym) + '("Ac*" LaTeX-arg-acro-acronym) + '("acs" LaTeX-arg-acro-acronym) + '("acs*" LaTeX-arg-acro-acronym) + '("acl" LaTeX-arg-acro-acronym) + '("acl*" LaTeX-arg-acro-acronym) + '("Acl" LaTeX-arg-acro-acronym) + '("Acl*" LaTeX-arg-acro-acronym) + '("aca" LaTeX-arg-acro-acronym) + '("aca*" LaTeX-arg-acro-acronym) + '("acf" LaTeX-arg-acro-acronym) + '("acf*" LaTeX-arg-acro-acronym) + '("Acf" LaTeX-arg-acro-acronym) + '("Acf*" LaTeX-arg-acro-acronym) + '("acp" LaTeX-arg-acro-acronym) + '("acp*" LaTeX-arg-acro-acronym) + '("Acp" LaTeX-arg-acro-acronym) + '("Acp*" LaTeX-arg-acro-acronym) + '("acsp" LaTeX-arg-acro-acronym) + '("acsp*" LaTeX-arg-acro-acronym) + '("aclp" LaTeX-arg-acro-acronym) + '("aclp*" LaTeX-arg-acro-acronym) + '("Aclp" LaTeX-arg-acro-acronym) + '("Aclp*" LaTeX-arg-acro-acronym) + '("acap" LaTeX-arg-acro-acronym) + '("acap*" LaTeX-arg-acro-acronym) + '("acfp" LaTeX-arg-acro-acronym) + '("acfp*" LaTeX-arg-acro-acronym) + '("Acfp" LaTeX-arg-acro-acronym) + '("Acfp*" LaTeX-arg-acro-acronym) + ;; Indefinite Forms + '("iac" LaTeX-arg-acro-acronym) + '("iac*" LaTeX-arg-acro-acronym) + '("Iac" LaTeX-arg-acro-acronym) + '("Iac*" LaTeX-arg-acro-acronym) + '("iacs" LaTeX-arg-acro-acronym) + '("iacs*" LaTeX-arg-acro-acronym) + '("Iacs" LaTeX-arg-acro-acronym) + '("Iacs*" LaTeX-arg-acro-acronym) + '("iaca" LaTeX-arg-acro-acronym) + '("iaca*" LaTeX-arg-acro-acronym) + '("Iaca" LaTeX-arg-acro-acronym) + '("Iaca*" LaTeX-arg-acro-acronym) + '("iacl" LaTeX-arg-acro-acronym) + '("iacl*" LaTeX-arg-acro-acronym) + '("Iacl" LaTeX-arg-acro-acronym) + '("Iacl*" LaTeX-arg-acro-acronym) + '("iacf" LaTeX-arg-acro-acronym) + '("iacf*" LaTeX-arg-acro-acronym) + '("Iacf" LaTeX-arg-acro-acronym) + '("Iacf*" LaTeX-arg-acro-acronym) + '("iacflike" LaTeX-arg-acro-acronym) + '("iacflike*" LaTeX-arg-acro-acronym) + '("Iacflike" LaTeX-arg-acro-acronym) + '("Iacflike*" LaTeX-arg-acro-acronym) + ;; Simulating the First Appearance + '("acflike" LaTeX-arg-acro-acronym) + '("acflike*" LaTeX-arg-acro-acronym) + '("acfplike" LaTeX-arg-acro-acronym) + '("acfplike*" LaTeX-arg-acro-acronym) + ;; Reset or Mark as Used + '("acreset" "List of acronyms") + '("acresetall" 0) + '("acuse" "List of acronyms") + '("acuseall" 0) + ;; PDF bookmarks + '("acpdfstring" LaTeX-arg-acro-acronym) + '("acpdfstringplural" LaTeX-arg-acro-acronym) + ;; Printing the List + '("printacronyms" [LaTeX-arg-acro-key-val nil LaTeX-acro-printacronyms-keys]) + ;; Customization + '("acsetup" (TeX-arg-key-val LaTeX-acro-package-options-list))) + (TeX-run-style-hooks + "l3sort" + "xspace" + "xtemplate" + "l3keys2e" + "xparse" + "expl3") + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("DeclareAcronym" "{{") + ("ac" "*{") + ("Ac" "*{") + ("acs" "*{") + ("acl" "*{") + ("Acl" "*{") + ("aca" "*{") + ("acf" "*{") + ("Acf" "*{") + ("acp" "*{") + ("Acp" "*{") + ("acsp" "*{") + ("aclp" "*{") + ("Aclp" "*{") + ("acap" "*{") + ("acfp" "*{") + ("Acfp" "*{") + ("acflike" "*{") + ("acfplike" "*{") + ("iac" "*{") + ("Iac" "*{") + ("iacs" "*{") + ("Iacs" "*{") + ("iaca" "*{") + ("Iaca" "*{") + ("iacl" "*{") + ("Iacl" "*{") + ("iacf" "*{") + ("Iacf" "*{") + ("iacflike" "*{") + ("Iacflike" "*{") + ("acuse" "{")) + 'function)))) + +(defun LaTeX-acro-package-options () + "Prompt for package options for the acro package." + (TeX-read-key-val t LaTeX-acro-package-options-list)) + +;;; acro.el ends here diff --git a/style/acronym.el b/style/acronym.el new file mode 100644 index 0000000..3bffd70 --- /dev/null +++ b/style/acronym.el @@ -0,0 +1,172 @@ +;;; acronym.el --- AUCTeX style for `acronym.sty' version 1.38. + +;; Copyright (C) 2013 Free Software Foundation, Inc. + +;; Maintainer: auctex-de...@gnu.org +;; Author: Mosè Giordano <giordano.m...@libero.it> +;; 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 `acronym.sty' version 1.38. + +;;; Code: + +(TeX-auto-add-type "acronym" "LaTeX") + +;; Self Parsing -- see (info "(auctex)Hacking the Parser"). +(defvar LaTeX-acronym-regexp + (concat "\\\\\\(?:acro\\|newacro\\|acrodef\\)" "{\\([^\n\r%\\{}]+\\)}") + "Matches acronyms by `acronym' package.") + +(defvar LaTeX-auto-acronym nil + "Temporary for parsing acronym by `acronym' package.") + +(defun LaTeX-acronym-prepare () + "Clear `LaTex-auto-acronym' before use." + (setq LaTeX-auto-acronym nil)) + +(defun LaTeX-acronym-cleanup () + "Move acronyms from `LaTeX-auto-acronym' to `LaTeX-acronym-list'." + (mapc (lambda (acronym) + (add-to-list 'LaTeX-acronym-list (list acronym))) + LaTeX-auto-acronym)) + +;; FIXME: This does not seem to work unless one does a manual reparse. +(add-hook 'TeX-auto-prepare-hook 'LaTeX-acronym-prepare) +(add-hook 'TeX-auto-cleanup-hook 'LaTeX-acronym-cleanup) + +;; The former `acronym' stands for package name, the latter stands for the +;; argument of the macro calling this function. +(defun LaTeX-arg-acronym-acronym (optional &optional prompt definition) + "Prompt for an acronym completing with known acronyms. +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 acronym to the +list of defined acronyms." + (let ((acronym (completing-read (TeX-argument-prompt optional prompt "Acronym") + (LaTeX-acronym-list)))) + (if (and definition (not (string-equal "" acronym))) + (LaTeX-add-acronyms acronym)) + (TeX-argument-insert acronym optional optional))) + +(defun LaTeX-arg-define-acronym-acronym (optional &optional prompt) + "Prompt for an acronym completing with known acronyms. +If OPTIONAL is non-nil, insert the resulting value as an optional +argument, otherwise as a mandatory one. Use PROMPT as the prompt +string." + (LaTeX-arg-acronym-acronym optional prompt t)) + +(TeX-add-style-hook + "acronym" + (lambda () + (TeX-auto-add-regexp `(,LaTeX-acronym-regexp 1 LaTeX-auto-acronym)) + (LaTeX-add-environments + '("acronym" LaTeX-env-args + [TeX-arg-string "Longest acronym"])) + (TeX-add-symbols + ;; Acronyms in the Text + '("ac" LaTeX-arg-acronym-acronym) + '("acresetall" 0) + '("acf" LaTeX-arg-acronym-acronym) + '("acs" LaTeX-arg-acronym-acronym) + '("acl" LaTeX-arg-acronym-acronym) + '("acp" LaTeX-arg-acronym-acronym) + '("acfp" LaTeX-arg-acronym-acronym) + '("acsp" LaTeX-arg-acronym-acronym) + '("aclp" LaTeX-arg-acronym-acronym) + '("acfi" LaTeX-arg-acronym-acronym) + '("acused" LaTeX-arg-acronym-acronym) + '("acsu" LaTeX-arg-acronym-acronym) + '("aclu" LaTeX-arg-acronym-acronym) + '("iac" LaTeX-arg-acronym-acronym) + '("Iac" LaTeX-arg-acronym-acronym) + '("ac*" LaTeX-arg-acronym-acronym) + '("acf*" LaTeX-arg-acronym-acronym) + '("acs*" LaTeX-arg-acronym-acronym) + '("acl*" LaTeX-arg-acronym-acronym) + '("acp*" LaTeX-arg-acronym-acronym) + '("acfp*" LaTeX-arg-acronym-acronym) + '("acsp*" LaTeX-arg-acronym-acronym) + '("aclp*" LaTeX-arg-acronym-acronym) + '("acfi*" LaTeX-arg-acronym-acronym) + '("acsu*" LaTeX-arg-acronym-acronym) + '("aclu*" LaTeX-arg-acronym-acronym) + '("iac*" LaTeX-arg-acronym-acronym) + '("Iac*" LaTeX-arg-acronym-acronym) + ;; Customization + '("acsfont" 1) + '("acffont" 1) + '("acfsfont" 1) + ;; Defining Acronyms + '("acro" LaTeX-arg-define-acronym-acronym [ "Short name" ] "Full name") + '("acroextra" "Additional info") + '("newacro" LaTeX-arg-define-acronym-acronym [ "Short name" ] "Full name") + '("acrodef" LaTeX-arg-define-acronym-acronym [ "Short name" ] "Full name") + ;; Non standard indefinite articles + '("acroindefinite" LaTeX-arg-acronym-acronym + "Short indefinite article" "Long indefinite article") + '("acrodefindefinite" LaTeX-arg-acronym-acronym + "Short indefinite article" "Long indefinite article") + '("newacroindefinite" LaTeX-arg-acronym-acronym + "Short indefinite article" "Long indefinite article") + ;; Non standard and foreign plural forms + '("acroplural" LaTeX-arg-acronym-acronym [ "Short plural" ] "Long plural") + '("acrodefplural" LaTeX-arg-acronym-acronym [ "Short plural" ] "Long plural") + '("newacroplural" LaTeX-arg-acronym-acronym [ "Short plural" ] "Long plural")) + (TeX-run-style-hooks + "relsize" + "xstring" + "suffix") + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("ac" "*{") + ("acf" "*{") + ("acs" "*{") + ("acl" "*{") + ("acp" "*{") + ("acfp" "*{") + ("acsp" "*{") + ("aclp" "*{") + ("acfi" "*{") + ("acused" "{") + ("acsu" "*{") + ("aclu" "*{") + ("iac" "*{") + ("Iac" "*{") + ("acro" "{[{") + ("acroextra" "{") + ("newacro" "{[{") + ("acrodef" "{[{") + ("acroindefinite" "{{{") + ("acrodefindefinite" "{{{") + ("newacroindefinite" "{{{") + ("acroplural" "{[{") + ("acrodefplural" "{[{") + ("newacroplural" "{[{")) + 'function)))) + +(defvar LaTeX-acronym-package-options + '("footnote" "nohyperlinks" "printonlyused" "withpage" "smaller" "dua" "nolist") + "Package options for the acronym package.") + +;; acronym.el ends here