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