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