1 ;;; muse-regexps.el --- define regexps used by Muse
3 ;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
5 ;; This file is part of Emacs Muse. It is not part of GNU Emacs.
7 ;; Emacs Muse is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 2, or (at your
10 ;; option) any later version.
12 ;; Emacs Muse is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with Emacs Muse; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
24 ;; This file is the part of the Muse project that describes regexps
25 ;; that are used throughout the project.
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33 ;; Muse Regular Expressions
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37 (defgroup muse-regexp nil
38 "Regular expressions used in publishing and syntax highlighting."
41 ;;; Deal with the lack of character classes for regexps in Emacs21 and
44 (defcustom muse-regexp-use-character-classes
'undecided
45 "Indicate whether to use extended character classes like [:space:].
46 If 'undecided, Muse will use them if your emacs is known to support them.
48 Emacs 22 and Emacs 21.3.50 are known to support them. XEmacs
49 does not support them.
51 Emacs 21.2 or higher support them, but with enough annoying edge
52 cases that the sanest default is to leave them disabled."
53 :type
'(choice (const :tag
"Yes" t
)
55 (const :tag
"Let Muse decide" undecided
))
58 (defvar muse-regexp-emacs-revision
60 (and (string-match "^[0-9]+\\.[0-9]+\\.\\([0-9]+\\)"
62 (match-string 1 emacs-version
)
63 (string-to-number (match-string 1 emacs-version
))))
64 "The revision number of this version of Emacs.")
66 (defun muse-extreg-usable-p ()
67 "Return non-nil if extended character classes can be used,
70 This is used when deciding the initial values of the muse-regexp
73 ((eq muse-regexp-use-character-classes t
)
75 ((eq muse-regexp-use-character-classes nil
)
77 ((featurep 'xemacs
) nil
) ; unusable on XEmacs
78 ((> emacs-major-version
21) t
) ; usable if > 21
79 ((< emacs-major-version
21) nil
)
80 ((< emacs-minor-version
3) nil
)
81 ;; don't use if version is of format 21.x
82 ((null muse-regexp-emacs-revision
) nil
)
83 ;; only trust 21.3.50 or higher
84 ((>= muse-regexp-emacs-revision
50) t
)
87 (defcustom muse-regexp-blank
88 (if (muse-extreg-usable-p)
91 "Regexp to use in place of \"[:blank:]\".
92 This should be something that matches spaces and tabs.
94 It is like a regexp, but should be embeddable inside brackets.
95 Muse will detect the appropriate value correctly most of
98 :options
'("[:blank:]" " \t")
101 (defcustom muse-regexp-alnum
102 (if (muse-extreg-usable-p)
105 "Regexp to use in place of \"[:alnum:]\".
106 This should be something that matches all letters and numbers.
108 It is like a regexp, but should be embeddable inside brackets.
109 muse will detect the appropriate value correctly most of
112 :options
'("[:alnum:]" "A-Za-z0-9")
115 (defcustom muse-regexp-lower
116 (if (muse-extreg-usable-p)
119 "Regexp to use in place of \"[:lower:]\".
120 This should match all lowercase characters.
122 It is like a regexp, but should be embeddable inside brackets.
123 muse will detect the appropriate value correctly most of
126 :options
'("[:lower:]" "a-z")
129 (defcustom muse-regexp-upper
130 (if (muse-extreg-usable-p)
133 "Regexp to use in place of \"[:upper:]\".
134 This should match all uppercase characters.
136 It is like a regexp, but should be embeddable inside brackets.
137 muse will detect the appropriate value correctly most of
140 :options
'("[:upper:]" "A-Z")
143 ;;; Regexps used to define Muse publishing syntax
145 (defcustom muse-list-item-regexp
146 (concat "^%s\\(\\([^\n" muse-regexp-blank
"].*?\\)?::"
147 "\\(?:[" muse-regexp-blank
"]+\\|$\\)"
148 "\\|[" muse-regexp-blank
"]-[" muse-regexp-blank
"]*"
149 "\\|[" muse-regexp-blank
"][0-9]+\\.[" muse-regexp-blank
"]*\\)")
150 "Regexp used to match the beginning of a list item.
151 The '%s' will be replaced with a whitespace regexp when publishing."
155 (defcustom muse-ol-item-regexp
(concat "\\`[" muse-regexp-blank
"]+[0-9]+\\.")
156 "Regexp used to match an ordered list item."
160 (defcustom muse-ul-item-regexp
(concat "\\`[" muse-regexp-blank
"]+-")
161 "Regexp used to match an unordered list item."
165 (defcustom muse-dl-term-regexp
166 (concat "[" muse-regexp-blank
"]*\\(.+?\\)["
167 muse-regexp-blank
"]+::\\(?:[" muse-regexp-blank
"]+\\|$\\)")
168 "Regexp used to match a definition list term.
169 The first match string must contain the term."
173 (defcustom muse-dl-entry-regexp
(concat "\\`[" muse-regexp-blank
"]*::")
174 "Regexp used to match a definition list entry."
178 (defcustom muse-table-field-regexp
179 (concat "[" muse-regexp-blank
"]+\\(|+\\)\\(?:["
180 muse-regexp-blank
"]\\|$\\)")
181 "Regexp used to match table separators when publishing."
185 (defcustom muse-table-line-regexp
(concat ".*" muse-table-field-regexp
".*")
186 "Regexp used to match a table line when publishing."
190 (defcustom muse-table-hline-regexp
(concat "[" muse-regexp-blank
191 "]*|[-+]+|[" muse-regexp-blank
193 "Regexp used to match a horizontal separator line in a table."
197 (defcustom muse-table-el-border-regexp
(concat "[" muse-regexp-blank
"]*"
199 "[" muse-regexp-blank
"]*")
200 "Regexp used to match the beginning and end of a table.el-style table."
204 (defcustom muse-tag-regexp
205 (concat "<\\([^/" muse-regexp-blank
"\n][^" muse-regexp-blank
206 "</>\n]*\\)\\(\\s-+[^<>\n]+[^</>\n]\\)?\\(/\\)?>")
207 "A regexp used to find XML-style tags within a buffer when publishing.
208 Group 1 should be the tag name, group 2 the properties, and group
209 3 the optional immediate ending slash."
213 (defcustom muse-explicit-link-regexp
214 "\\[\\[\\([^][\n]+\\)\\]\\(?:\\[\\([^][\n]+\\)\\]\\)?\\]"
215 "Regexp used to match [[target][description]] links.
216 Paren group 1 must match the URL, and paren group 2 the description."
220 (defcustom muse-implicit-link-regexp
221 (concat "\\([^" muse-regexp-blank
"\n]+\\)")
222 "Regexp used to match an implicit link.
223 An implicit link is the largest block of text to be checked for
224 URLs and bare WikiNames by the `muse-link-at-point' function.
225 Paren group 1 is the text to be checked.
227 URLs are checked by default. To get WikiNames, load
230 This is only used when you are using muse-mode.el, but not
233 If the above applies, and you want to match things with spaces in
234 them, you will have to modify this."
238 ;;; Regexps used to determine file types
240 (defcustom muse-file-regexp
241 (concat "\\`[~/]\\|\\?\\|/\\'\\|\\."
242 "\\(html?\\|pdf\\|mp3\\|el\\|zip\\|txt\\|tar\\)"
243 "\\(\\.\\(gz\\|bz2\\)\\)?\\'")
244 "A link matching this regexp will be regarded as a link to a file."
248 (defcustom muse-image-regexp
249 "\\.\\(eps\\|gif\\|jp\\(e?g\\)\\|p\\(bm\\|ng\\)\\|tiff\\|x\\([bp]m\\)\\)\\'"
250 "A link matching this regexp will be published inline as an image.
253 [[./wife.jpg][A picture of my wife]]
255 If you omit the description, the alt tag of the resulting HTML
256 buffer will be the name of the file."
260 (provide 'muse-regexps
)
262 ;;; muse-regexps.el ends here