;;; 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.
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
-;; Code
+;;; Commentary:
+
+;;; Code:
(provide 'viper-init)
(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)))))
: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
(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)
: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'
(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.
(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.
: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)
: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