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