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