view lisp/w3/w3-emulate.el @ 36:c53a95d3c46d r19-15b101

Import from CVS: tag r19-15b101
author cvs
date Mon, 13 Aug 2007 08:53:38 +0200
parents e04119814345
children 131b0175ea99
line wrap: on
line source

;;; w3-emulate.el --- All variable definitions for emacs-w3
;; Author: wmperry
;; Created: 1997/03/14 06:12:02
;; Version: 1.12
;; Keywords: comm, help, hypermedia

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
;;;
;;; This file is part of GNU Emacs.
;;;
;;; GNU Emacs is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.
;;;
;;; GNU Emacs is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Emacs; see the file COPYING.  If not, write to the
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;;; Boston, MA 02111-1307, USA.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Provide emulations of various other web browsers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'w3-vars)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; First, we emulate Netscape 2.x
;; ------------------------------
;; This entails mainly a few new keybindings.
;; Alt-S    == Save As
;; Alt-M    == New Mail Message
;; Alt-N    == New Window
;; Alt-L    == Open Location
;; Alt-O    == Open File
;; Alt-P    == Print
;; Alt-Q    == Quit
;; Alt-F    == Search
;; Alt-G    == Search Again
;; Alt-R    == Reload
;; Alt-I    == Load Images
;; Alt-A    == Add Bookmark
;; Alt-B    == Show Bookmark Window
;; Alt-H    == Show History Window
;; Alt-Left == Back
;; Alt-Right== Forward
;; Right    == Scroll left
;; Left     == Scroll right
;; Up       == Smooth scroll up
;; Down     == Smooth scroll down
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-key w3-netscape-emulation-minor-mode-map "\M-s" 'w3-save-as)
(define-key w3-netscape-emulation-minor-mode-map "\M-m" 'w3-mailto)
(define-key w3-netscape-emulation-minor-mode-map "\M-n" 'make-frame)
(define-key w3-netscape-emulation-minor-mode-map "\M-l" 'w3-fetch)
(define-key w3-netscape-emulation-minor-mode-map "\M-o" 'w3-open-local)
(define-key w3-netscape-emulation-minor-mode-map "\M-p" 'w3-print-this-url)
(define-key w3-netscape-emulation-minor-mode-map "\M-q" 'w3-quit)
(define-key w3-netscape-emulation-minor-mode-map "\M-f" 'w3-search-forward)
(define-key w3-netscape-emulation-minor-mode-map "\M-g" 'w3-search-again)
(define-key w3-netscape-emulation-minor-mode-map "\M-r" 'w3-reload-document)
(define-key w3-netscape-emulation-minor-mode-map "\M-i" 'w3-load-delayed-images)
(define-key w3-netscape-emulation-minor-mode-map "\M-a" 'w3-hotlist-add-document)
(define-key w3-netscape-emulation-minor-mode-map "\M-b" 'w3-show-hotlist)
(define-key w3-netscape-emulation-minor-mode-map "\M-h" 'w3-show-history-list)

(define-key w3-netscape-emulation-minor-mode-map [up]
  (function (lambda () (interactive) (scroll-down 1))))
(define-key w3-netscape-emulation-minor-mode-map [down]
  (function (lambda () (interactive) (scroll-up 1))))
(define-key w3-netscape-emulation-minor-mode-map [right] 'scroll-left)
(define-key w3-netscape-emulation-minor-mode-map [left] 'scroll-right)
(define-key w3-netscape-emulation-minor-mode-map [(meta left)]
  'w3-history-backward)
(define-key w3-netscape-emulation-minor-mode-map [(meta right)]
  'w3-history-forward)

(defun turn-on-netscape-emulation ()
  (interactive)
  (w3-lynx-emulation-minor-mode 0)
  (w3-netscape-emulation-minor-mode 1))

(defun w3-netscape-emulation-minor-mode (&optional arg)
  "Minor mode for emulating netscape key navigation."
  (interactive "P")
  (cond
   ((null arg)
    (setq w3-netscape-emulation-minor-mode
	  (not w3-netscape-emulation-minor-mode))
    (if w3-netscape-emulation-minor-mode
	(setq w3-lynx-emulation-minor-mode nil)))
   ((= 0 arg)
    (setq w3-netscape-emulation-minor-mode nil))
   (t
    (setq w3-lynx-emulation-minor-mode nil
	  w3-netscape-emulation-minor-mode t)))
  )

(defsubst w3-skip-word ()
  (skip-chars-forward "^ \t\n\r")
  (skip-chars-forward " \t"))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Now, lets try Lynx
;; ------------------
;; A few keybindings and modifications to some default functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun turn-on-lynx-emulation ()
  (interactive)
  (w3-netscape-emulation-minor-mode 0)
  (w3-lynx-emulation-minor-mode 1))

(defun w3-lynx-emulation-minor-mode (&optional arg)
  "Minor mode for emulating lynx key navigation."
  (interactive "P")
  (cond
   ((null arg)
    (setq w3-lynx-emulation-minor-mode
	  (not w3-lynx-emulation-minor-mode))
    (if w3-lynx-emulation-minor-mode
	(setq w3-netscape-emulation-minor-mode nil)))
   ((= 0 arg)
    (setq w3-lynx-emulation-minor-mode nil))
   (t
    (setq w3-lynx-emulation-minor-mode t
	  w3-netscape-emulation-minor-mode nil))))

;; The list of keybindings for lynx minor mode was compiled from:
;; http://www.crl.com/~subir/lynx/lynx_help/keystroke_commands/keystroke_help.htm

;; Movement
(define-key w3-lynx-emulation-minor-mode-map [up]   'w3-widget-backward)
(define-key w3-lynx-emulation-minor-mode-map [down] 'w3-widget-forward)
(define-key w3-lynx-emulation-minor-mode-map [right] 'w3-follow-link)
(define-key w3-lynx-emulation-minor-mode-map [left] 'w3-history-backward)

;; Scrolling
(define-key w3-lynx-emulation-minor-mode-map "+"    'w3-scroll-up)
(define-key w3-lynx-emulation-minor-mode-map "-"    'scroll-down)
(define-key w3-lynx-emulation-minor-mode-map "b"    'scroll-down)
(define-key w3-lynx-emulation-minor-mode-map "\C-a" 'w3-start-of-document)
(define-key w3-lynx-emulation-minor-mode-map "\C-e" 'w3-end-of-document)
(define-key w3-lynx-emulation-minor-mode-map "\C-f" 'scroll-down)
(define-key w3-lynx-emulation-minor-mode-map "\C-n" 'ignore) ; down 2
(define-key w3-lynx-emulation-minor-mode-map "\C-p" 'ignore) ; up 2
(define-key w3-lynx-emulation-minor-mode-map ")"    'ignore) ; forward half
(define-key w3-lynx-emulation-minor-mode-map "("    'ignore) ; back half
(define-key w3-lynx-emulation-minor-mode-map "#"    'w3-toggle-toolbar)

;; Dired bindings don't have any meaning for us

;; Other
(define-key w3-lynx-emulation-minor-mode-map "?"   'w3-help)
(define-key w3-lynx-emulation-minor-mode-map "a"   'w3-hotlist-add-document)
(define-key w3-lynx-emulation-minor-mode-map "c"   'w3-mail-document-author)
(define-key w3-lynx-emulation-minor-mode-map "d"   'w3-download-url) 
(define-key w3-lynx-emulation-minor-mode-map "e"   'ignore) ; edit current
(define-key w3-lynx-emulation-minor-mode-map "f"   'dired)
(define-key w3-lynx-emulation-minor-mode-map "g"   'w3-fetch)
(define-key w3-lynx-emulation-minor-mode-map "h"   'w3-help)
(define-key w3-lynx-emulation-minor-mode-map "i"   'ignore)
(define-key w3-lynx-emulation-minor-mode-map "j"   'w3-use-hotlist)
(define-key w3-lynx-emulation-minor-mode-map "k"   'describe-mode)
(define-key w3-lynx-emulation-minor-mode-map "l"   'w3-complete-link)
(define-key w3-lynx-emulation-minor-mode-map "m"   'w3)
(define-key w3-lynx-emulation-minor-mode-map "n"   'w3-search-again)
(define-key w3-lynx-emulation-minor-mode-map "o"   'w3-preferences-edit)
(define-key w3-lynx-emulation-minor-mode-map "p"   'w3-print-this-url)
(define-key w3-lynx-emulation-minor-mode-map "q"   'w3-quit)
(define-key w3-lynx-emulation-minor-mode-map "r"   'w3-hotlist-delete)
(define-key w3-lynx-emulation-minor-mode-map "t"   'ignore) ; tag
(define-key w3-lynx-emulation-minor-mode-map "u"   'w3-history-backward)
(define-key w3-lynx-emulation-minor-mode-map "/"   'w3-search-forward)
(define-key w3-lynx-emulation-minor-mode-map "v"   'w3-show-hotlist)
(define-key w3-lynx-emulation-minor-mode-map "V"   'w3-show-hotlist)
(define-key w3-lynx-emulation-minor-mode-map "x"   'w3-follow-link)
(define-key w3-lynx-emulation-minor-mode-map "z"   'keyboard-quit)
(define-key w3-lynx-emulation-minor-mode-map "="   'w3-document-information)
(define-key w3-lynx-emulation-minor-mode-map "\\"  'w3-source-document)
(define-key w3-lynx-emulation-minor-mode-map "!"   'shell)
(define-key w3-lynx-emulation-minor-mode-map "'"   'ignore) ; toggle comment
(define-key w3-lynx-emulation-minor-mode-map "`"   'ignore) ; toggle comment
(define-key w3-lynx-emulation-minor-mode-map "*"   'ignore) ; toggle image_links
(define-key w3-lynx-emulation-minor-mode-map "@"   'ignore) ; toggle raw 8-bit
(define-key w3-lynx-emulation-minor-mode-map "["   'ignore) ; pseudo-inlines
(define-key w3-lynx-emulation-minor-mode-map "]"   'ignore) ; send head
(define-key w3-lynx-emulation-minor-mode-map "\""  'ignore) ; toggle quoting
(define-key w3-lynx-emulation-minor-mode-map "\C-r" 'w3-reload-document)
(define-key w3-lynx-emulation-minor-mode-map "\C-w" 'w3-refresh-buffer)
(define-key w3-lynx-emulation-minor-mode-map "\C-u" 'ignore) ; erase input
(define-key w3-lynx-emulation-minor-mode-map "\C-g" 'keyboard-quit)
(define-key w3-lynx-emulation-minor-mode-map "\C-t" 'ignore) ; toggle trace
(define-key w3-lynx-emulation-minor-mode-map "\C-k" 'ignore) ; cookie jar

(provide 'w3-emulate)

;;; Local Variables:
;;; truncate-lines: t
;;; End: