Minor code cleanup to address elint issues.
[muse-el.git] / muse-regexps.el
blob0fe165041ed558cd09034cb711b1dcd2836e572a
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 "Options relating to regular expressions as used in publishing
58 and syntax highlighting."
59 :group 'muse)
61 (defcustom muse-regexp-blank
62 (if (muse-extreg-usable-p)
63 "[:blank:]"
64 " \t")
65 "Regexp to use in place of \"[:blank:]\".
66 This should be something that matches spaces and tabs.
68 It is like a regexp, but should be embeddable inside brackets.
69 Muse will detect the appropriate value correctly most of
70 the time."
71 :type 'string
72 :options '("[:blank:]" " \t")
73 :group 'muse-regexp)
75 (defcustom muse-regexp-space
76 (if (muse-extreg-usable-p)
77 "[:space:]"
78 " \t\n")
79 "Regexp to use in place of \"[:space:]\".
80 This should be something that matches spaces, tabs, and newlines.
82 It is like a regexp, but should be embeddable inside brackets.
83 muse will detect the appropriate value correctly most of
84 the time."
85 :type 'string
86 :options '("[:space:]" " \t\n")
87 :group 'muse-regexp)
89 (defcustom muse-regexp-alnum
90 (if (muse-extreg-usable-p)
91 "[:alnum:]"
92 "A-Za-z0-9")
93 "Regexp to use in place of \"[:alnum:]\".
94 This should be something that matches all letters and numbers.
96 It is like a regexp, but should be embeddable inside brackets.
97 muse will detect the appropriate value correctly most of
98 the time."
99 :type 'string
100 :options '("[:alnum:]" "A-Za-z0-9")
101 :group 'muse-regexp)
103 (defcustom muse-regexp-lower
104 (if (muse-extreg-usable-p)
105 "[:lower:]"
106 "a-z")
107 "Regexp to use in place of \"[:lower:]\".
108 This should match all lowercase characters.
110 It is like a regexp, but should be embeddable inside brackets.
111 muse will detect the appropriate value correctly most of
112 the time."
113 :type 'string
114 :options '("[:lower:]" "a-z")
115 :group 'muse-regexp)
117 (defcustom muse-regexp-upper
118 (if (muse-extreg-usable-p)
119 "[:upper:]"
120 "A-Z")
121 "Regexp to use in place of \"[:upper:]\".
122 This should match all uppercase characters.
124 It is like a regexp, but should be embeddable inside brackets.
125 muse will detect the appropriate value correctly most of
126 the time."
127 :type 'string
128 :options '("[:upper:]" "A-Z")
129 :group 'muse-regexp)
131 (defcustom muse-tag-regexp
132 (concat "<\\([^/" muse-regexp-space "][^" muse-regexp-space
133 "</>]*\\)\\(\\s-+[^<>]+[^</>]\\)?\\(/\\)?>")
134 "A regexp used to find XML-style tags within a buffer when publishing.
135 Group 1 should be the tag name, group 2 the properties, and group
136 3 the optional immediate ending slash."
137 :type 'regexp
138 :group 'muse-regexp)
140 (defcustom muse-link-regexp
141 "\\[\\[\\([^][\t\n]+\\)\\]\\(?:\\[\\([^][\n]+\\)\\]\\)?\\]"
142 "Regexp used to match [[target][description]] links.
143 Paren group 1 must match the URL, and paren group 2 the description."
144 :type 'regexp
145 :group 'muse-regexp)
147 (defcustom muse-url-regexp
148 (concat "\\<\\(?:https?:/?/?\\|ftp:/?/?\\|gopher://\\|"
149 "telnet://\\|wais://\\|file:/\\|s?news:\\|"
150 "mailto:\\)"
151 "[^] \n \"'()<>[^`{}]*[^] \n \"'()<>[^`{}.,;]+")
152 "A regexp used to match URLs within a Muse page."
153 :type 'regexp
154 :group 'muse-regexp)
156 (defcustom muse-file-regexp
157 "[/?]\\|\\.\\(html?\\|pdf\\|mp3\\|el\\|zip\\|txt\\|tar\\)\\(\\.\\(gz\\|bz2\\)\\)?\\'"
158 "A link matching this regexp will be regarded as a link to a file."
159 :type 'regexp
160 :group 'muse-regexp)
162 (defcustom muse-image-regexp
163 "\\.\\(eps\\|gif\\|jp\\(e?g\\)\\|p\\(bm\\|ng\\)\\|tiff\\|x\\([bp]m\\)\\)\\'"
164 "A link matching this regexp will be published inline as an image.
165 For example:
167 [[./wife.jpg][A picture of my wife]]
169 If you omit the description, the alt tag of the resulting HTML
170 buffer will be the name of the file."
171 :type 'regexp
172 :group 'muse-regexp)
174 (defcustom muse-ignored-extensions-regexp
175 "\\.\\(bz2\\|gz\\|[Zz]\\)\\'"
176 "A regexp of extensions to omit from the ending of a Muse page name."
177 :type 'string
178 :group 'muse-regexp)
180 (provide 'muse-regexps)
182 ;;; muse-regexps.el ends here