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