2
|
1 ;;; w3-prefs.el --- Preferences panels for Emacs-W3
|
0
|
2 ;; Author: wmperry
|
30
|
3 ;; Created: 1997/03/04 14:33:41
|
|
4 ;; Version: 1.16
|
0
|
5 ;; Keywords: hypermedia, preferences
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
16
|
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
|
0
|
10 ;;;
|
14
|
11 ;;; This file is part of GNU Emacs.
|
0
|
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
|
14
|
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.
|
0
|
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
28
|
|
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
30 ;;; Preferences panels for Emacs-W3
|
|
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
32 (require 'w3-vars)
|
|
33 (require 'w3-keyword)
|
2
|
34 (require 'w3-toolbar)
|
14
|
35 (eval-and-compile
|
|
36 (require 'w3-widget))
|
0
|
37
|
|
38 (defvar w3-preferences-panel-begin-marker nil)
|
|
39 (defvar w3-preferences-panel-end-marker nil)
|
|
40 (defvar w3-preferences-panels '(
|
|
41 (appearance . "Appearance")
|
|
42 (images . "Images")
|
|
43 (cookies . "HTTP Cookies")
|
|
44 (hooks . "Various Hooks")
|
|
45 (compatibility . "Compatibility")
|
|
46 (proxy . "Proxy")))
|
|
47
|
|
48 (defun w3-preferences-generic-variable-callback (widget &rest ignore)
|
|
49 (condition-case ()
|
|
50 (set (widget-get widget 'variable) (widget-value widget))
|
|
51 (error (message "Invalid or incomplete data..."))))
|
|
52
|
|
53 (defun w3-preferences-restore-variables (vars)
|
|
54 (let ((temp nil))
|
|
55 (while vars
|
|
56 (setq temp (intern (format "w3-preferences-temp-%s" (car vars))))
|
|
57 (set (car vars) (symbol-value temp))
|
|
58 (setq vars (cdr vars)))))
|
|
59
|
|
60 (defun w3-preferences-create-temp-variables (vars)
|
|
61 (let ((temp nil))
|
|
62 (while vars
|
|
63 (setq temp (intern (format "w3-preferences-temp-%s" (car vars))))
|
|
64 (set (make-local-variable temp) (symbol-value (car vars)))
|
|
65 (setq vars (cdr vars)))))
|
|
66
|
|
67
|
|
68 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
69 ;;; Appearance of the frame / pages
|
|
70 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
71 (defun w3-preferences-init-appearance-panel ()
|
|
72 (let ((vars '(w3-toolbar-orientation
|
|
73 w3-use-menus
|
|
74 w3-honor-stylesheets
|
|
75 w3-default-stylesheet
|
|
76 w3-default-homepage
|
|
77 w3-toolbar-type))
|
|
78 (temp nil))
|
|
79 (set (make-local-variable 'w3-preferences-temp-use-home-page)
|
|
80 (and w3-default-homepage t))
|
|
81 (w3-preferences-create-temp-variables vars)))
|
|
82
|
|
83 (defun w3-preferences-create-appearance-panel ()
|
|
84 ;; First the toolbars
|
|
85 (widget-insert "\nToolbars\n--------\n")
|
|
86 (widget-insert "\tShow Toolbars as:\t")
|
|
87 (widget-put
|
|
88 (widget-create 'radio
|
|
89 :value (symbol-value 'w3-preferences-temp-w3-toolbar-type)
|
|
90 :notify 'w3-preferences-generic-variable-callback
|
14
|
91 :format "%v"
|
0
|
92 (list 'item :format "%t\t" :tag "Pictures" :value 'pictures)
|
|
93 (list 'item :format "%t\t" :tag "Text" :value 'text)
|
|
94 (list 'item :format "%t" :tag "Both" :value 'both))
|
|
95 'variable 'w3-preferences-temp-w3-toolbar-type)
|
|
96 (widget-insert "\n\tToolbars appear on ")
|
|
97 (widget-put
|
|
98 (widget-create 'choice
|
|
99 :value (symbol-value 'w3-preferences-temp-w3-toolbar-orientation)
|
|
100 :notify 'w3-preferences-generic-variable-callback
|
|
101 :format "%v"
|
|
102 :tag "Toolbar Position"
|
|
103 (list 'choice-item :format "%[%t%]" :tag "XEmacs Default" :value 'default)
|
|
104 (list 'choice-item :format "%[%t%]" :tag "Top" :value 'top)
|
|
105 (list 'choice-item :format "%[%t%]" :tag "Bottom" :value 'bottom)
|
|
106 (list 'choice-item :format "%[%t%]" :tag "Right" :value 'right)
|
|
107 (list 'choice-item :format "%[%t%]" :tag "Left" :value 'left)
|
|
108 (list 'choice-item :format "%[%t%]" :tag "No Toolbar" :value 'none))
|
|
109 'variable 'w3-preferences-temp-w3-toolbar-orientation)
|
|
110 (widget-insert " side of window.\n")
|
|
111
|
|
112 ;; Home page
|
|
113 (widget-insert "\nStartup\n--------\n\tBrowser starts with:\t")
|
|
114 (widget-put
|
|
115 (widget-create
|
|
116 'radio
|
14
|
117 :format "%v"
|
0
|
118 :value (symbol-value 'w3-preferences-temp-use-home-page)
|
|
119 :notify 'w3-preferences-generic-variable-callback
|
|
120 (list 'item :format "%t\t" :tag "Blank Page" :value nil)
|
|
121 (list 'item :format "%t" :tag "Home Page Location" :value t))
|
|
122 'variable 'w3-preferences-temp-use-home-page)
|
|
123 (widget-insert "\n\t\tURL: ")
|
|
124 (widget-put
|
|
125 (widget-create
|
14
|
126 'editable-field
|
0
|
127 :value (or (symbol-value 'w3-preferences-temp-w3-default-homepage) "None")
|
|
128 :notify 'w3-preferences-generic-variable-callback)
|
|
129 'variable 'w3-preferences-temp-w3-default-homepage)
|
|
130
|
|
131 ;; Stylesheet
|
|
132 (widget-insert "\nStyle\n--------\n\tDefault stylesheet:\t")
|
|
133 (widget-put
|
|
134 (widget-create
|
|
135 'file
|
|
136 :value (or (symbol-value 'w3-preferences-temp-w3-default-stylesheet) "")
|
|
137 :must-match t
|
|
138 :notify 'w3-preferences-generic-variable-callback)
|
|
139 'variable 'w3-preferences-temp-w3-default-stylesheet)
|
|
140 (widget-setup)
|
|
141 )
|
|
142
|
|
143 (defun w3-preferences-save-appearance-panel ()
|
|
144 (let ((vars '(w3-toolbar-orientation
|
|
145 w3-use-menus
|
|
146 w3-honor-stylesheets
|
|
147 w3-default-stylesheet
|
|
148 w3-toolbar-type))
|
|
149 (temp nil))
|
|
150 (if (symbol-value 'w3-preferences-temp-use-home-page)
|
|
151 (setq vars (cons 'w3-default-homepage vars))
|
|
152 (setq w3-default-homepage nil))
|
|
153 (w3-preferences-restore-variables vars)
|
|
154 (w3-toolbar-make-buttons)))
|
|
155
|
|
156
|
|
157 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
158 ;;; The images panel
|
|
159 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
160 (defun w3-preferences-init-images-panel ()
|
|
161 (let ((vars '(w3-delay-image-loads
|
|
162 w3-image-mappings)))
|
|
163 (w3-preferences-create-temp-variables vars)))
|
|
164
|
|
165 (defun w3-preferences-create-images-panel ()
|
|
166 (widget-insert "\n")
|
|
167 (widget-put
|
|
168 (widget-create
|
|
169 'checkbox
|
|
170 :notify 'w3-preferences-generic-variable-callback
|
|
171 :value (symbol-value 'w3-preferences-temp-w3-delay-image-loads))
|
|
172 'variable 'w3-preferences-temp-w3-delay-image-loads)
|
|
173 (widget-insert " Delay Image Loads\n"
|
|
174 ))
|
|
175
|
|
176 (defun w3-preferences-save-images-panel ()
|
|
177 (let ((vars '(w3-delay-image-loads
|
|
178 w3-image-mappings)))
|
|
179 (w3-preferences-restore-variables vars)))
|
|
180
|
|
181 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
182 ;;; The cookies panel
|
|
183 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
184 (defun w3-preferences-init-cookies-panel ()
|
|
185 (let ((cookies url-cookie-storage)
|
|
186 (secure-cookies url-cookie-secure-storage))
|
|
187 )
|
|
188 )
|
|
189
|
|
190 (defun w3-preferences-create-cookies-panel ()
|
|
191 (widget-insert "\n\t\tSorry, not yet implemented.\n\n"))
|
|
192
|
|
193 (defun w3-preferences-save-cookies-panel ()
|
|
194 )
|
|
195
|
|
196
|
|
197 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
198 ;;; The hooks panel
|
|
199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
200 (defvar w3-preferences-hooks-variables
|
30
|
201 '(w3-load-hook
|
0
|
202 w3-mode-hook
|
|
203 w3-preferences-cancel-hook
|
|
204 w3-preferences-default-hook
|
|
205 w3-preferences-ok-hook
|
|
206 w3-preferences-setup-hook
|
|
207 w3-source-file-hook))
|
|
208
|
|
209 (defun w3-preferences-init-hooks-panel ()
|
|
210 (w3-preferences-create-temp-variables w3-preferences-hooks-variables))
|
|
211
|
|
212 (defun w3-preferences-create-hooks-panel ()
|
|
213 (let ((todo w3-preferences-hooks-variables)
|
|
214 (cur nil)
|
|
215 (pt nil)
|
|
216 (doc nil))
|
|
217 (widget-insert "\n")
|
|
218 (while todo
|
|
219 (setq cur (car todo)
|
|
220 todo (cdr todo)
|
|
221 doc (get cur 'variable-documentation))
|
|
222 (if (string-match "^\\*" doc)
|
|
223 (setq doc (substring doc 1 nil)))
|
|
224 (setq pt (point))
|
|
225 (widget-insert "\n" (symbol-name cur) " - " doc)
|
|
226 (fill-region-as-paragraph pt (point))
|
|
227 (setq cur (intern (format "w3-preferences-temp-%s" cur)))
|
|
228 (widget-put
|
|
229 (widget-create
|
|
230 'sexp
|
|
231 :notify 'w3-preferences-generic-variable-callback
|
|
232 :value (or (symbol-value cur) "nil"))
|
|
233 'variable cur))
|
|
234 (widget-setup)))
|
|
235
|
|
236 (defun w3-preferences-save-hooks-panel ()
|
|
237 (w3-preferences-restore-variables w3-preferences-hooks-variables))
|
|
238
|
|
239
|
|
240 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
241 ;;; The compatibility panel
|
|
242 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
243 (defvar w3-preferences-compatibility-variables
|
|
244 '(
|
|
245 (w3-netscape-compatible-comments
|
|
246 . "Allow Netscape compatible comments")
|
|
247 (w3-user-colors-take-precedence
|
|
248 . "Ignore netscape document color control")
|
|
249 (url-honor-refresh-requests
|
|
250 . "Allow Netscape `Client Pull'"))
|
|
251 "A list of variables that the preferences compability pane knows about.")
|
|
252
|
|
253 (defun w3-preferences-init-compatibility-panel ()
|
|
254 (let ((compat w3-preferences-compatibility-variables)
|
|
255 (cur nil)
|
|
256 (var nil))
|
|
257 (w3-preferences-create-temp-variables
|
|
258 (mapcar 'car w3-preferences-compatibility-variables))))
|
|
259
|
|
260 (defun w3-preferences-create-compatibility-panel ()
|
|
261 (let ((compat w3-preferences-compatibility-variables)
|
|
262 (cur nil)
|
|
263 (var nil))
|
|
264 (widget-insert "\n")
|
|
265 (while compat
|
|
266 (setq cur (car compat)
|
|
267 compat (cdr compat)
|
|
268 var (intern (format "w3-preferences-temp-%s" (car cur))))
|
|
269 (widget-put
|
|
270 (widget-create 'checkbox
|
|
271 :notify 'w3-preferences-generic-variable-callback
|
|
272 :value (symbol-value var))
|
|
273 'variable var)
|
|
274 (widget-insert " " (cdr cur) "\n\n"))
|
|
275 (widget-setup)))
|
|
276
|
|
277 (defun w3-preferences-save-compatibility-panel ()
|
|
278 (w3-preferences-restore-variables
|
|
279 (mapcar 'car w3-preferences-compatibility-variables)))
|
|
280
|
|
281
|
|
282 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
283 ;;; The proxy configuration panel
|
|
284 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
285 (defun w3-preferences-init-proxy-panel ()
|
|
286 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
287 (proxy nil)
|
|
288 (host-var nil)
|
|
289 (port-var nil)
|
|
290 (urlobj nil))
|
|
291 (widget-insert "\n")
|
|
292 (while proxies
|
|
293 (setq proxy (car proxies)
|
|
294 proxies (cdr proxies)
|
|
295 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
296 port-var (intern (format "w3-%s-proxy-port" (downcase proxy)))
|
|
297 urlobj (url-generic-parse-url
|
|
298 (cdr-safe
|
|
299 (assoc (downcase proxy) url-proxy-services))))
|
|
300 (set (make-local-variable host-var) (or (url-host urlobj) ""))
|
|
301 (set (make-local-variable port-var) (or (url-port urlobj) "")))))
|
|
302
|
|
303 (defun w3-preferences-create-proxy-panel ()
|
|
304 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
305 (proxy nil)
|
|
306 (host-var nil)
|
|
307 (port-var nil)
|
|
308 (urlobj nil))
|
|
309 (widget-insert "\n")
|
|
310 (while proxies
|
|
311 (setq proxy (car proxies)
|
|
312 proxies (cdr proxies)
|
|
313 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
314 port-var (intern (format "w3-%s-proxy-port" (downcase proxy))))
|
|
315 (widget-insert (format "%10s Proxy: " proxy))
|
|
316 (widget-put
|
14
|
317 (widget-create 'editable-field
|
0
|
318 :size 20
|
|
319 :value-face 'underline
|
|
320 :notify 'w3-preferences-generic-variable-callback
|
|
321 :value (format "%-20s" (symbol-value host-var)))
|
|
322 'variable host-var)
|
|
323 (widget-insert " Port: ")
|
|
324 (widget-put
|
14
|
325 (widget-create 'editable-field
|
0
|
326 :size 5
|
|
327 :value-face 'underline
|
|
328 :notify 'w3-preferences-generic-variable-callback
|
|
329 :value (format "%5s" (symbol-value port-var)))
|
|
330 'variable port-var)
|
|
331 (widget-insert "\n\n"))
|
|
332 (widget-setup)))
|
|
333
|
|
334 (defun w3-preferences-save-proxy-panel ()
|
|
335 (let ((proxies '("FTP" "Gopher" "HTTP" "Security" "WAIS" "SHTTP" "News"))
|
|
336 (proxy nil)
|
|
337 (host-var nil)
|
|
338 (port-var nil)
|
|
339 (urlobj nil)
|
|
340 (host nil)
|
|
341 (port nil)
|
|
342 (new-proxy-services nil))
|
|
343 (while proxies
|
|
344 (setq proxy (car proxies)
|
|
345 proxies (cdr proxies)
|
|
346 host-var (intern (format "w3-%s-proxy-host" (downcase proxy)))
|
|
347 port-var (intern (format "w3-%s-proxy-port" (downcase proxy)))
|
|
348 urlobj (url-generic-parse-url
|
|
349 (cdr-safe
|
|
350 (assoc (downcase proxy) url-proxy-services)))
|
|
351 host (symbol-value host-var)
|
|
352 port (symbol-value port-var))
|
|
353 (if (and host (/= 0 (length host)))
|
|
354 (setq new-proxy-services (cons (cons (downcase proxy)
|
|
355 (format "http://%s:%s/" host
|
|
356 (or port "80")))
|
|
357 new-proxy-services))))
|
|
358 (setq url-proxy-services new-proxy-services)))
|
|
359
|
|
360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
361 ;;;
|
|
362 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
363 (defun w3-preferences-create-panel (panel)
|
|
364 (let ((func (intern (format "w3-preferences-create-%s-panel" panel)))
|
|
365 (inhibit-read-only t))
|
|
366 (goto-char w3-preferences-panel-begin-marker)
|
|
367 (delete-region w3-preferences-panel-begin-marker
|
|
368 w3-preferences-panel-end-marker)
|
|
369 (set-marker-insertion-type w3-preferences-panel-end-marker t)
|
|
370 (if (fboundp func)
|
|
371 (funcall func)
|
|
372 (insert (format "You should be seeing %s right now.\n" panel))))
|
|
373 (set-marker-insertion-type w3-preferences-panel-end-marker nil)
|
|
374 (set-marker w3-preferences-panel-end-marker (point))
|
|
375 (goto-char w3-preferences-panel-begin-marker)
|
|
376 (condition-case ()
|
|
377 (widget-forward 1)
|
|
378 (error nil)))
|
|
379
|
|
380 (defun w3-preferences-notify (widget widget-ignore &optional event)
|
|
381 (let* ((glyph (and event w3-running-xemacs (event-glyph event)))
|
14
|
382 (x (and glyph (widget-glyphp glyph) (event-glyph-x-pixel event)))
|
|
383 (y (and glyph (widget-glyphp glyph) (event-glyph-y-pixel event)))
|
0
|
384 (map (widget-get widget 'usemap))
|
|
385 (value (widget-value widget)))
|
|
386 (if (and map x y)
|
|
387 (setq value (w3-point-in-map (vector x y) map)))
|
|
388 (if value
|
|
389 (w3-preferences-create-panel value))))
|
|
390
|
|
391 (defun w3-preferences-save-options ()
|
|
392 (w3-menu-save-options))
|
|
393
|
|
394 (defun w3-preferences-ok-callback (widget &rest ignore)
|
|
395 (let ((panels w3-preferences-panels)
|
|
396 (buffer (current-buffer))
|
|
397 (func nil))
|
|
398 (run-hooks 'w3-preferences-ok-hook)
|
|
399 (while panels
|
|
400 (setq func (intern
|
|
401 (format "w3-preferences-save-%s-panel" (caar panels)))
|
|
402 panels (cdr panels))
|
|
403 (if (fboundp func)
|
|
404 (funcall func)))
|
|
405 (w3-preferences-save-options)
|
|
406 (message "Options saved")
|
|
407 (sit-for 1)
|
|
408 (kill-buffer (current-buffer))))
|
|
409
|
|
410 (defun w3-preferences-reset-all-panels ()
|
|
411 (let ((panels w3-preferences-panels)
|
|
412 (func nil))
|
|
413 (while panels
|
|
414 (setq func (intern (format "w3-preferences-init-%s-panel"
|
|
415 (caar panels)))
|
|
416 panels (cdr panels))
|
|
417 (if (and func (fboundp func))
|
|
418 (funcall func)))))
|
|
419
|
|
420 (defun w3-preferences-cancel-callback (widget &rest ignore)
|
|
421 (if (not (funcall url-confirmation-func "Cancel and lose all changes? "))
|
|
422 (error "Not cancelled!"))
|
|
423 (w3-preferences-reset-all-panels)
|
|
424 (kill-buffer (current-buffer))
|
|
425 (run-hooks 'w3-preferences-cancel-hook))
|
|
426
|
|
427 (defun w3-preferences-reset-callback (widget &rest ignore)
|
|
428 (w3-preferences-reset-all-panels)
|
|
429 (run-hooks 'w3-preferences-default-hook)
|
|
430 (w3-preferences-create-panel (caar w3-preferences-panels)))
|
|
431
|
|
432 (defvar w3-preferences-setup-hook nil
|
|
433 "*Hooks to be run before setting up the preferences buffer.")
|
|
434
|
|
435 (defvar w3-preferences-cancel-hook nil
|
|
436 "*Hooks to be run when cancelling the preferences (Cancel was chosen).")
|
|
437
|
|
438 (defvar w3-preferences-default-hook nil
|
|
439 "*Hooks to be run when resetting preference defaults (Defaults was chosen).")
|
|
440
|
|
441 (defvar w3-preferences-ok-hook nil
|
|
442 "*Hooks to be run before saving the preferences (OK was chosen).")
|
|
443
|
|
444 (defun w3-preferences-init-all-panels ()
|
|
445 (let ((todo w3-preferences-panels)
|
|
446 (func nil))
|
|
447 (while todo
|
|
448 (setq func (intern (format "w3-preferences-init-%s-panel" (caar todo)))
|
|
449 todo (cdr todo))
|
|
450 (and (fboundp func) (funcall func)))))
|
|
451
|
16
|
452 ;;###autoload
|
0
|
453 (defun w3-preferences-edit ()
|
|
454 (interactive)
|
|
455 (let* ((prefs-buffer (get-buffer-create "W3 Preferences"))
|
|
456 (widget nil)
|
|
457 (inhibit-read-only t)
|
|
458 (window-conf (current-window-configuration)))
|
|
459 (delete-other-windows)
|
|
460 (set-buffer prefs-buffer)
|
|
461 (w3-preferences-init-all-panels)
|
|
462 (set-window-buffer (selected-window) prefs-buffer)
|
|
463 (make-local-variable 'widget-field-face)
|
|
464 (setq w3-preferences-panel-begin-marker (make-marker)
|
|
465 w3-preferences-panel-end-marker (make-marker))
|
|
466 (set-marker-insertion-type w3-preferences-panel-begin-marker nil)
|
|
467 (set-marker-insertion-type w3-preferences-panel-end-marker t)
|
|
468 (use-local-map widget-keymap)
|
|
469 (erase-buffer)
|
|
470 (run-hooks 'w3-preferences-setup-hook)
|
30
|
471 (setq widget (apply 'widget-create 'menu-choice
|
|
472 :tag "Panel"
|
|
473 :notify 'w3-preferences-notify
|
|
474 :value 'appearance
|
|
475 (mapcar
|
|
476 (function
|
|
477 (lambda (x)
|
|
478 (list 'choice-item
|
|
479 :format "%[%t%]"
|
|
480 :tag (cdr x)
|
|
481 :value (car x))))
|
|
482 w3-preferences-panels)))
|
0
|
483 (goto-char (point-max))
|
|
484 (insert "\n\n")
|
|
485 (set-marker w3-preferences-panel-begin-marker (point))
|
|
486 (set-marker w3-preferences-panel-end-marker (point))
|
|
487 (w3-preferences-create-panel (caar w3-preferences-panels))
|
|
488 (goto-char (point-max))
|
|
489 (widget-insert "\n\n")
|
14
|
490 (widget-create 'push-button
|
0
|
491 :notify 'w3-preferences-ok-callback
|
|
492 :value "Ok")
|
|
493 (widget-insert " ")
|
14
|
494 (widget-create 'push-button
|
0
|
495 :notify 'w3-preferences-cancel-callback
|
|
496 :value "Cancel")
|
|
497 (widget-insert " ")
|
14
|
498 (widget-create 'push-button
|
0
|
499 :notify 'w3-preferences-reset-callback
|
|
500 :value "Reset")
|
|
501 (center-region (point-min) w3-preferences-panel-begin-marker)
|
|
502 (center-region w3-preferences-panel-end-marker (point-max))))
|
|
503
|
|
504 (provide 'w3-prefs)
|