comparison lisp/w3/w3-emulate.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 ;;; w3-emulate.el,v --- All variable definitions for emacs-w3
2 ;; Author: wmperry
3 ;; Created: 1996/05/24 15:25:13
4 ;; Version: 1.10
5 ;; Keywords: comm, help, hypermedia
6
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@spry.com)
9 ;;;
10 ;;; This file is not part of GNU Emacs, but the same permissions apply.
11 ;;;
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2, or (at your option)
15 ;;; any later version.
16 ;;;
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to
24 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ;;; Provide emulations of various other web browsers
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
30 (require 'w3-vars)
31
32
33 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34 ;; First, we emulate Netscape 2.x
35 ;; ------------------------------
36 ;; This entails mainly a few new keybindings.
37 ;; Alt-S == Save As
38 ;; Alt-M == New Mail Message
39 ;; Alt-N == New Window
40 ;; Alt-L == Open Location
41 ;; Alt-O == Open File
42 ;; Alt-P == Print
43 ;; Alt-Q == Quit
44 ;; Alt-F == Search
45 ;; Alt-G == Search Again
46 ;; Alt-R == Reload
47 ;; Alt-I == Load Images
48 ;; Alt-A == Add Bookmark
49 ;; Alt-B == Show Bookmark Window
50 ;; Alt-H == Show History Window
51 ;; Alt-Left == Back
52 ;; Alt-Right== Forward
53 ;; Right == Scroll left
54 ;; Left == Scroll right
55 ;; Up == Smooth scroll up
56 ;; Down == Smooth scroll down
57 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
58
59 (define-key w3-netscape-emulation-minor-mode-map "\M-s" 'w3-save-as)
60 (define-key w3-netscape-emulation-minor-mode-map "\M-m" 'w3-mailto)
61 (define-key w3-netscape-emulation-minor-mode-map "\M-n" 'make-frame)
62 (define-key w3-netscape-emulation-minor-mode-map "\M-l" 'w3-fetch)
63 (define-key w3-netscape-emulation-minor-mode-map "\M-o" 'w3-open-local)
64 (define-key w3-netscape-emulation-minor-mode-map "\M-p" 'w3-print-this-url)
65 (define-key w3-netscape-emulation-minor-mode-map "\M-q" 'w3-quit)
66 (define-key w3-netscape-emulation-minor-mode-map "\M-f" 'w3-search-forward)
67 (define-key w3-netscape-emulation-minor-mode-map "\M-g" 'w3-search-again)
68 (define-key w3-netscape-emulation-minor-mode-map "\M-r" 'w3-reload-document)
69 (define-key w3-netscape-emulation-minor-mode-map "\M-i" 'w3-load-delayed-images)
70 (define-key w3-netscape-emulation-minor-mode-map "\M-a" 'w3-hotlist-add-document)
71 (define-key w3-netscape-emulation-minor-mode-map "\M-b" 'w3-show-hotlist)
72 (define-key w3-netscape-emulation-minor-mode-map "\M-h" 'w3-show-history-list)
73
74 (define-key w3-netscape-emulation-minor-mode-map [up]
75 (function (lambda () (interactive) (scroll-down 1))))
76 (define-key w3-netscape-emulation-minor-mode-map [down]
77 (function (lambda () (interactive) (scroll-up 1))))
78 (define-key w3-netscape-emulation-minor-mode-map [right] 'scroll-left)
79 (define-key w3-netscape-emulation-minor-mode-map [left] 'scroll-right)
80 (define-key w3-netscape-emulation-minor-mode-map [(meta left)]
81 'w3-backward-in-history)
82 (define-key w3-netscape-emulation-minor-mode-map [(meta right)]
83 'w3-forward-in-history)
84
85 (defun turn-on-netscape-emulation ()
86 (interactive)
87 (w3-lynx-emulation-minor-mode 0)
88 (w3-netscape-emulation-minor-mode 1))
89
90 (defun w3-netscape-emulation-minor-mode (&optional arg)
91 "Minor mode for emulating netscape key navigation."
92 (interactive "P")
93 (cond
94 ((null arg)
95 (setq w3-netscape-emulation-minor-mode
96 (not w3-netscape-emulation-minor-mode))
97 (if w3-netscape-emulation-minor-mode
98 (setq w3-lynx-emulation-minor-mode nil)))
99 ((= 0 arg)
100 (setq w3-netscape-emulation-minor-mode nil))
101 (t
102 (setq w3-lynx-emulation-minor-mode nil
103 w3-netscape-emulation-minor-mode t)))
104 )
105
106 (defsubst w3-skip-word ()
107 (skip-chars-forward "^ \t\n\r")
108 (skip-chars-forward " \t"))
109
110 (defun w3-read-netscape-config (&optional fname)
111 "Read in a netscape-style configuration file."
112 (interactive "fNetscape configuration file: ")
113 (if (not (and (file-exists-p fname)
114 (file-readable-p fname)))
115 (error "Could not read %s" fname))
116 (let ((results nil)
117 (tag nil)
118 (val nil)
119 (var nil)
120 (save-pos nil))
121 (save-excursion
122 (set-buffer (get-buffer-create " *w3-tmp*"))
123 (erase-buffer)
124 (insert-file-contents-literally fname)
125 (goto-char (point-min))
126 (skip-chars-forward "^ \t\r\n") ; Skip tag line
127 (skip-chars-forward " \t\r\n") ; Skip blank line(s)
128 (while (not (eobp))
129 (setq save-pos (point))
130 (skip-chars-forward "^:")
131 (upcase-region save-pos (point))
132 (setq tag (buffer-substring save-pos (point)))
133 (skip-chars-forward ":\t ")
134 (setq save-pos (point))
135 (skip-chars-forward "^\r\n")
136 (setq val (if (= save-pos (point))
137 nil
138 (buffer-substring save-pos (point))))
139 (cond
140 ((null val) nil)
141 ((string-match "^[0-9]+$" val)
142 (setq val (string-to-int val)))
143 ((string= "false" (downcase val))
144 (setq val nil))
145 ((string= "true" (downcase val))
146 (setq val t))
147 (t nil))
148 (skip-chars-forward " \t\n\r")
149 (setq results (cons (cons tag val) results))))
150 (while results
151 (setq tag (car (car results))
152 val (cdr (car results))
153 var (cdr-safe (assoc tag w3-netscape-variable-mappings))
154 results (cdr results))
155 (cond
156 ((eq var 'w3-delay-image-loads) (set var (not val)))
157 (var (set var val))
158 (t nil)))))
159
160
161 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
162 ;; Now, lets try Lynx
163 ;; ------------------
164 ;; A few keybindings and modifications to some default functions
165 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
166
167 (defun turn-on-lynx-emulation ()
168 (interactive)
169 (w3-netscape-emulation-minor-mode 0)
170 (w3-lynx-emulation-minor-mode 1))
171
172 (defun w3-lynx-emulation-minor-mode (&optional arg)
173 "Minor mode for emulating lynx key navigation."
174 (interactive "P")
175 (cond
176 ((null arg)
177 (setq w3-lynx-emulation-minor-mode
178 (not w3-lynx-emulation-minor-mode))
179 (if w3-lynx-emulation-minor-mode
180 (setq w3-netscape-emulation-minor-mode nil)))
181 ((= 0 arg)
182 (setq w3-lynx-emulation-minor-mode nil))
183 (t
184 (setq w3-lynx-emulation-minor-mode t
185 w3-netscape-emulation-minor-mode nil))))
186
187 (define-key w3-lynx-emulation-minor-mode-map "+" 'w3-scroll-up)
188 (define-key w3-lynx-emulation-minor-mode-map "-" 'scroll-down)
189 (define-key w3-lynx-emulation-minor-mode-map "b" 'scroll-down)
190 (define-key w3-lynx-emulation-minor-mode-map "a" 'w3-hotlist-add-document)
191 (define-key w3-lynx-emulation-minor-mode-map "c" 'w3-mail-document-author)
192 (define-key w3-lynx-emulation-minor-mode-map "e" 'w3-edit-source)
193 (define-key w3-lynx-emulation-minor-mode-map "g" 'w3-fetch)
194 (define-key w3-lynx-emulation-minor-mode-map "i" 'ignore)
195 (define-key w3-lynx-emulation-minor-mode-map "m" 'w3)
196 (define-key w3-lynx-emulation-minor-mode-map "o" 'ignore)
197 (define-key w3-lynx-emulation-minor-mode-map "p" 'w3-print-this-url)
198 (define-key w3-lynx-emulation-minor-mode-map "q" 'w3-quit)
199 (define-key w3-lynx-emulation-minor-mode-map "/" 'w3-search-forward)
200 (define-key w3-lynx-emulation-minor-mode-map "s" 'w3-search-forward)
201 (define-key w3-lynx-emulation-minor-mode-map "n" 'w3-search-again)
202 (define-key w3-lynx-emulation-minor-mode-map "v" 'w3-show-hotlist)
203 (define-key w3-lynx-emulation-minor-mode-map "=" 'w3-document-information)
204 (define-key w3-lynx-emulation-minor-mode-map "\C-r" 'w3-reload-document)
205 (define-key w3-lynx-emulation-minor-mode-map "\C-w" 'w3-refresh-buffer)
206 (define-key w3-lynx-emulation-minor-mode-map "\\" 'w3-source-document)
207 (define-key w3-lynx-emulation-minor-mode-map "!" 'shell)
208 (define-key w3-lynx-emulation-minor-mode-map [up] 'w3-back-link)
209 (define-key w3-lynx-emulation-minor-mode-map [down] 'w3-forward-link)
210 (define-key w3-lynx-emulation-minor-mode-map [right] 'w3-follow-link)
211 (define-key w3-lynx-emulation-minor-mode-map [left] 'w3-backward-in-history)
212
213 (provide 'w3-emulate)
214
215 ;;; Local Variables:
216 ;;; truncate-lines: t
217 ;;; End: