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