Add arch taglines
[bpt/emacs.git] / lisp / emulation / viper-init.el
index acc95b1..2a13f00 100644 (file)
@@ -1,6 +1,8 @@
 ;;; viper-init.el --- some common definitions for Viper
 
-;; Copyright (C) 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+
+;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 
 ;; This file is part of GNU Emacs.
 
@@ -19,7 +21,9 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;; Code
+;;; Commentary:
+
+;;; Code:
 
 (provide 'viper-init)
 
@@ -33,6 +37,9 @@
 (defvar current-input-method)
 (defvar default-input-method)
 (defvar describe-current-input-method-function)
+(defvar bar-cursor)
+(defvar default-cursor-type)
+(defvar cursor-type)
 ;; end pacifier
 
 
 ;; Is it Emacs?
 (defconst viper-emacs-p (not viper-xemacs-p))
 ;; Tell whether we are running as a window application or on a TTY
+
+;; This is used to avoid compilation warnings. When emacs/xemacs forms can
+;; generate compile time warnings, we use this macro.
+;; In this case, the macro will expand into the form that is appropriate to the
+;; compiler at hand.
+;; Suggested by rms.
+(defmacro viper-cond-compile-for-xemacs-or-emacs (xemacs-form emacs-form)
+  (if (string-match "XEmacs" emacs-version)
+      xemacs-form emacs-form))
+
+
 (defsubst viper-device-type ()
-  (if viper-emacs-p
-      window-system
-    (device-type (selected-device))))
+  (viper-cond-compile-for-xemacs-or-emacs
+   (device-type (selected-device))
+   window-system
+   ))
+
 ;; in XEmacs: device-type is tty on tty and stream in batch.
 (defun viper-window-display-p ()
   (and (viper-device-type) (not (memq (viper-device-type) '(tty stream pc)))))
@@ -430,15 +450,18 @@ color displays.  By default, the delimiters are used only on TTYs."
   :group 'viper)
 
 ;; XEmacs requires glyphs
-(if viper-xemacs-p
-    (progn
-      (or (glyphp viper-replace-region-end-delimiter)
-         (setq viper-replace-region-end-delimiter
-               (make-glyph viper-replace-region-end-delimiter)))
-      (or (glyphp viper-replace-region-start-delimiter)
-         (setq viper-replace-region-start-delimiter
-               (make-glyph viper-replace-region-start-delimiter)))
-      ))
+(viper-cond-compile-for-xemacs-or-emacs
+ (progn ; xemacs
+   (or (glyphp viper-replace-region-end-delimiter)
+       (setq viper-replace-region-end-delimiter
+            (make-glyph viper-replace-region-end-delimiter)))
+   (or (glyphp viper-replace-region-start-delimiter)
+       (setq viper-replace-region-start-delimiter
+            (make-glyph viper-replace-region-start-delimiter)))
+   )
+  nil ; emacs
+ )
+
 
 
 ;; These are local marker that must be initialized to nil and moved with
@@ -492,7 +515,7 @@ text."
 (defcustom viper-fast-keyseq-timeout 200
   "*Key sequence separated by no more than this many milliseconds is viewed as a Vi-style macro, if such a macro is defined.
 Setting this too high may slow down your typing.  Setting this value too low
-will make it hard to use Vi-stile timeout macros."
+will make it hard to use Vi-style timeout macros."
   :type 'integer
   :group 'viper-misc)
 
@@ -505,6 +528,19 @@ on a dumb terminal."
   :type 'integer
   :group 'viper-misc)
 
+(defcustom viper-translate-all-ESC-keysequences (not (viper-window-display-p))
+  "Allow translation of all key sequences into commands.
+Normally, Viper lets Emacs translate only those ESC key sequences that are
+defined in the low-level key-translation-map or function-key-map, such as those
+emitted by the arrow and function keys. Other sequences, e.g., \\e/, are
+treated as ESC command followed by a `/'. This is done for people who type fast
+and tend to hit other characters right after they hit ESC. Other people like
+Emacs to translate ESC sequences all the time.
+The default is to translate all sequences only when using a dumb terminal.
+This permits you to use ESC as a meta key in insert mode."
+  :type 'boolean
+  :group 'viper-misc)
+
 ;; Modes and related variables
 
 ;; Current mode.  One of: `emacs-state', `vi-state', `insert-state'
@@ -833,7 +869,7 @@ this variable represents.")
 
 (defface viper-minibuffer-emacs-face
   '((((class color)) (:foreground "Black" :background "darkseagreen2"))
-    (t (:bold t)))
+    (t (:weight bold)))
   "Face used in the Minibuffer when it is in Emacs state."
   :group 'viper-highlighting)
 ;; An internal variable.  Viper takes the face from here.
@@ -847,7 +883,7 @@ this variable represents.")
 
 (defface viper-minibuffer-insert-face
   '((((class color)) (:foreground "Black" :background "pink"))
-    (t (:italic t)))
+    (t (:slant italic)))
   "Face used in the Minibuffer when it is in Insert state."
   :group 'viper-highlighting)
 ;; An internal variable.  Viper takes the face from here.
@@ -934,19 +970,19 @@ Should be set in `~/.viper' file."
   :prefix "viper-"
   :group 'viper)
 
-(defcustom viper-vi-state-hook nil
+(defcustom viper-vi-state-hook 'viper-restore-cursor-type
   "*Hooks run just before the switch to Vi mode is completed."
   :type 'hook
   :group 'viper-hooks)
-(defcustom viper-insert-state-hook nil
+(defcustom viper-insert-state-hook 'viper-set-insert-cursor-type
   "*Hooks run just before the switch to Insert mode is completed."
   :type 'hook
   :group 'viper-hooks)
-(defcustom viper-replace-state-hook nil
+(defcustom viper-replace-state-hook 'viper-restore-cursor-type
   "*Hooks run just before the switch to Replace mode is completed."
   :type 'hook
   :group 'viper-hooks)
-(defcustom viper-emacs-state-hook nil
+(defcustom viper-emacs-state-hook 'viper-restore-cursor-type
   "*Hooks run just before the switch to Emacs mode is completed."
   :type 'hook
   :group 'viper-hooks)
@@ -956,9 +992,22 @@ Should be set in `~/.viper' file."
   :type 'hook
   :group 'viper-hooks)
 
+(defun viper-restore-cursor-type ()
+  (condition-case nil
+      (if viper-xemacs-p
+         (setq bar-cursor nil)
+       (setq cursor-type default-cursor-type))
+    (error nil)))
+
+(defun viper-set-insert-cursor-type ()
+  (if viper-xemacs-p
+      (setq bar-cursor 2)
+    (setq cursor-type '(bar . 2))))
+
 
 ;;; Local Variables:
 ;;; eval: (put 'viper-deflocalvar 'lisp-indent-hook 'defun)
 ;;; End:
 
-;;;  viper-ex.el ends here
+;;; arch-tag: 4efa2416-1fcb-4690-be10-1a2a0248d250
+;;; viper-init.el ends here