annotate lisp/w3/w3-e19.el @ 32:e04119814345 r19-15b99

Import from CVS: tag r19-15b99
author cvs
date Mon, 13 Aug 2007 08:52:56 +0200
parents 441bb1e64a06
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; w3-e19.el --- Emacs 19.xx specific functions for emacs-w3
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 26
diff changeset
3 ;; Created: 1997/03/12 20:07:18
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 26
diff changeset
4 ;; Version: 1.19
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: faces, help, mouse, hypermedia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry (wmperry@cs.indiana.edu)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Enhancements For Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (require 'w3-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'font)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
34 (require 'w3-script)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
35
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; Help menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
39 (defvar w3-e19-hotlist-menu nil "A menu for hotlists.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
40 (defvar w3-e19-links-menu nil "A buffer-local menu for hyperlinks.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
41 (defvar w3-e19-nav-menu nil "A buffer-local menu for html based <link> tags.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
42 (mapcar 'make-variable-buffer-local
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
43 '(w3-e19-hotlist-menu w3-e19-links-menu w3-e19-nav-menu))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; Functions to build menus of urls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
48 (defun w3-e19-show-hotlist-menu ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
49 (interactive)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
50 (let ((keymap (easy-menu-create-keymaps "Hotlist"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
51 (w3-menu-hotlist-constructor nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
52 (x nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
53 (y nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
54 (setq x (x-popup-menu t keymap)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
55 y (and x (lookup-key keymap (apply 'vector x))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
56 (if (and x y)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
57 (funcall y))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
59 (defun w3-e19-show-links-menu ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
60 (interactive)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (if (not w3-e19-links-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (w3-build-FSF19-menu))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
63 (let (x y)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
64 (setq x (x-popup-menu t w3-e19-links-menu)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
65 y (and x (lookup-key w3-e19-links-menu (apply 'vector x))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
66 (if (and x y)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
67 (funcall y))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
68
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
69 (defun w3-e19-show-navigate-menu ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
70 (interactive)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
71 (if (not w3-e19-nav-menu)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
72 (w3-build-FSF19-menu))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
73 (let (x y)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
74 (setq x (x-popup-menu t w3-e19-nav-menu)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
75 y (and x (lookup-key w3-e19-nav-menu (apply 'vector x))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (if (and x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (funcall y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun w3-build-FSF19-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; Build emacs19 menus from w3-links-list
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
81 (let ((links (w3-menu-html-links-constructor nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
82 (hlink (w3-menu-links-constructor nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
83 (setq w3-e19-nav-menu (easy-menu-create-keymaps "Navigate" links)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
84 w3-e19-links-menu (easy-menu-create-keymaps "Links" hlink))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defun w3-setup-version-specifics ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; Set up routine for emacs 19
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
88 (require 'lmenu) ; for popup-menu
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
89 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defun w3-store-in-clipboard (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 "Store string STR in the Xwindows clipboard"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ((memq (device-type) '(x pm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (x-select-text str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ((eq (device-type) 'ns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (ns-store-pasteboard-internal str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 26
diff changeset
100 (defun w3-e19-no-read-only (st nd)
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 26
diff changeset
101 ;; Make sure we don't yank any read-only data out of this buffer
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 26
diff changeset
102 (let ((inhibit-read-only t))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 26
diff changeset
103 (put-text-property st nd 'read-only nil)))
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 26
diff changeset
104
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defun w3-mode-version-specifics ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; Emacs 19 specific stuff for w3-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (make-local-variable 'track-mouse)
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 26
diff changeset
108 (set (make-local-variable 'buffer-access-fontify-functions) 'w3-e19-no-read-only)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
109 (if w3-track-mouse (setq track-mouse t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (defun w3-mouse-handler (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 "Function to message the url under the mouse cursor"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (let* ((pt (posn-point (event-start e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (good (eq (posn-window (event-start e)) (selected-window)))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
116 (mouse-events nil))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
117 (if (not (and good pt (number-or-marker-p pt)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
118 nil
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
119 (widget-echo-help pt)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
120 ;; Need to handle onmouseover, on mouseout
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
121 (setq mouse-events (w3-script-find-event-handlers pt 'mouse))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
122 (if (assq 'onmouseover mouse-events)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 16
diff changeset
123 (w3-script-evaluate-form (cdr (assq 'onmouseover mouse-events)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defun w3-color-values (color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ((eq window-system 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (x-color-values color))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
129 ((eq window-system 'pm)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
130 (pm-color-values color))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ((eq window-system 'ns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (ns-color-values color))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (defun w3-color-light-p (color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (let (colors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ((null window-system)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ((facep color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (setq color-or-face (face-background color-or-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (if (null color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (setq color-or-face (cdr-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (assq 'background-color (frame-parameters)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq colors (w3-color-values color-or-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ((stringp color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq colors (w3-color-values color-or-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ((font-rgb-color-p color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (setq colors (list (font-rgb-color-red color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (font-rgb-color-green color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (font-rgb-color-blue color-or-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (signal 'wrong-type-argument 'color-or-face-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (not (< (apply '+ colors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (/ (apply '+ (w3-color-values "white")) 3)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (provide 'w3-emacs19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (provide 'w3-e19)