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