1 ;;; acronym.el --- AUCTeX style for `acronym.sty' version 1.38.
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
5 ;; Maintainer: auctex-devel@gnu.org
6 ;; Author: Mosè Giordano <giordano.mose@libero.it>
9 ;; This file is part of AUCTeX.
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 ;; This file adds support for `acronym.sty' version 1.38.
32 (TeX-auto-add-type "acronym" "LaTeX")
34 ;; Self Parsing -- see (info "(auctex)Hacking the Parser").
35 (defvar LaTeX-acronym-regexp
36 (concat "\\\\\\(?:acro\\|newacro\\|acrodef\\)" "{\\([^\n\r%\\{}]+\\)}")
37 "Matches acronyms by `acronym' package.")
39 (defvar LaTeX-auto-acronym nil
40 "Temporary for parsing acronym by `acronym' package.")
42 (defun LaTeX-acronym-prepare ()
43 "Clear `LaTex-auto-acronym' before use."
44 (setq LaTeX-auto-acronym nil))
46 (defun LaTeX-acronym-cleanup ()
47 "Move acronyms from `LaTeX-auto-acronym' to `LaTeX-acronym-list'."
48 (mapc (lambda (acronym)
49 (add-to-list 'LaTeX-acronym-list (list acronym)))
52 ;; FIXME: This does not seem to work unless one does a manual reparse.
53 (add-hook 'TeX-auto-prepare-hook 'LaTeX-acronym-prepare)
54 (add-hook 'TeX-auto-cleanup-hook 'LaTeX-acronym-cleanup)
56 (defvar LaTeX-acronym-acronym-history nil
57 "History of acronyms in acronym.")
59 ;; The former `acronym' stands for package name, the latter stands for the
60 ;; argument of the macro calling this function.
61 (defun LaTeX-arg-acronym-acronym (optional &optional prompt definition)
62 "Prompt for an acronym completing with known acronyms.
63 If OPTIONAL is non-nil, insert the resulting value as an optional
64 argument, otherwise as a mandatory one. Use PROMPT as the prompt
65 string. If DEFINITION is non-nil, add the chosen acronym to the
66 list of defined acronyms."
67 (let ((acronym (completing-read (TeX-argument-prompt optional prompt "Acronym")
68 (LaTeX-acronym-list) nil nil nil
69 'LaTeX-acronym-acronym-history)))
70 (if (and definition (not (string-equal "" acronym)))
71 (LaTeX-add-acronyms acronym))
72 (TeX-argument-insert acronym optional optional)))
74 (defun LaTeX-arg-define-acronym-acronym (optional &optional prompt)
75 "Prompt for an acronym completing with known acronyms.
76 If OPTIONAL is non-nil, insert the resulting value as an optional
77 argument, otherwise as a mandatory one. Use PROMPT as the prompt
79 (LaTeX-arg-acronym-acronym optional prompt t))
84 (TeX-auto-add-regexp `(,LaTeX-acronym-regexp 1 LaTeX-auto-acronym))
85 (LaTeX-add-environments
86 '("acronym" LaTeX-env-args
87 [TeX-arg-string "Longest acronym"]))
89 ;; Acronyms in the Text
90 '("ac" LaTeX-arg-acronym-acronym)
92 '("acf" LaTeX-arg-acronym-acronym)
93 '("acs" LaTeX-arg-acronym-acronym)
94 '("acl" LaTeX-arg-acronym-acronym)
95 '("acp" LaTeX-arg-acronym-acronym)
96 '("acfp" LaTeX-arg-acronym-acronym)
97 '("acsp" LaTeX-arg-acronym-acronym)
98 '("aclp" LaTeX-arg-acronym-acronym)
99 '("acfi" LaTeX-arg-acronym-acronym)
100 '("acused" LaTeX-arg-acronym-acronym)
101 '("acsu" LaTeX-arg-acronym-acronym)
102 '("aclu" LaTeX-arg-acronym-acronym)
103 '("iac" LaTeX-arg-acronym-acronym)
104 '("Iac" LaTeX-arg-acronym-acronym)
105 '("ac*" LaTeX-arg-acronym-acronym)
106 '("acf*" LaTeX-arg-acronym-acronym)
107 '("acs*" LaTeX-arg-acronym-acronym)
108 '("acl*" LaTeX-arg-acronym-acronym)
109 '("acp*" LaTeX-arg-acronym-acronym)
110 '("acfp*" LaTeX-arg-acronym-acronym)
111 '("acsp*" LaTeX-arg-acronym-acronym)
112 '("aclp*" LaTeX-arg-acronym-acronym)
113 '("acfi*" LaTeX-arg-acronym-acronym)
114 '("acsu*" LaTeX-arg-acronym-acronym)
115 '("aclu*" LaTeX-arg-acronym-acronym)
116 '("iac*" LaTeX-arg-acronym-acronym)
117 '("Iac*" LaTeX-arg-acronym-acronym)
123 '("acro" LaTeX-arg-define-acronym-acronym [ "Short name" ] "Full name")
124 '("acroextra" "Additional info")
125 '("newacro" LaTeX-arg-define-acronym-acronym [ "Short name" ] "Full name")
126 '("acrodef" LaTeX-arg-define-acronym-acronym [ "Short name" ] "Full name")
127 ;; Non standard indefinite articles
128 '("acroindefinite" LaTeX-arg-acronym-acronym
129 "Short indefinite article" "Long indefinite article")
130 '("acrodefindefinite" LaTeX-arg-acronym-acronym
131 "Short indefinite article" "Long indefinite article")
132 '("newacroindefinite" LaTeX-arg-acronym-acronym
133 "Short indefinite article" "Long indefinite article")
134 ;; Non standard and foreign plural forms
135 '("acroplural" LaTeX-arg-acronym-acronym [ "Short plural" ] "Long plural")
136 '("acrodefplural" LaTeX-arg-acronym-acronym [ "Short plural" ] "Long plural")
137 '("newacroplural" LaTeX-arg-acronym-acronym [ "Short plural" ] "Long plural"))
144 (when (and (featurep 'font-latex)
145 (eq TeX-install-font-lock 'font-latex-setup))
146 (font-latex-add-keywords '(("ac" "*{")
164 ("acroindefinite" "{{{")
165 ("acrodefindefinite" "{{{")
166 ("newacroindefinite" "{{{")
168 ("acrodefplural" "{[{")
169 ("newacroplural" "{[{"))
173 (defvar LaTeX-acronym-package-options
174 '("footnote" "nohyperlinks" "printonlyused" "withpage" "smaller" "dua" "nolist")
175 "Package options for the acronym package.")
177 ;; acronym.el ends here