annotate lisp/w3/w3-e19.el @ 138:6608ceec7cf8 r20-2b3

Import from CVS: tag r20-2b3
author cvs
date Mon, 13 Aug 2007 09:31:46 +0200
parents d2f30a177268
children 5a88923fcbfe
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
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
3 ;; Created: 1997/04/24 04:44:57
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
4 ;; Version: 1.25
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)
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
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
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
32 (eval-when-compile
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
33 (require 'w3-props))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (require 'w3-forms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (require 'font)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
36 (require 'w3-script)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
37
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; Help menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
41 (defvar w3-e19-hotlist-menu nil "A menu for hotlists.")
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
42 (defvar w3-e19-links-menu nil "A buffer-local menu for hyperlinks.")
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
43 (defvar w3-e19-nav-menu nil "A buffer-local menu for html based <link> tags.")
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
44 (mapcar 'make-variable-buffer-local
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
45 '(w3-e19-hotlist-menu w3-e19-links-menu w3-e19-nav-menu))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; Functions to build menus of urls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
50 (defun w3-e19-show-hotlist-menu ()
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
51 (interactive)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
52 (let ((keymap (easy-menu-create-keymaps "Hotlist"
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
53 (w3-menu-hotlist-constructor nil)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
54 (x nil)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
55 (y nil))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
56 (setq x (x-popup-menu t keymap)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
57 y (and x (lookup-key keymap (apply 'vector x))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
58 (if (and x y)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
59 (funcall y))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
61 (defun w3-e19-show-links-menu ()
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
62 (interactive)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (if (not w3-e19-links-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (w3-build-FSF19-menu))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
65 (let (x y)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
66 (setq x (x-popup-menu t w3-e19-links-menu)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
67 y (and x (lookup-key w3-e19-links-menu (apply 'vector x))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
68 (if (and x y)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
69 (funcall y))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
70
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
71 (defun w3-e19-show-navigate-menu ()
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
72 (interactive)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
73 (if (not w3-e19-nav-menu)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
74 (w3-build-FSF19-menu))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
75 (let (x y)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
76 (setq x (x-popup-menu t w3-e19-nav-menu)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
77 y (and x (lookup-key w3-e19-nav-menu (apply 'vector x))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (if (and x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (funcall y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defun w3-build-FSF19-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; Build emacs19 menus from w3-links-list
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
83 (let ((links (w3-menu-html-links-constructor nil))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
84 (hlink (w3-menu-links-constructor nil)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
85 (setq w3-e19-nav-menu (easy-menu-create-keymaps "Navigate" links)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
86 w3-e19-links-menu (easy-menu-create-keymaps "Links" hlink))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defun w3-setup-version-specifics ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; Set up routine for emacs 19
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
90 (require 'lmenu) ; for popup-menu
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
91 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun w3-store-in-clipboard (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "Store string STR in the Xwindows clipboard"
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
95 (case (device-type)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
96 (x (x-select-text str))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
97 (pm (pm-put-clipboard str))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
98 (ns (ns-store-pasteboard-internal str))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 122
diff changeset
99 (otherwise nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
101 (defun w3-e19-no-read-only (st nd)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
102 ;; Make sure we don't yank any read-only data out of this buffer
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
103 (let ((inhibit-read-only t))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
104 (put-text-property st nd 'read-only nil)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
105
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (defun w3-mode-version-specifics ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; Emacs 19 specific stuff for w3-mode
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
108 (declare (special w3-face-index w3-display-background-properties))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (make-local-variable 'track-mouse)
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 102
diff changeset
110 (set (make-local-variable 'buffer-access-fontify-functions) 'w3-e19-no-read-only)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
111 (if w3-track-mouse (setq track-mouse t))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
112 (if w3-display-background-properties
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
113 (let ((face (w3-make-face (intern
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
114 (format "w3-style-face-%05d" w3-face-index))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
115 "An Emacs-W3 face... don't edit by hand." t))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
116 (fore (car w3-display-background-properties))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
117 (inhibit-read-only t)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
118 (back (cdr w3-display-background-properties)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
119 (setq w3-face-index (1+ w3-face-index))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
120 (if fore (font-set-face-foreground face fore))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
121 (if back (font-set-face-background face back))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
122 (fillin-text-property (point-min) (point-max) 'face 'face face))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
122
d2f30a177268 Import from CVS: tag r20-1b14
cvs
parents: 118
diff changeset
124 (defun w3-text-pixel-width (str &optional face)
d2f30a177268 Import from CVS: tag r20-1b14
cvs
parents: 118
diff changeset
125 "Return the pixel-width of a chunk of text STR with face FACE."
d2f30a177268 Import from CVS: tag r20-1b14
cvs
parents: 118
diff changeset
126 (* (length str) (frame-char-width)))
d2f30a177268 Import from CVS: tag r20-1b14
cvs
parents: 118
diff changeset
127
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defun w3-mouse-handler (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 "Function to message the url under the mouse cursor"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (let* ((pt (posn-point (event-start e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (good (eq (posn-window (event-start e)) (selected-window)))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
133 (mouse-events nil))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
134 (if (not (and good pt (number-or-marker-p pt)))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
135 nil
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
136 (widget-echo-help pt)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
137 ;; Need to handle onmouseover, on mouseout
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
138 (setq mouse-events (w3-script-find-event-handlers pt 'mouse))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
139 (if (assq 'onmouseover mouse-events)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 82
diff changeset
140 (w3-script-evaluate-form (cdr (assq 'onmouseover mouse-events)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (provide 'w3-emacs19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (provide 'w3-e19)