2
|
1 ;;; w3-e19.el --- Emacs 19.xx specific functions for emacs-w3
|
0
|
2 ;; Author: wmperry
|
26
|
3 ;; Created: 1997/02/18 23:32:51
|
|
4 ;; Version: 1.18
|
0
|
5 ;; Keywords: faces, help, mouse, hypermedia
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
8 ;;; Copyright (c) 1993 - 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
30 ;;; Enhancements For Emacs 19
|
|
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
32 (require 'w3-forms)
|
|
33 (require 'font)
|
26
|
34 (require 'w3-script)
|
|
35
|
0
|
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
37 ;;; Help menu
|
|
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
14
|
39 (defvar w3-e19-hotlist-menu nil "A menu for hotlists.")
|
|
40 (defvar w3-e19-links-menu nil "A buffer-local menu for hyperlinks.")
|
|
41 (defvar w3-e19-nav-menu nil "A buffer-local menu for html based <link> tags.")
|
|
42 (mapcar 'make-variable-buffer-local
|
|
43 '(w3-e19-hotlist-menu w3-e19-links-menu w3-e19-nav-menu))
|
0
|
44
|
|
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
46 ;;; Functions to build menus of urls
|
|
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
14
|
48 (defun w3-e19-show-hotlist-menu ()
|
|
49 (interactive)
|
|
50 (let ((keymap (easy-menu-create-keymaps "Hotlist"
|
|
51 (w3-menu-hotlist-constructor nil)))
|
|
52 (x nil)
|
|
53 (y nil))
|
|
54 (setq x (x-popup-menu t keymap)
|
|
55 y (and x (lookup-key keymap (apply 'vector x))))
|
|
56 (if (and x y)
|
|
57 (funcall y))))
|
0
|
58
|
14
|
59 (defun w3-e19-show-links-menu ()
|
|
60 (interactive)
|
0
|
61 (if (not w3-e19-links-menu)
|
|
62 (w3-build-FSF19-menu))
|
14
|
63 (let (x y)
|
|
64 (setq x (x-popup-menu t w3-e19-links-menu)
|
|
65 y (and x (lookup-key w3-e19-links-menu (apply 'vector x))))
|
|
66 (if (and x y)
|
|
67 (funcall y))))
|
|
68
|
|
69 (defun w3-e19-show-navigate-menu ()
|
|
70 (interactive)
|
|
71 (if (not w3-e19-nav-menu)
|
|
72 (w3-build-FSF19-menu))
|
|
73 (let (x y)
|
|
74 (setq x (x-popup-menu t w3-e19-nav-menu)
|
|
75 y (and x (lookup-key w3-e19-nav-menu (apply 'vector x))))
|
0
|
76 (if (and x y)
|
|
77 (funcall y))))
|
|
78
|
|
79 (defun w3-build-FSF19-menu ()
|
|
80 ;; Build emacs19 menus from w3-links-list
|
14
|
81 (let ((links (w3-menu-html-links-constructor nil))
|
|
82 (hlink (w3-menu-links-constructor nil)))
|
|
83 (setq w3-e19-nav-menu (easy-menu-create-keymaps "Navigate" links)
|
|
84 w3-e19-links-menu (easy-menu-create-keymaps "Links" hlink))))
|
0
|
85
|
|
86 (defun w3-setup-version-specifics ()
|
|
87 ;; Set up routine for emacs 19
|
14
|
88 (require 'lmenu) ; for popup-menu
|
|
89 )
|
0
|
90
|
|
91 (defun w3-store-in-clipboard (str)
|
|
92 "Store string STR in the Xwindows clipboard"
|
|
93 (cond
|
|
94 ((memq (device-type) '(x pm))
|
|
95 (x-select-text str))
|
|
96 ((eq (device-type) 'ns)
|
|
97 (ns-store-pasteboard-internal str))
|
|
98 (t nil)))
|
|
99
|
|
100 (defun w3-mode-version-specifics ()
|
|
101 ;; Emacs 19 specific stuff for w3-mode
|
|
102 (make-local-variable 'track-mouse)
|
26
|
103 (if w3-track-mouse (setq track-mouse t)))
|
0
|
104
|
|
105 (defun w3-mouse-handler (e)
|
|
106 "Function to message the url under the mouse cursor"
|
|
107 (interactive "e")
|
|
108 (let* ((pt (posn-point (event-start e)))
|
|
109 (good (eq (posn-window (event-start e)) (selected-window)))
|
26
|
110 (mouse-events nil))
|
|
111 (if (not (and good pt (number-or-marker-p pt)))
|
|
112 nil
|
|
113 (widget-echo-help pt)
|
|
114 ;; Need to handle onmouseover, on mouseout
|
|
115 (setq mouse-events (w3-script-find-event-handlers pt 'mouse))
|
|
116 (if (assq 'onmouseover mouse-events)
|
|
117 (w3-script-evaluate-form (cdr (assq 'onmouseover mouse-events)))))))
|
0
|
118
|
|
119 (defun w3-color-values (color)
|
|
120 (cond
|
|
121 ((eq window-system 'x)
|
|
122 (x-color-values color))
|
2
|
123 ((eq window-system 'pm)
|
|
124 (pm-color-values color))
|
0
|
125 ((eq window-system 'ns)
|
|
126 (ns-color-values color))
|
|
127 (t nil)))
|
|
128
|
|
129 (defun w3-color-light-p (color-or-face)
|
|
130 (let (colors)
|
|
131 (cond
|
|
132 ((null window-system)
|
|
133 nil)
|
|
134 ((facep color-or-face)
|
|
135 (setq color-or-face (face-background color-or-face))
|
|
136 (if (null color-or-face)
|
|
137 (setq color-or-face (cdr-safe
|
|
138 (assq 'background-color (frame-parameters)))))
|
|
139 (setq colors (w3-color-values color-or-face)))
|
|
140 ((stringp color-or-face)
|
|
141 (setq colors (w3-color-values color-or-face)))
|
|
142 ((font-rgb-color-p color-or-face)
|
|
143 (setq colors (list (font-rgb-color-red color-or-face)
|
|
144 (font-rgb-color-green color-or-face)
|
|
145 (font-rgb-color-blue color-or-face))))
|
|
146 (t
|
|
147 (signal 'wrong-type-argument 'color-or-face-p)))
|
|
148 (not (< (apply '+ colors)
|
|
149 (/ (apply '+ (w3-color-values "white")) 3)))))
|
|
150
|
|
151
|
|
152
|
|
153 (provide 'w3-emacs19)
|
|
154 (provide 'w3-e19)
|