Initial Commit
[packages] / xemacs-packages / w3 / lisp / w3-cus.el
1 ;;; w3-cus.el --- Customization support for Emacs-W3
2 ;; Author: $Author: fx $
3 ;; Created: $Date: 2001/10/11 12:59:46 $
4 ;; Version: $Revision: 1.9 $
5 ;; Keywords: comm, help, hypermedia
6
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry <wmperry@cs.indiana.edu>
9 ;;; Copyright (c) 1996 - 1999 Free Software Foundation, Inc.
10 ;;;
11 ;;; This file is part of GNU Emacs.
12 ;;;
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;;; it under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 2, or (at your option)
16 ;;; any later version.
17 ;;;
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Emacs; see the file COPYING.  If not, write to the
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;;; Boston, MA 02111-1307, USA.
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28
29 (defgroup w3 '((url custom-group))
30   "Emacs-W3 - the web browser of choice."
31   :group 'hypermedia)
32
33 (defgroup w3-files nil
34   "Emacs-W3 configuration files."
35   :group 'w3
36   :prefix "w3-")
37
38 (defgroup w3-images nil
39   "Controlling image handling."
40   :group 'w3
41   :prefix "w3-")
42
43 (defgroup w3-printing nil
44   "Various options for hardcopy from web pages."
45   :group 'w3
46   :prefix "w3-")
47
48 (defgroup w3-menus nil
49   "The look of menus in Emacs-W3"
50   :group 'w3
51   :prefix "w3-")
52
53 (defgroup w3-parsing nil
54   "Options relating to HTML parsing"
55   :group 'w3
56   :prefix "w3-")
57
58 (defgroup w3-display nil
59   "Variables relating to how web pages are displayed."
60   :group 'w3
61   :prefix "w3-")
62
63 (defgroup w3-hooks nil
64   "Hooks relating to Emacs-W3."
65   :group 'w3
66   :prefix "w3-")
67
68 ;;; File related variables
69 (defcustom w3-configuration-directory "~/.w3/"
70   "Directory where Emacs-w3 can find its configuration files."
71   :group 'w3-files
72   :type 'directory)
73
74 (defcustom w3-default-configuration-file "profile"
75   "Base filename where per-user customizations are kept.
76 This filename is relative to `w3-configuration-directory' if
77 not fully specified."
78   :group 'w3-files
79   :type 'string)
80
81 (defcustom w3-default-homepage nil
82   "The url to open at startup.  It can be any valid URL.
83 This will default to the environment variable WWW_HOME if you do not
84 set it in your .emacs file.  If WWW_HOME is undefined, then it will
85 default to  the hypertext documentation for W3 at Indiana University."
86   :group 'w3-files
87   :type 'string)
88
89 (defcustom w3-default-stylesheet nil
90   "The filename of the users default stylesheet."
91   :group 'w3-files
92   :type '(choice (const :tag "None" :value nil)
93                  (file)))
94
95 (defcustom w3-hotlist-file nil
96   "*Hotlist filename.
97 This should be the name of a file that is stored in either
98 NCSA's Mosaic/X or Netscape/X format.  It is used to keep a listing
99 of commonly accessed URL's without having to go through 20 levels of
100 menus to get to them."
101   :group 'w3-files
102   :type 'file)
103
104 (defcustom w3-explicit-encodings-file nil
105   "Explicit encodings filename.
106 This should be the name of a file that is used to keep user-specified
107 explicit encodings for URLs."
108   :group 'w3-files
109   :type 'file)
110
111 (defcustom w3-documentation-root "http://www.cs.indiana.edu/elisp/w3/"
112   "Where the w3 documentation lives.  This MUST end in a slash."
113   :group 'w3-files
114   :type 'string)
115
116 ;;; Display related variables
117 (defcustom w3-display-frames t
118   "*Fetch frames - can be:
119 nil             no frame display whatsoever
120 'as-links       display frame hyperlinks, but do not fetch them
121 'ask            display frame hyperlinks and ask whether to fetch them
122 t               display frame hyperlinks and fetch them."
123   :group 'w3-display
124   :type '(choice (const :tag "Do not display frames" :value nil)
125                  (const :tag "Show hyperlinks" :value as-links)
126                  (const :tag "Show hyperlinks, ask whether to retrieve them" :value ask)
127                  (const :tag "Automatically retrieve frames" :value t)))
128
129 (defcustom w3-bullets
130   '((disc   . ?*)
131     (circle . ?o)
132     (square . ?#)
133     (none   . ? )
134     )
135   "An alist of unordered list types.
136 This maps to characters to use as the bullet character."
137   :group 'w3-display
138   :type '(repeat (cons :format "%v"
139                        (symbol :tag "Type")
140                        (character :tag "Character"))))
141
142 (defcustom w3-echo-link '(title url text name)
143   "*Whether to display the URL of a link when tabbing through links.
144 Value is a list of one or more of the following symbols:
145
146   url    == url of the target
147   text   == text of the link
148   title  == title attribute of the link
149   name   == name or id attribute of the link
150
151 If none of the information is available, nothing will be shown for the link
152 in menus, etc."
153   :group 'w3-display
154   :type '(set (const :tag "URL" :value url)
155               (const :tag "Link Text" :value text)
156               (const :tag "Title of the link as defined in the HTML tag"
157                      :value title)
158               (const :tag "Name of the link as defined in the HTML tag"
159                      :value name)))
160
161 (defcustom w3-horizontal-rule-char nil
162   "The character to use to create a horizontal rule.
163 Must be the character's code, not a string.  This character is
164 replicated across the screen to create a division.
165 If nil W3 will use a terminal graphic character if possible."
166   :group 'w3-display
167   :type '(choice (const :tag "Best possible" :value nil)
168                  (character)))
169
170 (defcustom w3-force-conversion-alist nil
171   "*An alist of URL host/filename regexps and coding systems to use for them."
172   :group 'w3-display
173   :type `(repeat (cons (string :tag "Host / filename")
174                        ;; Fixme: Emacs 21 has coding-system :type.
175                        (symbol :tag "Coding system" :value binary))))
176
177 ;;; these four variables control how w3-setup-terminal-chars works
178 (defcustom w3-use-terminal-characters nil
179   "*Use terminal graphics characters for drawing tables and rules if available."
180   :group 'w3-display
181   :type 'boolean)
182
183 (defcustom w3-use-terminal-characters-on-tty nil
184   "*Use terminal graphics characters for tables and rules even on a tty.
185 This triggers display bugs on both Emacs and XEmacs.
186 \(Though it's usually tolerable at least in Emacs.)"
187   :group 'w3-display
188   :type 'boolean)
189
190 (defcustom w3-use-terminal-glyphs nil
191   "*Use glyphs if possible rather than properties for terminal graphics characters.
192
193 Glyphs are probably more efficient but don't work with the most recent versions
194 of XEmacs and there are some cute tricks we can play with text-properties that
195 glyphs won't let us do. It may be possible someday to make XEmacs automagically
196 translate the characters back to ascii characters when pasted into another
197 buffer. (On the other hand, right now `w3-excise-terminal-characters' doesn't
198 work at all if we're using text-properties)."
199   :group 'w3-display
200   :type '(choice (const :tag "Use Glyphs" :value t)
201                  (const :tag "Use Text Properties" :value nil)))
202
203 (defcustom w3-use-unicode-table-characters nil
204   "*Non-nil means use Unicode box-drawing characters for tables if avilable.
205 This only works for Emacs 21.  You might wat to turn this off if your
206 Unicode font isn't available in appropriate sizes."
207   :group 'w3-display
208   :type 'boolean)
209
210 (defcustom w3-do-incremental-display nil
211   "*Non-nil means do incremental display of pages."
212   :group 'w3-display
213   :type 'boolean)
214
215 (defcustom w3-defined-link-types
216   ;; This is the HTML3.0 list (downcased) plus "made".
217   '("previous" "next" "up" "down" "home" "toc" "index" "glossary"
218     "copyright" "bookmark" "help" "made" "contents" "top")
219   ;; HTML 4 link types
220   ;; <URL:http://www.w3.org/TR/html401/types.html#type-links>:
221   ;; Alternate, Stylesheet, Start, Next, Prev, Contents, Index,
222   ;; Glossary, Copyright, Chapter, Section, Subsection, Appendix,
223   ;; Help, Bookmark
224   "A list of the (lower-case) names which have special significance.
225 The significance is when they are used as the values of REL or REV
226 attributes of <link> elements.  They will be presented on the toolbar
227 or the links menu, for instance."
228   :group 'w3-display
229   :type '(repeat string))
230
231 ;;; Parsing related variables
232 (defcustom w3-debug-html nil
233   "*Non-nil means to gripe about bad HTML."
234   :group 'w3-parsing
235   :type '(choice (const :tag "HTML Errors" :value t)
236                  (const :tag "Errors and stylistic issues" :value style)
237                  (const :tag "None" :value nil)))
238
239 (defcustom w3-debug-buffer "*HTML Debug*"
240   "Name of buffer to store debugging information in."
241   :group 'w3-parsing
242   :type 'string)
243
244 ;;; Image related variables
245 (defcustom w3-auto-image-alt 'w3-default-image-alt-func
246   "*Whether to create an alt attribute for an image that is missing it.
247 If nil, Emacs-W3 will not automatically create an ALT attribute.
248
249 If a string, it should be a string suitable for running through format,
250 with only one %s, which will be replaced with just the filename of the
251 graphic that is not loaded.
252
253 Otherwise, it is considered a function and is passed a single
254 argument, the filename of the graphic that is not loaded."
255   :group 'w3-images
256   :type '(choice (const :tag "None" :value nil)
257                  (const :tag "Default" :value "[IMAGE(%s)]")
258                  (string :tag "Format string")
259                  (sexp :tag "Function" :value nil)))
260
261 (defcustom w3-delay-image-loads (not (or (and (fboundp 'display-images-p)
262                                               (display-images-p))
263                                          (featurep 'gif)
264                                          (featurep 'jpeg)
265                                          (featurep 'imagick)
266                                          (featurep 'png)))
267   "*Non-nil means delay loading images, not automatically retrieve them."
268   :group 'w3-images
269   :type 'boolean)
270
271 (defcustom w3-image-mappings
272   '(
273     ("image/x-xbitmap"        . xbm)
274     ("image/xbitmap"          . xbm)
275     ("image/xbm"              . xbm)
276     ("image/jpeg"             . jpeg)
277     ("image/gif"              . gif)
278     ("image/png"              . png)
279     ("image/x-fax"            . g3fax)
280     ("image/x-raster"         . rast)
281     ("image/windowdump"       . xwd)
282     ("image/x-icon"           . icon)
283     ("image/portable-graymap" . pgm)
284     ("image/portable-pixmap"  . ppm)
285     ("image/x-pixmap"         . xpm)
286     ("image/x-xpixmap"        . xpm)
287     ("image/pict"             . pict)
288     ("image/x-rgb"            . sgi)
289     ("image/x-sgi"            . sgi)
290     ("image/x-macpaint"       . macpt)
291     ("image/x-targa"          . tga)
292     ("image/tiff"             . tiff)
293     )
294   "How to map MIME types to image types for the `image' package.
295 Each entry is a cons cell of MIME types and image-type symbols."
296   :group 'w3-images
297   :type '(repeat (cons :format "%v"
298                        (string :tag "MIME Type")
299                        (symbol :tag "Image type"))))
300
301 ;;; Menus
302 (defcustom w3-max-menu-length 35
303   "The maximum length of a pulldown menu.
304 This is the length before it will be split into smaller chunks, with
305 the first part as a submenu, followed by the rest of the menu."
306   :group 'w3-menus
307   :type 'integer)
308
309 (defcustom w3-max-menu-width 40
310   "*The maximum width of a pulldown menu choice."
311   :group 'w3-menus
312   :type 'integer)
313
314 ;;; Advanced stuff
315 (defcustom w3-modeline-format
316   '("  " ("W3"
317         (w3-netscape-emulation-minor-mode
318          " (NS)")
319         (w3-lynx-emulation-minor-mode
320          " (Lynx)")
321         ": "
322         (40 (-40 "%b"))
323         " "
324         (w3-current-isindex "[Searchable]  ")
325         (w3-current-badhtml "[BAD HTML]  ")
326         "%p" "  " global-mode-string))
327   "The modeline format string when in w3 mode."
328   :group 'w3-advanced
329   :type 'sexp)
330
331 (defcustom w3-netscape-compatible-comments nil
332   "*Whether to honor netscape-style <! > comments."
333   :group 'w3-parsing
334   :type 'boolean)
335
336 (defcustom w3-notify 'semibully
337   "*Selects the behavior when w3 page is ready.
338 This variable may have one of the following values:
339
340 newframe   -- put the w3 page in its own frame
341 bully      -- make the w3 page the current buffer and only window
342 semibully  -- make the w3 page the current buffer in the same window
343 aggressive -- make the w3 page the current buffer in the other window
344 friendly   -- display  w3page in other window but don't make current
345 polite     -- don't display w3 page, but prints message when ready (beeps)
346 quiet      -- like `polite', but don't beep
347 meek       -- make no indication that page is ready
348
349 Any other value of `w3-notify' is equivalent to `meek'."
350   :group 'w3-display
351   :type '(choice (const :tag "Display in a new frame"
352                         :value newframe)
353                  (const :tag "Display in the current window, select buffer, and kill other windows"
354                         :value bully)
355                  (const :tag "Display in the current window, select buffer"
356                         :value semibully)
357                  (const :tag "Display in another window, select buffer"
358                         :value aggressive)
359                  (const :tag "Display in another window, but do not select it"
360                         :value friendly)
361                  (const :tag "Do not display page, but show a message and beep"
362                         :value polite)
363                  (const :tag "Do not display page, but show a message (no beep)"
364                         :value quiet)
365                  (const :tag "Do not indicate that the page has been retrieved"
366                         :value meek)))
367
368 (defcustom w3-popup-menu-on-mouse-3 t
369   "*Non-nil value means W3 should provide context-sensitive menus on mouse-3.
370 A nil value means W3 should not change the binding of mouse-3."
371   :group 'w3-display
372   :type 'boolean)
373
374 (defcustom w3-reuse-buffers 'yes
375   "What to do when following a link will re-fetch a document.
376 This means a document that has already been fetched into a W3 buffer.
377 Possible values are: nil, `yes', and `no'.  Nil means ask the user if
378 we should reuse the buffer.  A value of 'yes means assume the user
379 wants us to reuse the buffer.  A value of 'no means assume the user
380 wants us to re-fetch the document.
381
382 This will also accept:
383 'no     ==> always reload
384 'yes    ==> always reuse
385 'ask    ==> always ask"
386   :group 'w3-display
387   :type '(choice (const :tag "Always reload" :value no)
388                  (const :tag "Always reuse" :value yes)
389                  (const :tag "Always ask" :value ask)))
390
391 (defcustom w3-right-margin 2
392   "*Default right margin for Emacs-W3 buffers.
393 This amount is subtracted from (window-width) for each new WWW buffer
394 and used as the new fill column."
395   :group 'w3-display
396   :type 'integer)
397
398 (defcustom w3-maximum-line-length nil
399   "*Maximum length of a line.
400 If nil, then lines can extend all the way to the window margin."
401   :group 'w3-display
402   :type '(radio (const :tag "Use all available space" :value nil)
403                 (integer :tag "Limit to")))
404
405 (defcustom w3-track-mouse t
406   "*Non-nil means track the mouse and message the url under the mouse."
407   :group 'w3-display
408   :type 'boolean)
409
410 (defcustom w3-honor-stylesheets nil
411   "*Whether to let a document specify a CSS stylesheet."
412   :group 'w3-display
413   :type 'boolean)
414
415 (defcustom w3-user-colors-take-precedence nil
416   "*Non-nil means don't let a document define certain colors itself.
417 Like foreground and background colors and pixmaps, color of links and
418 visited links, etc."
419   :group 'w3-display
420   :type 'boolean)
421
422 (defcustom w3-user-fonts-take-precedence nil
423   "*Non-nil means don't let a document define certain fonts.
424 Certain fonts can cause problems under Emacs."
425   :group 'w3-display
426   :type 'boolean)
427
428 ;;; Hook Variables
429 (defcustom w3-load-hook nil
430   "Hook run after loading w3."
431   :group 'w3-hooks
432   :type 'hook)
433
434 (defcustom w3-mode-hook nil
435   "Hook run after entering W3 mode."
436   :group 'w3-hooks
437   :type 'hook)
438
439 (defcustom w3-source-file-hook nil
440   "Hook run after getting document source."
441   :group 'w3-hooks
442   :type 'hook)
443
444 (defcustom w3-display-errors-hook nil
445   "Hook run after displaying HTML errors for a page."
446   :group 'w3-hooks
447   :type 'hook)
448
449 (defcustom w3-html-errors-font-lock-keywords
450   '(("\\(HTML errors for\\) \\(.*\\)"
451      (1 font-lock-function-name-face) (2 font-lock-reference-face))
452     ("Empty \\([A-Z0-9]+\\) element." (1 font-lock-type-face))
453     ("Bad attribute name syntax: \\(.*\\)" (1 font-lock-type-face))
454     ("Bad attribute value syntax: \\(.*\\)" (1 font-lock-type-face))
455     ("Evil attribute value syntax: \\(.*\\)" (1 font-lock-type-face))
456     ("Attribute value missing end quote: \\(.*\\)" (1 font-lock-type-face))
457     ("Bad start-tag \\([A-Z0-9]+\\)" (1 font-lock-type-face))
458     ("\\([A-Z0-9]+\\) element has no \\([A-Z0-9]+\\) attribute"
459      (1 font-lock-type-face) (2 font-lock-type-face))
460     (", inferring \\(</?[A-Z0-9]+>\\)" (1 font-lock-type-face))
461     ("Bad unclosed \\([A-Z0-9]+\\) tag" (1 font-lock-type-face))
462     ("Bad comment (unterminated or unbalanced \"\\(--\\)\" pairs)" (1 font-lock-type-face t))
463     ("Obsolete element \\(.*\\)" (1 font-lock-type-face))
464     ("Deprecated element \\(.*\\)" (1 font-lock-type-face))
465     ("\\[deprecated inside \\([A-Z0-9]+\\)\\]" (1 font-lock-type-face))
466     ("\\(</[A-Z0-9]+>\\) end-tag not omissible (required due to \\(</?[A-Z0-9]+>\\) end-tag)"
467      (1 font-lock-type-face) (2 font-lock-type-face))
468     ("Bad data characters [\\([^][]\\)], " (1 font-lock-comment-face))
469     ("Bad \\(<!\\) syntax." (1 font-lock-type-face))
470     ("Unterminated IGNORE marked section.")
471     ("Invalid SGML character: \\(.\\)" (1 font-lock-type-face))
472     ("Unmatched end-tag \\(</[A-Z0-9]+>\\)" (1 font-lock-type-face))
473     ;;("</?[A-Z0-9]+>" . font-lock-type-face)
474     ("^  [A-Z][a-zA-Z0-9 ]*: .*" . font-lock-comment-face)
475     ("^  [A-Z][a-zA-Z0-9 ]*: " . font-lock-comment-face)
476     ("\\*ERROR\\*" 0 font-lock-keyword-face t))
477   "Font locking keywords used for HTML error display."
478   :group 'w3
479   :type 'sexp)
480   
481 (provide 'w3-cus)