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
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
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.
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 (defun muse-extreg-usable-p ()
38 "Return non-nil if extended character classes can be used,
41 This is used when deciding the initial values of the muse-regexp
44 (string-match "^[0-9]+\\.[0-9]+\\.\\([0-9]+\\)"
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
)
56 (defgroup muse-regexp nil
57 "Regular expressions used in publishing and syntax highlighting."
60 (defcustom muse-regexp-blank
61 (if (muse-extreg-usable-p)
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
71 :options
'("[:blank:]" " \t")
74 (defcustom muse-regexp-space
75 (if (muse-extreg-usable-p)
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
85 :options
'("[:space:]" " \t\n")
88 (defcustom muse-regexp-alnum
89 (if (muse-extreg-usable-p)
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
99 :options
'("[:alnum:]" "A-Za-z0-9")
102 (defcustom muse-regexp-lower
103 (if (muse-extreg-usable-p)
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
113 :options
'("[:lower:]" "a-z")
116 (defcustom muse-regexp-upper
117 (if (muse-extreg-usable-p)
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
127 :options
'("[:upper:]" "A-Z")
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."
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."
146 (defcustom muse-url-regexp
147 (concat "\\<\\(?:https?:/?/?\\|ftp:/?/?\\|gopher://\\|"
148 "telnet://\\|wais://\\|file:/\\|s?news:\\|"
150 "[^] \n \"'()<>[^`{}]*[^] \n \"'()<>[^`{}.,;]+")
151 "A regexp used to match URLs within a Muse page."
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."
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.
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."
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."
179 (provide 'muse-regexps
)
181 ;;; muse-regexps.el ends here