annotate lisp/w3/w3-e19.el @ 14:9ee227acff29 r19-15b90

Import from CVS: tag r19-15b90
author cvs
date Mon, 13 Aug 2007 08:48:42 +0200
parents ac2d302a0011
children 0293115a14e9
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
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
3 ;; Created: 1996/12/31 15:38:51
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
4 ;; Version: 1.12
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)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
9 ;;; Copyright (c) 1996 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)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Help menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
37 (defvar w3-e19-hotlist-menu nil "A menu for hotlists.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
38 (defvar w3-e19-links-menu nil "A buffer-local menu for hyperlinks.")
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
39 (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
40 (mapcar 'make-variable-buffer-local
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
41 '(w3-e19-hotlist-menu w3-e19-links-menu w3-e19-nav-menu))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; Functions to build menus of urls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
46 (defun w3-e19-show-hotlist-menu ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
47 (interactive)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
48 (let ((keymap (easy-menu-create-keymaps "Hotlist"
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
49 (w3-menu-hotlist-constructor nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
50 (x nil)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
51 (y nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
52 (setq x (x-popup-menu t keymap)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
53 y (and x (lookup-key keymap (apply 'vector x))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
54 (if (and x y)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
55 (funcall y))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
57 (defun w3-e19-show-links-menu ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
58 (interactive)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (if (not w3-e19-links-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (w3-build-FSF19-menu))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
61 (let (x y)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
62 (setq x (x-popup-menu t w3-e19-links-menu)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
63 y (and x (lookup-key w3-e19-links-menu (apply 'vector x))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
64 (if (and x y)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
65 (funcall y))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
66
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
67 (defun w3-e19-show-navigate-menu ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
68 (interactive)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
69 (if (not w3-e19-nav-menu)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
70 (w3-build-FSF19-menu))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
71 (let (x y)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
72 (setq x (x-popup-menu t w3-e19-nav-menu)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
73 y (and x (lookup-key w3-e19-nav-menu (apply 'vector x))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (if (and x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (funcall y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defun w3-build-FSF19-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; Build emacs19 menus from w3-links-list
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
79 (let ((links (w3-menu-html-links-constructor nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
80 (hlink (w3-menu-links-constructor nil)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
81 (setq w3-e19-nav-menu (easy-menu-create-keymaps "Navigate" links)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
82 w3-e19-links-menu (easy-menu-create-keymaps "Links" hlink))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun w3-setup-version-specifics ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; Set up routine for emacs 19
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
86 (require 'lmenu) ; for popup-menu
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
87 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defun w3-store-in-clipboard (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 "Store string STR in the Xwindows clipboard"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ((memq (device-type) '(x pm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (x-select-text str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ((eq (device-type) 'ns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (ns-store-pasteboard-internal str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defun w3-mode-version-specifics ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; Emacs 19 specific stuff for w3-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (make-local-variable 'track-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (if w3-track-mouse (setq track-mouse t))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
102 '(if (or (memq (device-type) '(x pm ns)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (w3-build-FSF19-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defun w3-mouse-handler (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "Function to message the url under the mouse cursor"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (let* ((pt (posn-point (event-start e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (good (eq (posn-window (event-start e)) (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (widget (and good pt (number-or-marker-p pt) (widget-at pt)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
111 (link (and widget (or (widget-get widget 'href)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
112 (widget-get widget 'name))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (form (and widget (widget-get widget 'w3-form-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (imag nil) ; (nth 1 (memq 'w3graphic props))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (cond
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
117 (link (w3-widget-echo widget))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ((eq 'submit (w3-form-element-type form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (message "Submit form to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (cdr-safe (assq 'action (w3-form-element-action form)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ((eq 'reset (w3-form-element-type form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (message "Reset form contents"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (message "Form entry (name=%s, type=%s)" (w3-form-element-name form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (w3-form-element-type form)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (imag (message "Inlined image (%s)" (car imag)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (t (message "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defun w3-color-values (color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ((eq window-system 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (x-color-values color))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
135 ((eq window-system 'pm)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136 (pm-color-values color))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ((eq window-system 'ns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (ns-color-values color))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defun w3-color-light-p (color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (let (colors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ((null window-system)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ((facep color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq color-or-face (face-background color-or-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if (null color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (setq color-or-face (cdr-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (assq 'background-color (frame-parameters)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (setq colors (w3-color-values color-or-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ((stringp color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq colors (w3-color-values color-or-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ((font-rgb-color-p color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq colors (list (font-rgb-color-red color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (font-rgb-color-green color-or-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (font-rgb-color-blue color-or-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (signal 'wrong-type-argument 'color-or-face-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (not (< (apply '+ colors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (/ (apply '+ (w3-color-values "white")) 3)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (provide 'w3-emacs19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (provide 'w3-e19)