]> code.delx.au - gnu-emacs-elpa/blob - packages/muse/muse-regexps.el
Fix some quoting problems in doc strings
[gnu-emacs-elpa] / packages / muse / muse-regexps.el
1 ;;; muse-regexps.el --- define regexps used by Muse
2
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
5
6 ;; This file is part of Emacs Muse. It is not part of GNU Emacs.
7
8 ;; Emacs Muse is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 3, or (at your
11 ;; option) any later version.
12
13 ;; Emacs Muse is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ;; General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with Emacs Muse; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
22
23 ;;; Commentary:
24
25 ;; This file is the part of the Muse project that describes regexps
26 ;; that are used throughout the project.
27
28 ;;; Contributors:
29
30 ;;; Code:
31
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33 ;;
34 ;; Muse Regular Expressions
35 ;;
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37
38 (defgroup muse-regexp nil
39 "Regular expressions used in publishing and syntax highlighting."
40 :group 'muse)
41
42 ;;; Deal with the lack of character classes for regexps in Emacs21 and
43 ;;; XEmacs
44
45 (defcustom muse-regexp-use-character-classes 'undecided
46 "Indicate whether to use extended character classes like [:space:].
47 If `undecided', Muse will use them if your emacs is known to support them.
48
49 Emacs 22 and Emacs 21.3.50 are known to support them. XEmacs
50 does not support them.
51
52 Emacs 21.2 or higher support them, but with enough annoying edge
53 cases that the sanest default is to leave them disabled."
54 :type '(choice (const :tag "Yes" t)
55 (const :tag "No" nil)
56 (const :tag "Let Muse decide" undecided))
57 :group 'muse-regexp)
58
59 (defvar muse-regexp-emacs-revision
60 (save-match-data
61 (and (string-match "^[0-9]+\\.[0-9]+\\.\\([0-9]+\\)"
62 emacs-version)
63 (match-string 1 emacs-version)
64 (string-to-number (match-string 1 emacs-version))))
65 "The revision number of this version of Emacs.")
66
67 (defun muse-extreg-usable-p ()
68 "Return non-nil if extended character classes can be used,
69 nil otherwise.
70
71 This is used when deciding the initial values of the muse-regexp
72 options."
73 (cond
74 ((eq muse-regexp-use-character-classes t)
75 t)
76 ((eq muse-regexp-use-character-classes nil)
77 nil)
78 ((featurep 'xemacs) nil) ; unusable on XEmacs
79 ((> emacs-major-version 21) t) ; usable if > 21
80 ((< emacs-major-version 21) nil)
81 ((< emacs-minor-version 3) nil)
82 ;; don't use if version is of format 21.x
83 ((null muse-regexp-emacs-revision) nil)
84 ;; only trust 21.3.50 or higher
85 ((>= muse-regexp-emacs-revision 50) t)
86 (t nil)))
87
88 (defcustom muse-regexp-blank
89 (if (muse-extreg-usable-p)
90 "[:blank:]"
91 " \t")
92 "Regexp to use in place of \"[:blank:]\".
93 This should be something that matches spaces and tabs.
94
95 It is like a regexp, but should be embeddable inside brackets.
96 Muse will detect the appropriate value correctly most of
97 the time."
98 :type 'string
99 :options '("[:blank:]" " \t")
100 :group 'muse-regexp)
101
102 (defcustom muse-regexp-alnum
103 (if (muse-extreg-usable-p)
104 "[:alnum:]"
105 "A-Za-z0-9")
106 "Regexp to use in place of \"[:alnum:]\".
107 This should be something that matches all letters and numbers.
108
109 It is like a regexp, but should be embeddable inside brackets.
110 muse will detect the appropriate value correctly most of
111 the time."
112 :type 'string
113 :options '("[:alnum:]" "A-Za-z0-9")
114 :group 'muse-regexp)
115
116 (defcustom muse-regexp-lower
117 (if (muse-extreg-usable-p)
118 "[:lower:]"
119 "a-z")
120 "Regexp to use in place of \"[:lower:]\".
121 This should match all lowercase characters.
122
123 It is like a regexp, but should be embeddable inside brackets.
124 muse will detect the appropriate value correctly most of
125 the time."
126 :type 'string
127 :options '("[:lower:]" "a-z")
128 :group 'muse-regexp)
129
130 (defcustom muse-regexp-upper
131 (if (muse-extreg-usable-p)
132 "[:upper:]"
133 "A-Z")
134 "Regexp to use in place of \"[:upper:]\".
135 This should match all uppercase characters.
136
137 It is like a regexp, but should be embeddable inside brackets.
138 muse will detect the appropriate value correctly most of
139 the time."
140 :type 'string
141 :options '("[:upper:]" "A-Z")
142 :group 'muse-regexp)
143
144 ;;; Regexps used to define Muse publishing syntax
145
146 (defcustom muse-list-item-regexp
147 (concat "^%s\\(\\([^\n" muse-regexp-blank "].*?\\)?::"
148 "\\(?:[" muse-regexp-blank "]+\\|$\\)"
149 "\\|[" muse-regexp-blank "]-[" muse-regexp-blank "]*"
150 "\\|[" muse-regexp-blank "][0-9]+\\.[" muse-regexp-blank "]*\\)")
151 "Regexp used to match the beginning of a list item.
152 The `%s' will be replaced with a whitespace regexp when publishing."
153 :type 'regexp
154 :group 'muse-regexp)
155
156 (defcustom muse-ol-item-regexp (concat "\\`[" muse-regexp-blank "]+[0-9]+\\.")
157 "Regexp used to match an ordered list item."
158 :type 'regexp
159 :group 'muse-regexp)
160
161 (defcustom muse-ul-item-regexp (concat "\\`[" muse-regexp-blank "]+-")
162 "Regexp used to match an unordered list item."
163 :type 'regexp
164 :group 'muse-regexp)
165
166 (defcustom muse-dl-term-regexp
167 (concat "[" muse-regexp-blank "]*\\(.+?\\)["
168 muse-regexp-blank "]+::\\(?:[" muse-regexp-blank "]+\\|$\\)")
169 "Regexp used to match a definition list term.
170 The first match string must contain the term."
171 :type 'regexp
172 :group 'muse-regexp)
173
174 (defcustom muse-dl-entry-regexp (concat "\\`[" muse-regexp-blank "]*::")
175 "Regexp used to match a definition list entry."
176 :type 'regexp
177 :group 'muse-regexp)
178
179 (defcustom muse-table-field-regexp
180 (concat "[" muse-regexp-blank "]+\\(|+\\)\\(?:["
181 muse-regexp-blank "]\\|$\\)")
182 "Regexp used to match table separators when publishing."
183 :type 'regexp
184 :group 'muse-regexp)
185
186 (defcustom muse-table-line-regexp (concat ".*" muse-table-field-regexp ".*")
187 "Regexp used to match a table line when publishing."
188 :type 'regexp
189 :group 'muse-regexp)
190
191 (defcustom muse-table-hline-regexp (concat "[" muse-regexp-blank
192 "]*|[-+]+|[" muse-regexp-blank
193 "]*")
194 "Regexp used to match a horizontal separator line in a table."
195 :type 'regexp
196 :group 'muse-regexp)
197
198 (defcustom muse-table-el-border-regexp (concat "[" muse-regexp-blank "]*"
199 "\\+\\(-*\\+\\)+"
200 "[" muse-regexp-blank "]*")
201 "Regexp used to match the beginning and end of a table.el-style table."
202 :type 'regexp
203 :group 'muse-regexp)
204
205 (defcustom muse-table-el-line-regexp (concat "[" muse-regexp-blank "]*"
206 "|\\(.*|\\)*"
207 "[" muse-regexp-blank "]*")
208 "Regexp used to match a table line of a table.el-style table."
209 :type 'regexp
210 :group 'muse-regexp)
211
212 (defcustom muse-tag-regexp
213 (concat "<\\([^/" muse-regexp-blank "\n][^" muse-regexp-blank
214 "</>\n]*\\)\\(\\s-+[^<>]+[^</>\n]\\)?\\(/\\)?>")
215 "A regexp used to find XML-style tags within a buffer when publishing.
216 Group 1 should be the tag name, group 2 the properties, and group
217 3 the optional immediate ending slash."
218 :type 'regexp
219 :group 'muse-regexp)
220
221 (defcustom muse-explicit-link-regexp
222 "\\[\\[\\([^][\n]+\\)\\]\\(?:\\[\\([^][\n]+\\)\\]\\)?\\]"
223 "Regexp used to match [[target][description]] links.
224 Paren group 1 must match the URL, and paren group 2 the description."
225 :type 'regexp
226 :group 'muse-regexp)
227
228 (defcustom muse-implicit-link-regexp
229 (concat "\\([^" muse-regexp-blank "\n]+\\)")
230 "Regexp used to match an implicit link.
231 An implicit link is the largest block of text to be checked for
232 URLs and bare WikiNames by the `muse-link-at-point' function.
233 Paren group 1 is the text to be checked.
234
235 URLs are checked by default. To get WikiNames, load
236 muse-wiki.el.
237
238 This is only used when you are using muse-mode.el, but not
239 muse-colors.el.
240
241 If the above applies, and you want to match things with spaces in
242 them, you will have to modify this."
243 :type 'regexp
244 :group 'muse-regexp)
245
246 ;;; Regexps used to determine file types
247
248 (defcustom muse-file-regexp
249 (concat "\\`[~/]\\|\\?\\|/\\'\\|\\."
250 "\\(html?\\|pdf\\|mp3\\|el\\|zip\\|txt\\|tar\\)"
251 "\\(\\.\\(gz\\|bz2\\)\\)?\\'")
252 "A link matching this regexp will be regarded as a link to a file."
253 :type 'regexp
254 :group 'muse-regexp)
255
256 (defcustom muse-image-regexp
257 "\\.\\(eps\\|gif\\|jp\\(e?g\\)\\|p\\(bm\\|ng\\)\\|tiff\\|x\\([bp]m\\)\\)\\'"
258 "A link matching this regexp will be published inline as an image.
259 For example:
260
261 [[./wife.jpg][A picture of my wife]]
262
263 If you omit the description, the alt tag of the resulting HTML
264 buffer will be the name of the file."
265 :type 'regexp
266 :group 'muse-regexp)
267
268 (provide 'muse-regexps)
269
270 ;;; muse-regexps.el ends here