Provide optional outline-style faces; customization fixes; experimental stuff.
[muse-el.git] / muse-regexps.el
blob39c408d60b8319d1b32ab62255855c7af9403f75
1 ;;; muse-regexps.el --- Define regexps used by Muse.
3 ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 ;; This file is not part of GNU Emacs.
7 ;; This is free software; you can redistribute it and/or modify it under
8 ;; the terms of the GNU General Public License as published by the Free
9 ;; Software Foundation; either version 2, or (at your option) any later
10 ;; version.
12 ;; This is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 ;; for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; 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.
22 ;;; Commentary:
24 ;; This file is the part of the Muse project that describes regexps
25 ;; that are used throughout the project.
27 ;;; Contributors:
29 ;;; Code:
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33 ;; Muse Regular Expressions
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37 (defun muse-extreg-usable-p ()
38 "Return non-nil if extended character classes can be used,
39 nil otherwise.
41 This is used when deciding the initial values of the muse-regexp
42 options."
43 (save-match-data
44 (string-match "^[0-9]+\\.[0-9]+\\.\\([0-9]+\\)"
45 emacs-version)
46 (cond ((featurep 'xemacs) nil) ; unusable on XEmacs
47 ((> emacs-major-version 21) t) ; usable if > 21
48 ((< emacs-major-version 21) nil)
49 ((< emacs-minor-version 3) nil)
50 ;; don't use if version is of format 21.x
51 ((null (match-string 1 emacs-version)) nil)
52 ;; don't trust the 21.3.1 release or its predecessors
53 ((> (string-to-number (match-string 1 emacs-version)) 1) t)
54 (t nil))))
56 (defgroup muse-regexp nil
57 "Regular expressions used in publishing and syntax highlighting."
58 :group 'muse)
60 (defcustom muse-regexp-blank
61 (if (muse-extreg-usable-p)
62 "[:blank:]"
63 " \t")
64 "Regexp to use in place of \"[:blank:]\".
65 This should be something that matches spaces and tabs.
67 It is like a regexp, but should be embeddable inside brackets.
68 Muse will detect the appropriate value correctly most of
69 the time."
70 :type 'string
71 :options '("[:blank:]" " \t")
72 :group 'muse-regexp)
74 (defcustom muse-regexp-space
75 (if (muse-extreg-usable-p)
76 "[:space:]"
77 " \t\n")
78 "Regexp to use in place of \"[:space:]\".
79 This should be something that matches spaces, tabs, and newlines.
81 It is like a regexp, but should be embeddable inside brackets.
82 muse will detect the appropriate value correctly most of
83 the time."
84 :type 'string
85 :options '("[:space:]" " \t\n")
86 :group 'muse-regexp)
88 (defcustom muse-regexp-alnum
89 (if (muse-extreg-usable-p)
90 "[:alnum:]"
91 "A-Za-z0-9")
92 "Regexp to use in place of \"[:alnum:]\".
93 This should be something that matches all letters and numbers.
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 '("[:alnum:]" "A-Za-z0-9")
100 :group 'muse-regexp)
102 (defcustom muse-regexp-lower
103 (if (muse-extreg-usable-p)
104 "[:lower:]"
105 "a-z")
106 "Regexp to use in place of \"[:lower:]\".
107 This should match all lowercase characters.
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 '("[:lower:]" "a-z")
114 :group 'muse-regexp)
116 (defcustom muse-regexp-upper
117 (if (muse-extreg-usable-p)
118 "[:upper:]"
119 "A-Z")
120 "Regexp to use in place of \"[:upper:]\".
121 This should match all uppercase characters.
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 '("[:upper:]" "A-Z")
128 :group 'muse-regexp)
130 (defcustom muse-tag-regexp
131 (concat "<\\([^/" muse-regexp-space "][^" muse-regexp-space
132 "</>]*\\)\\(\\s-+[^<>]+[^</>]\\)?\\(/\\)?>")
133 "A regexp used to find XML-style tags within a buffer when publishing.
134 Group 1 should be the tag name, group 2 the properties, and group
135 3 the optional immediate ending slash."
136 :type 'regexp
137 :group 'muse-regexp)
139 (defcustom muse-link-regexp
140 "\\[\\[\\([^][\t\n]+\\)\\]\\(?:\\[\\([^][\n]+\\)\\]\\)?\\]"
141 "Regexp used to match [[target][description]] links.
142 Paren group 1 must match the URL, and paren group 2 the description."
143 :type 'regexp
144 :group 'muse-regexp)
146 (defcustom muse-url-regexp
147 (concat "\\<\\(?:https?:/?/?\\|ftp:/?/?\\|gopher://\\|"
148 "telnet://\\|wais://\\|file:/\\|s?news:\\|"
149 "mailto:\\)"
150 "[^] \n \"'()<>[^`{}]*[^] \n \"'()<>[^`{}.,;]+")
151 "A regexp used to match URLs within a Muse page."
152 :type 'regexp
153 :group 'muse-regexp)
155 (defcustom muse-file-regexp
156 "[/?]\\|\\.\\(html?\\|pdf\\|mp3\\|el\\|zip\\|txt\\|tar\\)\\(\\.\\(gz\\|bz2\\)\\)?\\'"
157 "A link matching this regexp will be regarded as a link to a file."
158 :type 'regexp
159 :group 'muse-regexp)
161 (defcustom muse-image-regexp
162 "\\.\\(eps\\|gif\\|jp\\(e?g\\)\\|p\\(bm\\|ng\\)\\|tiff\\|x\\([bp]m\\)\\)\\'"
163 "A link matching this regexp will be published inline as an image.
164 For example:
166 [[./wife.jpg][A picture of my wife]]
168 If you omit the description, the alt tag of the resulting HTML
169 buffer will be the name of the file."
170 :type 'regexp
171 :group 'muse-regexp)
173 (defcustom muse-ignored-extensions-regexp
174 "\\.\\(bz2\\|gz\\|[Zz]\\)\\'"
175 "A regexp of extensions to omit from the ending of a Muse page name."
176 :type 'string
177 :group 'muse-regexp)
179 (provide 'muse-regexps)
181 ;;; muse-regexps.el ends here