2
|
1 ;;; w3-emulate.el --- All variable definitions for emacs-w3
|
0
|
2 ;; Author: wmperry
|
98
|
3 ;; Created: 1997/02/04 19:21:18
|
|
4 ;; Version: 1.11
|
0
|
5 ;; Keywords: comm, help, hypermedia
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2
|
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
82
|
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
|
0
|
10 ;;;
|
80
|
11 ;;; This file is part of GNU Emacs.
|
0
|
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 ;;; Provide emulations of various other web browsers
|
|
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
32 (require 'w3-vars)
|
|
33
|
|
34
|
|
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
36 ;; First, we emulate Netscape 2.x
|
|
37 ;; ------------------------------
|
|
38 ;; This entails mainly a few new keybindings.
|
|
39 ;; Alt-S == Save As
|
|
40 ;; Alt-M == New Mail Message
|
|
41 ;; Alt-N == New Window
|
|
42 ;; Alt-L == Open Location
|
|
43 ;; Alt-O == Open File
|
|
44 ;; Alt-P == Print
|
|
45 ;; Alt-Q == Quit
|
|
46 ;; Alt-F == Search
|
|
47 ;; Alt-G == Search Again
|
|
48 ;; Alt-R == Reload
|
|
49 ;; Alt-I == Load Images
|
|
50 ;; Alt-A == Add Bookmark
|
|
51 ;; Alt-B == Show Bookmark Window
|
|
52 ;; Alt-H == Show History Window
|
|
53 ;; Alt-Left == Back
|
|
54 ;; Alt-Right== Forward
|
|
55 ;; Right == Scroll left
|
|
56 ;; Left == Scroll right
|
|
57 ;; Up == Smooth scroll up
|
|
58 ;; Down == Smooth scroll down
|
|
59 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
60
|
|
61 (define-key w3-netscape-emulation-minor-mode-map "\M-s" 'w3-save-as)
|
|
62 (define-key w3-netscape-emulation-minor-mode-map "\M-m" 'w3-mailto)
|
|
63 (define-key w3-netscape-emulation-minor-mode-map "\M-n" 'make-frame)
|
|
64 (define-key w3-netscape-emulation-minor-mode-map "\M-l" 'w3-fetch)
|
|
65 (define-key w3-netscape-emulation-minor-mode-map "\M-o" 'w3-open-local)
|
|
66 (define-key w3-netscape-emulation-minor-mode-map "\M-p" 'w3-print-this-url)
|
|
67 (define-key w3-netscape-emulation-minor-mode-map "\M-q" 'w3-quit)
|
|
68 (define-key w3-netscape-emulation-minor-mode-map "\M-f" 'w3-search-forward)
|
|
69 (define-key w3-netscape-emulation-minor-mode-map "\M-g" 'w3-search-again)
|
|
70 (define-key w3-netscape-emulation-minor-mode-map "\M-r" 'w3-reload-document)
|
|
71 (define-key w3-netscape-emulation-minor-mode-map "\M-i" 'w3-load-delayed-images)
|
|
72 (define-key w3-netscape-emulation-minor-mode-map "\M-a" 'w3-hotlist-add-document)
|
|
73 (define-key w3-netscape-emulation-minor-mode-map "\M-b" 'w3-show-hotlist)
|
|
74 (define-key w3-netscape-emulation-minor-mode-map "\M-h" 'w3-show-history-list)
|
|
75
|
|
76 (define-key w3-netscape-emulation-minor-mode-map [up]
|
|
77 (function (lambda () (interactive) (scroll-down 1))))
|
|
78 (define-key w3-netscape-emulation-minor-mode-map [down]
|
|
79 (function (lambda () (interactive) (scroll-up 1))))
|
|
80 (define-key w3-netscape-emulation-minor-mode-map [right] 'scroll-left)
|
|
81 (define-key w3-netscape-emulation-minor-mode-map [left] 'scroll-right)
|
|
82 (define-key w3-netscape-emulation-minor-mode-map [(meta left)]
|
98
|
83 'w3-history-backward)
|
0
|
84 (define-key w3-netscape-emulation-minor-mode-map [(meta right)]
|
98
|
85 'w3-history-forward)
|
0
|
86
|
|
87 (defun turn-on-netscape-emulation ()
|
|
88 (interactive)
|
|
89 (w3-lynx-emulation-minor-mode 0)
|
|
90 (w3-netscape-emulation-minor-mode 1))
|
|
91
|
|
92 (defun w3-netscape-emulation-minor-mode (&optional arg)
|
|
93 "Minor mode for emulating netscape key navigation."
|
|
94 (interactive "P")
|
|
95 (cond
|
|
96 ((null arg)
|
|
97 (setq w3-netscape-emulation-minor-mode
|
|
98 (not w3-netscape-emulation-minor-mode))
|
|
99 (if w3-netscape-emulation-minor-mode
|
|
100 (setq w3-lynx-emulation-minor-mode nil)))
|
|
101 ((= 0 arg)
|
|
102 (setq w3-netscape-emulation-minor-mode nil))
|
|
103 (t
|
|
104 (setq w3-lynx-emulation-minor-mode nil
|
|
105 w3-netscape-emulation-minor-mode t)))
|
|
106 )
|
|
107
|
|
108 (defsubst w3-skip-word ()
|
|
109 (skip-chars-forward "^ \t\n\r")
|
|
110 (skip-chars-forward " \t"))
|
|
111
|
70
|
112 (defun w3-read-netscape-config (&optional fname)
|
|
113 "Read in a netscape-style configuration file."
|
|
114 (interactive "fNetscape configuration file: ")
|
|
115 (if (not (and (file-exists-p fname)
|
|
116 (file-readable-p fname)))
|
|
117 (error "Could not read %s" fname))
|
|
118 (let ((results nil)
|
|
119 (tag nil)
|
|
120 (val nil)
|
|
121 (var nil)
|
|
122 (save-pos nil))
|
|
123 (save-excursion
|
|
124 (set-buffer (get-buffer-create " *w3-tmp*"))
|
|
125 (erase-buffer)
|
|
126 (insert-file-contents-literally fname)
|
|
127 (goto-char (point-min))
|
|
128 (skip-chars-forward "^ \t\r\n") ; Skip tag line
|
|
129 (skip-chars-forward " \t\r\n") ; Skip blank line(s)
|
|
130 (while (not (eobp))
|
|
131 (setq save-pos (point))
|
|
132 (skip-chars-forward "^:")
|
|
133 (upcase-region save-pos (point))
|
|
134 (setq tag (buffer-substring save-pos (point)))
|
|
135 (skip-chars-forward ":\t ")
|
|
136 (setq save-pos (point))
|
|
137 (skip-chars-forward "^\r\n")
|
|
138 (setq val (if (= save-pos (point))
|
|
139 nil
|
|
140 (buffer-substring save-pos (point))))
|
|
141 (cond
|
|
142 ((null val) nil)
|
|
143 ((string-match "^[0-9]+$" val)
|
|
144 (setq val (string-to-int val)))
|
|
145 ((string= "false" (downcase val))
|
|
146 (setq val nil))
|
|
147 ((string= "true" (downcase val))
|
|
148 (setq val t))
|
|
149 (t nil))
|
|
150 (skip-chars-forward " \t\n\r")
|
|
151 (setq results (cons (cons tag val) results))))
|
|
152 (while results
|
|
153 (setq tag (car (car results))
|
|
154 val (cdr (car results))
|
|
155 var (cdr-safe (assoc tag w3-netscape-variable-mappings))
|
|
156 results (cdr results))
|
|
157 (cond
|
|
158 ((eq var 'w3-delay-image-loads) (set var (not val)))
|
|
159 (var (set var val))
|
|
160 (t nil)))))
|
|
161
|
0
|
162
|
|
163 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
164 ;; Now, lets try Lynx
|
|
165 ;; ------------------
|
|
166 ;; A few keybindings and modifications to some default functions
|
|
167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
168
|
|
169 (defun turn-on-lynx-emulation ()
|
|
170 (interactive)
|
|
171 (w3-netscape-emulation-minor-mode 0)
|
|
172 (w3-lynx-emulation-minor-mode 1))
|
|
173
|
|
174 (defun w3-lynx-emulation-minor-mode (&optional arg)
|
|
175 "Minor mode for emulating lynx key navigation."
|
|
176 (interactive "P")
|
|
177 (cond
|
|
178 ((null arg)
|
|
179 (setq w3-lynx-emulation-minor-mode
|
|
180 (not w3-lynx-emulation-minor-mode))
|
|
181 (if w3-lynx-emulation-minor-mode
|
|
182 (setq w3-netscape-emulation-minor-mode nil)))
|
|
183 ((= 0 arg)
|
|
184 (setq w3-lynx-emulation-minor-mode nil))
|
|
185 (t
|
|
186 (setq w3-lynx-emulation-minor-mode t
|
|
187 w3-netscape-emulation-minor-mode nil))))
|
|
188
|
98
|
189 ;; The list of keybindings for lynx minor mode was compiled from:
|
|
190 ;; http://www.crl.com/~subir/lynx/lynx_help/keystroke_commands/keystroke_help.htm
|
|
191
|
|
192 ;; Movement
|
|
193 (define-key w3-lynx-emulation-minor-mode-map [up] 'w3-widget-backward)
|
|
194 (define-key w3-lynx-emulation-minor-mode-map [down] 'w3-widget-forward)
|
|
195 (define-key w3-lynx-emulation-minor-mode-map [right] 'w3-follow-link)
|
|
196 (define-key w3-lynx-emulation-minor-mode-map [left] 'w3-history-backward)
|
|
197
|
|
198 ;; Scrolling
|
0
|
199 (define-key w3-lynx-emulation-minor-mode-map "+" 'w3-scroll-up)
|
|
200 (define-key w3-lynx-emulation-minor-mode-map "-" 'scroll-down)
|
|
201 (define-key w3-lynx-emulation-minor-mode-map "b" 'scroll-down)
|
98
|
202 (define-key w3-lynx-emulation-minor-mode-map "\C-a" 'w3-start-of-document)
|
|
203 (define-key w3-lynx-emulation-minor-mode-map "\C-e" 'w3-end-of-document)
|
|
204 (define-key w3-lynx-emulation-minor-mode-map "\C-f" 'scroll-down)
|
|
205 (define-key w3-lynx-emulation-minor-mode-map "\C-n" 'ignore) ; down 2
|
|
206 (define-key w3-lynx-emulation-minor-mode-map "\C-p" 'ignore) ; up 2
|
|
207 (define-key w3-lynx-emulation-minor-mode-map ")" 'ignore) ; forward half
|
|
208 (define-key w3-lynx-emulation-minor-mode-map "(" 'ignore) ; back half
|
|
209 (define-key w3-lynx-emulation-minor-mode-map "#" 'w3-toggle-toolbar)
|
|
210
|
|
211 ;; Dired bindings don't have any meaning for us
|
|
212
|
|
213 ;; Other
|
|
214 (define-key w3-lynx-emulation-minor-mode-map "?" 'w3-help)
|
|
215 (define-key w3-lynx-emulation-minor-mode-map "a" 'w3-hotlist-add-document)
|
|
216 (define-key w3-lynx-emulation-minor-mode-map "c" 'w3-mail-document-author)
|
|
217 (define-key w3-lynx-emulation-minor-mode-map "d" 'w3-download-url)
|
|
218 (define-key w3-lynx-emulation-minor-mode-map "e" 'ignore) ; edit current
|
|
219 (define-key w3-lynx-emulation-minor-mode-map "f" 'dired)
|
|
220 (define-key w3-lynx-emulation-minor-mode-map "g" 'w3-fetch)
|
|
221 (define-key w3-lynx-emulation-minor-mode-map "h" 'w3-help)
|
|
222 (define-key w3-lynx-emulation-minor-mode-map "i" 'ignore)
|
|
223 (define-key w3-lynx-emulation-minor-mode-map "j" 'w3-use-hotlist)
|
|
224 (define-key w3-lynx-emulation-minor-mode-map "k" 'describe-mode)
|
|
225 (define-key w3-lynx-emulation-minor-mode-map "l" 'w3-complete-link)
|
|
226 (define-key w3-lynx-emulation-minor-mode-map "m" 'w3)
|
|
227 (define-key w3-lynx-emulation-minor-mode-map "n" 'w3-search-again)
|
|
228 (define-key w3-lynx-emulation-minor-mode-map "o" 'w3-preferences-edit)
|
|
229 (define-key w3-lynx-emulation-minor-mode-map "p" 'w3-print-this-url)
|
|
230 (define-key w3-lynx-emulation-minor-mode-map "q" 'w3-quit)
|
|
231 (define-key w3-lynx-emulation-minor-mode-map "r" 'w3-hotlist-delete)
|
|
232 (define-key w3-lynx-emulation-minor-mode-map "t" 'ignore) ; tag
|
|
233 (define-key w3-lynx-emulation-minor-mode-map "u" 'w3-history-backward)
|
|
234 (define-key w3-lynx-emulation-minor-mode-map "/" 'w3-search-forward)
|
|
235 (define-key w3-lynx-emulation-minor-mode-map "v" 'w3-show-hotlist)
|
|
236 (define-key w3-lynx-emulation-minor-mode-map "V" 'w3-show-hotlist)
|
|
237 (define-key w3-lynx-emulation-minor-mode-map "x" 'w3-follow-link)
|
|
238 (define-key w3-lynx-emulation-minor-mode-map "z" 'keyboard-quit)
|
|
239 (define-key w3-lynx-emulation-minor-mode-map "=" 'w3-document-information)
|
|
240 (define-key w3-lynx-emulation-minor-mode-map "\\" 'w3-source-document)
|
|
241 (define-key w3-lynx-emulation-minor-mode-map "!" 'shell)
|
|
242 (define-key w3-lynx-emulation-minor-mode-map "'" 'ignore) ; toggle comment
|
|
243 (define-key w3-lynx-emulation-minor-mode-map "`" 'ignore) ; toggle comment
|
|
244 (define-key w3-lynx-emulation-minor-mode-map "*" 'ignore) ; toggle image_links
|
|
245 (define-key w3-lynx-emulation-minor-mode-map "@" 'ignore) ; toggle raw 8-bit
|
|
246 (define-key w3-lynx-emulation-minor-mode-map "[" 'ignore) ; pseudo-inlines
|
|
247 (define-key w3-lynx-emulation-minor-mode-map "]" 'ignore) ; send head
|
|
248 (define-key w3-lynx-emulation-minor-mode-map "\"" 'ignore) ; toggle quoting
|
0
|
249 (define-key w3-lynx-emulation-minor-mode-map "\C-r" 'w3-reload-document)
|
|
250 (define-key w3-lynx-emulation-minor-mode-map "\C-w" 'w3-refresh-buffer)
|
98
|
251 (define-key w3-lynx-emulation-minor-mode-map "\C-u" 'ignore) ; erase input
|
|
252 (define-key w3-lynx-emulation-minor-mode-map "\C-g" 'keyboard-quit)
|
|
253 (define-key w3-lynx-emulation-minor-mode-map "\C-t" 'ignore) ; toggle trace
|
|
254 (define-key w3-lynx-emulation-minor-mode-map "\C-k" 'ignore) ; cookie jar
|
0
|
255
|
|
256 (provide 'w3-emulate)
|
|
257
|
|
258 ;;; Local Variables:
|
|
259 ;;; truncate-lines: t
|
|
260 ;;; End:
|