2
|
1 ;;; w3-menu.el --- Menu functions for emacs-w3
|
0
|
2 ;; Author: wmperry
|
70
|
3 ;; Created: 1996/07/21 18:29:01
|
|
4 ;; Version: 1.7
|
0
|
5 ;; Keywords: menu, hypermedia
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
0
|
9 ;;;
|
|
10 ;;; This file is part of GNU Emacs.
|
|
11 ;;;
|
|
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
13 ;;; it under the terms of the GNU General Public License as published by
|
|
14 ;;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;;; any later version.
|
|
16 ;;;
|
|
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
|
|
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 ;;; GNU General Public License for more details.
|
|
21 ;;;
|
|
22 ;;; You should have received a copy of the GNU General Public License
|
70
|
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
24 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
0
|
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
26
|
|
27 (require 'w3-vars)
|
|
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
29 ;;; Spiffy new menus (for both Emacs and XEmacs)
|
|
30 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
31 (defvar w3-menu-fsfemacs-bookmark-menu nil)
|
|
32 (defvar w3-menu-fsfemacs-debug-menu nil)
|
|
33 (defvar w3-menu-fsfemacs-edit-menu nil)
|
|
34 (defvar w3-menu-fsfemacs-file-menu nil)
|
|
35 (defvar w3-menu-fsfemacs-go-menu nil)
|
|
36 (defvar w3-menu-fsfemacs-help-menu nil)
|
|
37 (defvar w3-menu-fsfemacs-view-menu nil)
|
|
38 (defvar w3-menu-fsfemacs-options-menu nil)
|
|
39 (defvar w3-menu-fsfemacs-style-menu nil)
|
|
40 (defvar w3-menu-w3-menubar nil)
|
|
41 (defvar w3-links-menu nil "Menu for w3-mode in XEmacs.")
|
|
42 (make-variable-buffer-local 'w3-links-menu)
|
|
43
|
70
|
44 (defvar w3-use-menus '(file edit view go bookmark options
|
|
45 buffers style emacs nil help)
|
0
|
46 "*Non-nil value causes W3 to provide a menu interface.
|
|
47 A value that is a list causes W3 to install its own menubar.
|
|
48 A value of 1 causes W3 to install a \"W3\" item in the Emacs menubar.
|
|
49
|
|
50 If the value of w3-use-menus is a list, it should be a list of symbols.
|
|
51 The symbols and the order that they are listed determine what menus
|
|
52 will be in the menubar and how they are ordered. Valid symbol values
|
|
53 are:
|
|
54
|
|
55 file -- A list of file related commands
|
|
56 edit -- Various standard editing commands (copy/paste)
|
|
57 view -- Controlling various things about the document view
|
|
58 go -- Navigation control
|
|
59 bookmark -- Bookmark / hotlist control
|
|
60 options -- Various options
|
|
61 buffers -- The standard buffers menu
|
|
62 emacs -- A toggle button to switch back to normal emacs menus
|
70
|
63 style -- Control fonts and who gets to set them
|
|
64 help -- The help
|
0
|
65 nil -- ** special **
|
|
66
|
|
67 If nil appears in the list, it should appear exactly once. All
|
|
68 menus after nil in the list will be displayed flushright in the
|
70
|
69 menubar.")
|
0
|
70
|
|
71 (defun w3-menu-hotlist-constructor (menu-items)
|
|
72 (or (cdr w3-html-bookmarks)
|
|
73 (let ((hot-menu nil)
|
|
74 (hot w3-hotlist))
|
|
75 (while hot
|
|
76 (setq hot-menu (cons (vector
|
|
77 (w3-truncate-menu-item (car (car hot)))
|
|
78 (list 'w3-fetch (car (cdr (car hot))))
|
|
79 t) hot-menu)
|
|
80 hot (cdr hot)))
|
70
|
81 (or hot-menu '(["No Hotlist" undefined nil])))))
|
0
|
82
|
|
83 (defun w3-menu-links-constructor (menu-items)
|
|
84 (or menu-items
|
|
85 (let ((widgets (w3-only-links))
|
|
86 widget href menu)
|
|
87 (while widgets
|
|
88 (setq widget (car widgets)
|
|
89 widgets (cdr widgets)
|
|
90 href (widget-get widget 'href)
|
|
91 menu (cons
|
|
92 (vector (w3-truncate-menu-item
|
70
|
93 (w3-fix-spaces
|
|
94 (buffer-substring
|
|
95 (widget-get widget :from)
|
|
96 (widget-get widget :to))))
|
0
|
97 (list 'url-maybe-relative href) t) menu)))
|
|
98 (setq menu (w3-breakup-menu menu w3-max-menu-length))
|
70
|
99 (or menu '(["No Links" undefined nil])))))
|
0
|
100
|
|
101 (defun w3-toggle-minibuffer ()
|
|
102 (interactive)
|
|
103 (cond
|
|
104 (w3-running-xemacs
|
70
|
105 (set-frame-property (selected-frame) 'minibuffer
|
|
106 (not (frame-property (selected-frame) 'minibuffer))))
|
0
|
107 (t nil)))
|
|
108
|
|
109 (defun w3-toggle-location ()
|
|
110 (interactive)
|
|
111 (cond
|
|
112 (w3-running-xemacs
|
|
113 (let ((on (specifier-instance has-modeline-p (selected-window))))
|
|
114 (set-specifier has-modeline-p (not on) (selected-window))))
|
|
115 (t nil)))
|
|
116
|
|
117 (defun w3-toggle-menubar ()
|
|
118 (interactive)
|
|
119 (cond
|
|
120 ;; XEmacs style
|
|
121 (w3-running-xemacs
|
2
|
122 (set-specifier menubar-visible-p (cons (current-buffer)
|
|
123 (not (specifier-instance
|
|
124 menubar-visible-p)))))
|
0
|
125 ;; Emacs 19 style
|
|
126 (t
|
|
127 (menu-bar-mode (if (w3-menubar-active) -1 1)))))
|
|
128
|
|
129 (defun w3-location-active ()
|
|
130 (if w3-running-xemacs
|
|
131 (specifier-instance has-modeline-p (selected-window))
|
|
132 t))
|
|
133
|
|
134 (defun w3-menubar-active ()
|
|
135 (if w3-running-xemacs
|
2
|
136 (and (featurep 'menubar) (specifier-instance menubar-visible-p))
|
0
|
137 (and (boundp 'menu-bar-mode) menu-bar-mode)))
|
|
138
|
|
139 (defun w3-menu-global-menubar ()
|
|
140 (if w3-running-xemacs
|
|
141 (default-value 'default-menubar)
|
|
142 (lookup-key (current-global-map) [menu-bar])))
|
|
143
|
|
144 (defconst w3-menu-file-menu
|
|
145 (list
|
|
146 "File"
|
|
147 ["Open Location..." w3-fetch t]
|
|
148 ["Open File..." w3-open-local t]
|
|
149 ["Open in New Window..." w3-fetch-other-frame t]
|
|
150 ["New Window" make-frame t]
|
|
151 "---"
|
|
152 ["Save" save-buffer t nil]
|
|
153 (list
|
|
154 "Save As..."
|
|
155 ["HTML" (w3-save-as "HTML Source") t]
|
|
156 ["Formatted Text" (w3-save-as "Formatted Text") t]
|
|
157 ["LaTeX" (w3-save-as "LaTeX Source") t]
|
|
158 ["PostScript" (w3-save-as "PostScript") t]
|
|
159 ["Binary" (w3-save-as "Binary") t]
|
|
160 )
|
|
161 "---"
|
|
162 (list
|
|
163 "Print As..."
|
|
164 ["PostScript" (w3-print-this-url nil "PostScript") t]
|
|
165 ["Formatted Text" (w3-print-this-url nil "Formatted Text") t]
|
|
166 ["HTML Source" (w3-print-this-url nil "HTML Source") t]
|
|
167 ["LaTeX'd" (w3-print-this-url nil "LaTeX'd") t]
|
|
168 )
|
|
169 (list
|
|
170 "Mail Document..."
|
|
171 ["HTML" (w3-mail-current-document nil "HTML Source") t]
|
|
172 ["Formatted Text" (w3-mail-current-document nil "Formatted Text") t]
|
|
173 ["PostScript" (w3-mail-current-document nil "PostScript") t]
|
|
174 ["LaTeX Source" (w3-mail-current-document nil "LaTeX Source") t]
|
|
175 )
|
70
|
176 ["Add Annotation" w3-annotation-add w3-personal-annotation-directory]
|
0
|
177 (if w3-running-xemacs
|
|
178 "---:shadowDoubleEtchedIn"
|
|
179 "---")
|
|
180 ["Close" delete-frame (not (eq (next-frame) (selected-frame)))]
|
|
181 ["Exit" save-buffers-kill-emacs t]
|
|
182 )
|
|
183 "W3 file menu list.")
|
|
184
|
|
185 (defconst w3-menu-edit-menu
|
|
186 (list
|
|
187 "Edit"
|
|
188 ["Undo" advertised-undo nil]
|
|
189 ["Cut" kill-region nil]
|
|
190 ["Copy" copy-region-as-kill t]
|
|
191 "----"
|
|
192 ["Search..." w3-search-forward t]
|
|
193 ["Search Again..." w3-search-again w3-last-search-item]
|
|
194 )
|
|
195 "W3 edit menu list.")
|
|
196
|
|
197 (defconst w3-menu-view-menu
|
|
198 (list
|
|
199 "View"
|
|
200 ["Document Information" w3-document-information t]
|
|
201 ["Document Source" w3-source-document t]
|
|
202 ["Load Images" w3-load-delayed-images w3-delayed-images]
|
|
203 "----"
|
|
204 ["Refresh" w3-refresh-buffer w3-current-parse]
|
|
205 ["Reload" w3-reload-document (and (url-view-url t)
|
|
206 (not (equal (url-view-url t) "")))]
|
|
207 "----"
|
|
208 ["Show URL" url-view-url t]
|
|
209 ["Show URL At Point" w3-view-this-url t]
|
|
210 "----"
|
|
211 )
|
|
212 "W3 menu view list.")
|
|
213
|
|
214 (defconst w3-menu-debug-menu
|
|
215 (list
|
|
216 "Debugging"
|
|
217 ["View Parse Tree" (w3-display-parse-tree w3-current-parse)
|
|
218 w3-current-parse]
|
|
219 ["View Stylesheet" w3-display-stylesheet w3-current-stylesheet]
|
|
220 )
|
|
221 "W3 menu debug list.")
|
|
222
|
|
223 (defconst w3-menu-go-menu
|
|
224 (list
|
|
225 "Go"
|
70
|
226 ["Forward" w3-forward-in-history t]
|
|
227 ["Backward" w3-backward-in-history t]
|
0
|
228 ["Home" w3 w3-default-homepage]
|
|
229 ["View History..." w3-show-history-list url-keep-history]
|
|
230 "----"
|
|
231 (if w3-running-xemacs
|
|
232 '("Links" :filter w3-menu-links-constructor)
|
70
|
233 ["Link..." w3-e19-show-links-menu t])
|
0
|
234 )
|
|
235 "W3 menu go list.")
|
|
236
|
|
237 (defconst w3-menu-bookmark-menu
|
|
238 (list
|
|
239 "Bookmark"
|
|
240 ["View Bookmarks..." w3-show-hotlist w3-hotlist]
|
|
241 ["Add Bookmark" w3-hotlist-add-document t]
|
|
242 ["Delete Bookmark" w3-hotlist-delete t]
|
|
243 ["Rename Bookmark" w3-hotlist-rename-entry t]
|
|
244 ["Append Bookmark List" w3-hotlist-append t]
|
|
245 "----"
|
|
246 (if w3-running-xemacs
|
|
247 '("Bookmarks" :filter w3-menu-hotlist-constructor)
|
|
248 ["Bookmarks" w3-e19-show-hotlist-menu t])
|
|
249 )
|
|
250 "W3 menu bookmark list.")
|
|
251
|
|
252 (defconst w3-menu-options-menu
|
|
253 (list "Options"
|
2
|
254 ["Edit Preferences" w3-preferences-edit t]
|
|
255 "---"
|
0
|
256 ["Show Menubar" w3-toggle-menubar
|
|
257 :style toggle :selected (w3-menubar-active)]
|
|
258 (if (and w3-running-xemacs (featurep 'toolbar))
|
|
259 ["Show Toolbar" w3-toggle-toolbar
|
|
260 :style toggle :selected (w3-toolbar-active)]
|
70
|
261 nil)
|
0
|
262 (if w3-running-xemacs
|
|
263 ["Show Location" w3-toggle-location
|
|
264 :style toggle :selected (w3-location-active)]
|
70
|
265 nil)
|
0
|
266 (if w3-running-xemacs
|
|
267 ["Show Status Bar" w3-toggle-minibuffer
|
70
|
268 :style toggle :selected nil]
|
|
269 nil)
|
0
|
270 ["Incremental Display"
|
|
271 (setq w3-do-incremental-display (not w3-do-incremental-display))
|
|
272 :style toggle :selected w3-do-incremental-display]
|
|
273 "----"
|
|
274 ["Auto Load Images"
|
|
275 (setq w3-delay-image-loads (not w3-delay-image-loads))
|
|
276 :style toggle :selected (not w3-delay-image-loads)]
|
|
277 ["Flush Image Cache" (setq w3-graphics-list nil) w3-graphics-list]
|
|
278 "----"
|
|
279 ["Download to disk" (setq w3-dump-to-disk (not w3-dump-to-disk))
|
|
280 :style toggle :selected w3-dump-to-disk]
|
|
281 ["Caching" (setq url-automatic-caching (not url-automatic-caching))
|
|
282 :style toggle :selected url-automatic-caching]
|
|
283 ["Use Cache Only"
|
|
284 (setq url-standalone-mode (not url-standalone-mode))
|
|
285 :style toggle :selected url-standalone-mode]
|
|
286 "----"
|
|
287 ["Save Options" w3-menu-save-options t]
|
|
288 )
|
|
289 "W3 menu options list.")
|
|
290
|
|
291 (defconst w3-menu-style-menu
|
|
292 (list
|
|
293 "Style"
|
|
294 ["Allow Document Stylesheets" (setq w3-honor-stylesheets
|
|
295 (not w3-honor-stylesheets))
|
|
296 :style toggle :selected w3-honor-stylesheets]
|
70
|
297 ["IE 3.0 Compatible Parsing" (setq w3-style-ie-compatibility
|
|
298 (not w3-style-ie-compatibility))
|
|
299 :style toggle :selected (and w3-honor-stylesheets
|
|
300 w3-style-ie-compatibility)]
|
0
|
301 ["Honor Color Requests" (setq w3-user-colors-take-precedence
|
|
302 (not w3-user-colors-take-precedence))
|
|
303 :style toggle :selected (not w3-user-colors-take-precedence)]
|
2
|
304 "---"
|
|
305 ["Reload Stylesheets" w3-refresh-stylesheets t]
|
0
|
306 )
|
|
307 "W3 menu style list.")
|
|
308
|
|
309 (defconst w3-menu-buffer-menu
|
|
310 (if w3-running-xemacs
|
|
311 '("Buffers"
|
|
312 :filter buffers-menu-filter
|
|
313 ["List All Buffers" list-buffers t]
|
|
314 "--!here")
|
|
315 nil)
|
|
316 "W3 menu buffer list.")
|
|
317
|
|
318 (defconst w3-menu-emacs-button
|
|
319 (vector
|
|
320 (if w3-running-xemacs "XEmacs" "Emacs") 'w3-menu-toggle-menubar t))
|
|
321
|
|
322 (defconst w3-menu-help-menu
|
|
323 (list
|
|
324 "Help"
|
|
325 ["About Emacs-w3" (w3-fetch "about:") t]
|
70
|
326 ["Manual" (w3-fetch (concat w3-documentation-root "w3_toc.html")) t]
|
0
|
327 "---"
|
|
328 ["Version Information..."
|
|
329 (w3-fetch
|
70
|
330 (concat w3-documentation-root "help_on_" w3-version-number ".html"))
|
0
|
331 t]
|
70
|
332 ["On Window" (w3-fetch (concat w3-documentation-root "help/window.html")) t]
|
|
333 ["On FAQ" (w3-fetch (concat w3-documentation-root"help/FAQ.html")) t]
|
0
|
334 "---"
|
|
335 ["Mail Developer(s)" w3-submit-bug t]
|
|
336 )
|
|
337 "W3 menu help list.")
|
|
338
|
|
339 (defvar w3-mode-menu-map nil)
|
|
340
|
|
341 (defun w3-menu-initialize-w3-mode-menu-map ()
|
|
342 (if (null w3-mode-menu-map)
|
|
343 (let ((map (make-sparse-keymap))
|
|
344 (dummy (make-sparse-keymap)))
|
|
345 (require 'easymenu)
|
|
346 ;; initialize all the w3-menu-fsfemacs-*-menu variables
|
|
347 ;; with the menus.
|
|
348 (easy-menu-define w3-menu-fsfemacs-bookmark-menu (list dummy) nil
|
|
349 w3-menu-bookmark-menu)
|
|
350 (easy-menu-define w3-menu-fsfemacs-debug-menu (list dummy) nil
|
|
351 w3-menu-debug-menu)
|
|
352 (easy-menu-define w3-menu-fsfemacs-edit-menu (list dummy) nil
|
|
353 w3-menu-edit-menu)
|
|
354 (easy-menu-define w3-menu-fsfemacs-file-menu (list dummy) nil
|
|
355 w3-menu-file-menu)
|
|
356 (easy-menu-define w3-menu-fsfemacs-go-menu (list dummy) nil
|
|
357 w3-menu-go-menu)
|
|
358 (easy-menu-define w3-menu-fsfemacs-help-menu (list dummy) nil
|
|
359 w3-menu-help-menu)
|
|
360 (easy-menu-define w3-menu-fsfemacs-view-menu (list dummy) nil
|
|
361 w3-menu-view-menu)
|
|
362 (easy-menu-define w3-menu-fsfemacs-options-menu (list dummy) nil
|
|
363 w3-menu-options-menu)
|
|
364 (easy-menu-define w3-menu-fsfemacs-style-menu (list dummy) nil
|
|
365 w3-menu-style-menu)
|
|
366
|
|
367 ;; block the global menubar entries in the map so that W3
|
|
368 ;; can take over the menubar if necessary.
|
|
369 (define-key map [rootmenu] (make-sparse-keymap))
|
|
370 (define-key map [rootmenu w3] (cons "W3" (make-sparse-keymap "W3")))
|
|
371 (define-key map [rootmenu w3 file] 'undefined)
|
|
372 (define-key map [rootmenu w3 files] 'undefined)
|
|
373 (define-key map [rootmenu w3 search] 'undefined)
|
|
374 (define-key map [rootmenu w3 edit] 'undefined)
|
|
375 (define-key map [rootmenu w3 options] 'undefined)
|
|
376 (define-key map [rootmenu w3 buffer] 'undefined)
|
|
377 (define-key map [rootmenu w3 tools] 'undefined)
|
|
378 (define-key map [rootmenu w3 help] 'undefined)
|
|
379 (define-key map [rootmenu w3 help-menu] 'undefined)
|
|
380 ;; now build W3's menu tree.
|
|
381 (let ((menu-alist
|
|
382 '(
|
|
383 (bookmark
|
|
384 (cons "Bookmark" w3-menu-fsfemacs-bookmark-menu))
|
|
385 (debug
|
|
386 (cons "Debug" w3-menu-fsfemacs-debug-menu))
|
|
387 (edit
|
|
388 (cons "Edit" w3-menu-fsfemacs-edit-menu))
|
|
389 (file
|
|
390 (cons "File" w3-menu-fsfemacs-file-menu))
|
|
391 (go
|
|
392 (cons "Go" w3-menu-fsfemacs-go-menu))
|
|
393 (help
|
|
394 (cons "Help" w3-menu-fsfemacs-help-menu))
|
|
395 (options
|
|
396 (cons "Options" w3-menu-fsfemacs-options-menu))
|
|
397 (view
|
|
398 (cons "View" w3-menu-fsfemacs-view-menu))
|
|
399 (style
|
|
400 (cons "Style" w3-menu-fsfemacs-style-menu))
|
|
401 (emacs
|
70
|
402 (cons "[Emacs]" 'w3-menu-toggle-menubar))))
|
0
|
403 cons
|
|
404 (vec (vector 'rootmenu 'w3 nil))
|
|
405 ;; menus appear in the opposite order that we
|
|
406 ;; define-key them.
|
|
407 (menu-list
|
|
408 (if (consp w3-use-menus)
|
|
409 (reverse w3-use-menus)
|
|
410 (list 'help nil 'emacs 'buffers 'options 'bookmark
|
|
411 'go 'view 'edit 'file))))
|
|
412 (while menu-list
|
|
413 (if (null (car menu-list))
|
|
414 nil;; no flushright support in FSF Emacs
|
|
415 (aset vec 2 (intern (concat "w3-menu-fsfemacs-"
|
|
416 (symbol-name
|
|
417 (car menu-list)) "-menu")))
|
|
418 (setq cons (assq (car menu-list) menu-alist))
|
|
419 (if cons
|
|
420 (define-key map vec (eval (car (cdr cons))))))
|
|
421 (setq menu-list (cdr menu-list))))
|
|
422 (setq w3-mode-menu-map map)
|
|
423 (run-hooks 'w3-menu-setup-hook))))
|
|
424
|
|
425 (defun w3-menu-make-xemacs-menubar ()
|
|
426 (let ((menu-alist
|
|
427 '((bookmark . w3-menu-bookmark-menu)
|
|
428 (style . w3-menu-style-menu)
|
|
429 (buffer . w3-menu-buffer-menu)
|
|
430 (debug . w3-menu-debug-menu)
|
|
431 (edit . w3-menu-edit-menu)
|
|
432 (emacs . w3-menu-emacs-button)
|
|
433 (file . w3-menu-file-menu)
|
|
434 (go . w3-menu-go-menu)
|
|
435 (help . w3-menu-help-menu)
|
|
436 (options . w3-menu-options-menu)
|
|
437 (view . w3-menu-view-menu)
|
|
438 )
|
|
439 )
|
|
440 cons
|
|
441 (menubar nil)
|
|
442 (menu-list w3-use-menus))
|
|
443 (while menu-list
|
|
444 (if (null (car menu-list))
|
|
445 (setq menubar (cons nil menubar))
|
|
446 (setq cons (assq (car menu-list) menu-alist))
|
|
447 (if cons
|
|
448 (setq menubar (cons (symbol-value (cdr cons)) menubar))))
|
|
449 (setq menu-list (cdr menu-list)))
|
|
450 (nreverse menubar)))
|
|
451
|
|
452 (defun w3-menu-install-menubar ()
|
|
453 (cond
|
|
454 (w3-running-xemacs
|
|
455 (if (not (featurep 'menubar))
|
|
456 nil ; No menus available
|
|
457 (setq w3-menu-w3-menubar (w3-menu-make-xemacs-menubar))
|
|
458 (set-buffer-menubar w3-menu-w3-menubar)))
|
|
459 ((not (fboundp 'vm-menu-undo-menu))
|
|
460 (w3-menu-initialize-w3-mode-menu-map)
|
|
461 (define-key w3-mode-map [menu-bar]
|
|
462 (lookup-key w3-mode-menu-map [rootmenu w3])))))
|
|
463
|
|
464 (defun w3-menu-install-menubar-item ()
|
|
465 (cond
|
|
466 (w3-running-xemacs
|
|
467 (if (not (featurep 'menubar))
|
|
468 nil ; No menus available
|
|
469 (set-buffer-menubar (copy-sequence (w3-menu-global-menubar)))
|
|
470 (add-menu nil "W3" (cdr w3-menu-w3-menubar))))
|
|
471 ((not (fboundp 'w3-menu-fsfemacs-edit-menu))
|
|
472 (w3-menu-initialize-w3-mode-menu-map)
|
|
473 (define-key w3-mode-map [menu-bar]
|
|
474 (lookup-key w3-mode-menu-map [rootmenu])))))
|
|
475
|
|
476 (defun w3-menu-install-menus ()
|
2
|
477 (cond ((= emacs-minor-version 28) ; Hey, get with the times people!!
|
|
478 nil)
|
|
479 ((consp w3-use-menus)
|
0
|
480 (w3-menu-install-menubar))
|
|
481 ((eq w3-use-menus 1)
|
|
482 (w3-menu-install-menubar-item))
|
|
483 (t nil)))
|
|
484
|
|
485 (defun w3-menu-set-menubar-dirty-flag ()
|
|
486 (cond (w3-running-xemacs
|
|
487 (set-menubar-dirty-flag))
|
|
488 (t
|
|
489 (force-mode-line-update))))
|
|
490
|
|
491 (defun w3-menu-toggle-menubar ()
|
|
492 (interactive)
|
|
493 (cond
|
|
494 ;;((eq w3-use-menus 1)
|
|
495 ;;nil)
|
|
496 (w3-running-xemacs
|
|
497 (if (null (car (find-menu-item current-menubar '("XEmacs"))))
|
|
498 (set-buffer-menubar w3-menu-w3-menubar)
|
|
499 (set-buffer-menubar (copy-sequence (w3-menu-global-menubar)))
|
|
500 (condition-case ()
|
|
501 (add-menu-button nil ["W3" w3-menu-toggle-menubar t] nil)
|
|
502 (void-function
|
|
503 (add-menu-item nil "W3" 'w3-menu-toggle-menubar t))))
|
|
504 (w3-menu-set-menubar-dirty-flag))
|
|
505 (t
|
|
506 (if (not (eq (lookup-key w3-mode-map [menu-bar])
|
|
507 (lookup-key w3-mode-menu-map [rootmenu w3])))
|
|
508 (define-key w3-mode-map [menu-bar]
|
|
509 (lookup-key w3-mode-menu-map [rootmenu w3]))
|
|
510 (define-key w3-mode-map [menu-bar]
|
|
511 (make-sparse-keymap))
|
|
512 (define-key w3-mode-map [menu-bar w3]
|
|
513 (cons "[W3]" 'w3-menu-toggle-menubar)))
|
|
514 (w3-menu-set-menubar-dirty-flag))))
|
|
515
|
|
516 (defun w3-menu-save-options ()
|
|
517 (interactive)
|
|
518 (let ((output-buffer (find-file-noselect w3-default-configuration-file))
|
|
519 output-marker)
|
|
520 (save-excursion
|
|
521 (set-buffer output-buffer)
|
|
522 ;;
|
|
523 ;; Find and delete the previously saved data, and position to write.
|
|
524 ;;
|
|
525 (goto-char (point-min))
|
|
526 (if (re-search-forward "^;; W3 Options Settings *\n" nil 'move)
|
|
527 (let ((p (match-beginning 0)))
|
|
528 (goto-char p)
|
|
529 (or (re-search-forward
|
|
530 "^;; End of W3 Options Settings *\\(\n\\|\\'\\)"
|
|
531 nil t)
|
|
532 (error "can't find END of saved state in .emacs"))
|
|
533 (delete-region p (match-end 0)))
|
|
534 (goto-char (point-max))
|
|
535 (insert "\n"))
|
|
536 (setq output-marker (point-marker))
|
|
537 (let ((print-readably t)
|
|
538 (print-escape-newlines t)
|
|
539 (standard-output output-marker))
|
|
540 (princ ";; W3 Options Settings\n")
|
|
541 (princ ";; ===================\n")
|
|
542 (mapcar (function
|
|
543 (lambda (var)
|
|
544 (princ " ")
|
|
545 (if (and (symbolp var) (boundp var))
|
|
546 (prin1 (list 'setq-default var
|
|
547 (let ((val (symbol-value var)))
|
|
548 (if (or (memq val '(t nil))
|
|
549 (and (not (symbolp val))
|
|
550 (not (listp val))))
|
|
551 val
|
|
552 (list 'quote val))))))
|
|
553 (if var (princ "\n"))))
|
|
554 '(
|
|
555 ps-print-color-p
|
|
556 url-automatic-caching
|
2
|
557 url-be-asynchronous
|
|
558 url-honor-refresh-requests
|
|
559 url-privacy-level
|
0
|
560 url-proxy-services
|
2
|
561 url-standalone-mode
|
70
|
562 url-use-hypertext-dired
|
2
|
563 url-use-hypertext-gopher
|
70
|
564 w3-color-filter
|
|
565 w3-color-use-reducing
|
0
|
566 w3-default-homepage
|
2
|
567 w3-default-stylesheet
|
|
568 w3-delay-image-loads
|
|
569 w3-do-incremental-display
|
|
570 w3-dump-to-disk
|
70
|
571 w3-file-done-hook
|
|
572 w3-file-prepare-hook
|
2
|
573 w3-honor-stylesheets
|
|
574 w3-image-mappings
|
|
575 w3-load-hook
|
|
576 w3-mode-hook
|
|
577 w3-netscape-compatible-comments
|
|
578 w3-preferences-cancel-hook
|
|
579 w3-preferences-default-hook
|
|
580 w3-preferences-ok-hook
|
|
581 w3-preferences-setup-hook
|
|
582 w3-source-file-hook
|
70
|
583 w3-style-ie-compatibility
|
0
|
584 w3-toolbar-orientation
|
2
|
585 w3-toolbar-type
|
|
586 w3-use-menus
|
|
587 w3-user-colors-take-precedence
|
0
|
588 )
|
|
589 )
|
|
590 (princ ";; ==========================\n")
|
|
591 (princ ";; End of W3 Options Settings\n")))
|
|
592 (set-marker output-marker nil)
|
|
593 (save-excursion
|
|
594 (set-buffer output-buffer)
|
|
595 (save-buffer))
|
|
596 ))
|
|
597
|
|
598 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
599 ;;; Context-sensitive popup menu
|
|
600 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
601 (if (not (fboundp 'event-glyph))
|
|
602 (fset 'event-glyph 'ignore))
|
|
603
|
|
604 (defun w3-popup-menu (e)
|
|
605 "Pop up a menu of common w3 commands"
|
|
606 (interactive "e")
|
70
|
607 (mouse-set-point e)
|
|
608 (let* ((glyph (event-glyph e))
|
|
609 (widget (or (and glyph (glyph-property glyph 'widget))
|
|
610 (widget-at (point))))
|
|
611 (href (and widget (widget-get widget 'href)))
|
|
612 (imag (and widget (widget-get widget 'src)))
|
|
613 (menu (copy-tree w3-popup-menu))
|
|
614 url val trunc-url)
|
|
615 (if href
|
|
616 (progn
|
|
617 (setq url href)
|
|
618 (if url (setq trunc-url (url-truncate-url-for-viewing
|
|
619 url
|
|
620 w3-max-menu-width)))
|
0
|
621 (setcdr menu (append (cdr menu)
|
70
|
622 '("---")
|
|
623 (mapcar
|
|
624 (function
|
|
625 (lambda (x)
|
|
626 (vector (format (car x) trunc-url)
|
|
627 (list (cdr x) url) t)))
|
|
628 w3-hyperlink-menu)))))
|
|
629 (if imag
|
|
630 (progn
|
|
631 (setq url imag
|
|
632 trunc-url (url-truncate-url-for-viewing url
|
|
633 w3-max-menu-width))
|
|
634 (setcdr menu (append (cdr menu)
|
|
635 '("---")
|
|
636 (mapcar
|
|
637 (function
|
|
638 (lambda (x)
|
|
639 (vector (format (car x) trunc-url)
|
|
640 (list (cdr x) url) t)))
|
|
641 w3-graphlink-menu)))))
|
|
642 (if (not (w3-menubar-active))
|
|
643 (setcdr menu (append (cdr menu)
|
|
644 '("---" ["Show Menubar" w3-toggle-menubar t]))))
|
|
645 (popup-menu menu)))
|
0
|
646
|
|
647 (provide 'w3-menu)
|