summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMichael Kifer <kifer@cs.stonybrook.edu>1997-06-09 04:00:50 +0000
committerMichael Kifer <kifer@cs.stonybrook.edu>1997-06-09 04:00:50 +0000
commit9e0062901b4424efaadc1388cabdb7145977cd0f (patch)
treece42ba54e711501b860770bea217d5091566f73e /lisp
parent3afd33a8355f3601c41bfcea3b055191f9f127fb (diff)
downloademacs-9e0062901b4424efaadc1388cabdb7145977cd0f.tar.gz
new version
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emulation/viper-cmd.el127
-rw-r--r--lisp/emulation/viper-ex.el21
-rw-r--r--lisp/emulation/viper-init.el26
-rw-r--r--lisp/emulation/viper-keym.el13
-rw-r--r--lisp/emulation/viper-macs.el33
-rw-r--r--lisp/emulation/viper-mous.el58
-rw-r--r--lisp/emulation/viper-util.el12
-rw-r--r--lisp/emulation/viper.el182
8 files changed, 244 insertions, 228 deletions
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 644b73fa6bc..2e25a44a7e5 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -1,30 +1,11 @@
;;; viper-cmd.el --- Vi command support for Viper
-
;; Copyright (C) 1997 Free Software Foundation, Inc.
-;; Keywords: emulations
-;; Author: Michael Kifer <kifer@cs.sunysb.edu>
-
-;; 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.
;; Code
(provide 'viper-cmd)
+(require 'advice)
;; Compiler pacifier
(defvar vip-minibuffer-current-face)
@@ -36,19 +17,22 @@
(defvar zmacs-region-stays)
(defvar mark-even-if-inactive)
-(eval-when-compile
- (let ((load-path (cons (expand-file-name ".") load-path)))
- (or (featurep 'viper-util)
- (load "viper-util.el" nil nil 'nosuffix))
- (or (featurep 'viper-keym)
- (load "viper-keym.el" nil nil 'nosuffix))
- (or (featurep 'viper-mous)
- (load "viper-mous.el" nil nil 'nosuffix))
- (or (featurep 'viper-macs)
- (load "viper-macs.el" nil nil 'nosuffix))
- (or (featurep 'viper-ex)
- (load "viper-ex.el" nil nil 'nosuffix))
- ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+ (eval-when-compile
+ (let ((load-path (cons (expand-file-name ".") load-path)))
+ (or (featurep 'viper-util)
+ (load "viper-util.el" nil nil 'nosuffix))
+ (or (featurep 'viper-keym)
+ (load "viper-keym.el" nil nil 'nosuffix))
+ (or (featurep 'viper-mous)
+ (load "viper-mous.el" nil nil 'nosuffix))
+ (or (featurep 'viper-macs)
+ (load "viper-macs.el" nil nil 'nosuffix))
+ (or (featurep 'viper-ex)
+ (load "viper-ex.el" nil nil 'nosuffix))
+ )))
;; end pacifier
@@ -937,36 +921,6 @@ as a Meta key and any number of multiple escapes is allowed."
keyseq))
-
-(defadvice read-key-sequence (around vip-read-keyseq-ad activate)
- "Harness to work for Viper. This advice is harmless---don't worry!"
- (let (inhibit-quit event keyseq)
- (setq keyseq ad-do-it)
- (setq event (if vip-xemacs-p
- (elt keyseq 0) ; XEmacs returns vector of events
- (elt (listify-key-sequence keyseq) 0)))
- (if (vip-ESC-event-p event)
- (let (unread-command-events)
- (vip-set-unread-command-events keyseq)
- (if (vip-fast-keysequence-p)
- (let ((vip-vi-global-user-minor-mode nil)
- (vip-vi-local-user-minor-mode nil)
- (vip-replace-minor-mode nil) ; actually unnecessary
- (vip-insert-global-user-minor-mode nil)
- (vip-insert-local-user-minor-mode nil))
- (setq keyseq ad-do-it))
- (setq keyseq ad-do-it))))
- keyseq))
-
-(defadvice describe-key (before vip-read-keyseq-ad protect activate)
- "Force to read key via `read-key-sequence'."
- (interactive (list (vip-events-to-keys
- (read-key-sequence "Describe key: ")))))
-
-(defadvice describe-key-briefly (before vip-read-keyseq-ad protect activate)
- "Force to read key via `read-key-sequence'."
- (interactive (list (vip-events-to-keys
- (read-key-sequence "Describe key briefly: ")))))
;; Listen to ESC key.
;; If a sequence of keys starting with ESC is issued with very short delays,
@@ -3188,8 +3142,6 @@ controlled by the sign of prefix numeric value."
;; scrolling
-(setq scroll-step 1)
-
(defun vip-scroll-screen (arg)
"Scroll to next screen."
(interactive "p")
@@ -3628,51 +3580,6 @@ To turn this feature off, set this variable to nil.")
))
-;; Advice for use in find-file and read-file-name commands.
-(defadvice exit-minibuffer (before vip-exit-minibuffer-advice activate)
- "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer."
- (run-hooks 'vip-minibuffer-exit-hook))
-
-(defadvice find-file (before vip-add-suffix-advice activate)
- "Use `read-file-name' for reading arguments."
- (interactive (cons (read-file-name "Find file: " nil default-directory)
- ;; if Mule and prefix argument, ask for coding system
- (if (or (boundp 'MULE) ; mule integrated Emacs 19
- (featurep 'mule)) ; mule integrated XEmacs 20
- (list
- (and current-prefix-arg
- (read-coding-system "Coding-system: "))))
- )))
-
-(defadvice find-file-other-window (before vip-add-suffix-advice activate)
- "Use `read-file-name' for reading arguments."
- (interactive (cons (read-file-name "Find file in other window: "
- nil default-directory)
- ;; if Mule and prefix argument, ask for coding system
- (if (or (boundp 'MULE) ; mule integrated Emacs 19
- (featurep 'mule)) ; mule integrated XEmacs 20
- (list
- (and current-prefix-arg
- (read-coding-system "Coding-system: "))))
- )))
-
-(defadvice find-file-other-frame (before vip-add-suffix-advice activate)
- "Use `read-file-name' for reading arguments."
- (interactive (cons (read-file-name "Find file in other frame: "
- nil default-directory)
- ;; if Mule and prefix argument, ask for coding system
- (if (or (boundp 'MULE) ; mule integrated Emacs 19
- (featurep 'mule)) ; mule integrated XEmacs 20
- (list
- (and current-prefix-arg
- (read-coding-system "Coding-system: "))))
- )))
-
-(defadvice read-file-name (around vip-suffix-advice activate)
- "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook."
- (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix))
- ad-do-it))
-
;; yank and pop
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index 4c64b7b3c70..4a81df559e0 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -35,15 +35,18 @@
(defvar vip-custom-file-name)
(defvar vip-case-fold-search)
-(eval-when-compile
- (let ((load-path (cons (expand-file-name ".") load-path)))
- (or (featurep 'viper-util)
- (load "viper-util.el" nil nil 'nosuffix))
- (or (featurep 'viper-keym)
- (load "viper-keym.el" nil nil 'nosuffix))
- (or (featurep 'viper-cmd)
- (load "viper-cmd.el" nil nil 'nosuffix))
- ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+ (eval-when-compile
+ (let ((load-path (cons (expand-file-name ".") load-path)))
+ (or (featurep 'viper-util)
+ (load "viper-util.el" nil nil 'nosuffix))
+ (or (featurep 'viper-keym)
+ (load "viper-keym.el" nil nil 'nosuffix))
+ (or (featurep 'viper-cmd)
+ (load "viper-cmd.el" nil nil 'nosuffix))
+ )))
;; end pacifier
(require 'viper-util)
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index b8fa5d1d84b..84a40193cb5 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -25,8 +25,16 @@
;; compiler pacifier
(defvar mark-even-if-inactive)
+(defvar viper-version)
;; end pacifier
+
+;; Viper version
+(defun viper-version ()
+ (interactive)
+ (message "Viper version is %s" viper-version))
+(defalias 'vip-version 'viper-version)
+
;; Is it XEmacs?
(defconst vip-xemacs-p (string-match "\\(Lucid\\|XEmacs\\)" emacs-version))
;; Is it Emacs?
@@ -122,15 +130,6 @@ that Viper doesn't know about.")
;;; Viper minor modes
-;; This is not local in Emacs, so we make it local.
-;; This must be local because although the stack of minor modes can be the same
-;; for all buffers, the associated *keymaps* can be different. In Viper,
-;; vip-vi-local-user-map, vip-insert-local-user-map, and others can have
-;; different keymaps for different buffers.
-;; Also, the keymaps associated with vip-vi/insert-state-modifier-minor-mode
-;; can be different.
-(make-variable-buffer-local 'minor-mode-map-alist)
-
;; Mode for vital things like \e, C-z.
(vip-deflocalvar vip-vi-intercept-minor-mode nil)
@@ -597,9 +596,6 @@ These buffers can be cycled through via :R and :P commands.")
;;; Miscellaneous
-;; don't bark when mark is inactive
-(setq mark-even-if-inactive t)
-
(defvar vip-inhibit-startup-message nil
"Whether Viper startup message should be inhibited.")
@@ -634,12 +630,6 @@ Should be set in `~/.vip' file.")
;; Beginning with Emacs 19.26, the standard `minibuffer-exit-hook' is run
;; *after* exiting the minibuffer
(defvar vip-minibuffer-exit-hook nil)
-
-;; setup emacs-supported vi-style feel
-(setq next-line-add-newlines nil
- require-final-newline t)
-
-(make-variable-buffer-local 'require-final-newline)
;; Mode line
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index 2ff89a7f6df..370ae3de291 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -31,11 +31,14 @@
(defvar vip-ex-style-editing-in-insert)
(defvar vip-ex-style-motion)
-(eval-when-compile
- (let ((load-path (cons (expand-file-name ".") load-path)))
- (or (featurep 'viper-util)
- (load "viper-util.el" nil nil 'nosuffix))
- ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+ (eval-when-compile
+ (let ((load-path (cons (expand-file-name ".") load-path)))
+ (or (featurep 'viper-util)
+ (load "viper-util.el" nil nil 'nosuffix))
+ )))
;; end pacifier
(require 'viper-util)
diff --git a/lisp/emulation/viper-macs.el b/lisp/emulation/viper-macs.el
index 3328eacd527..07e39038b47 100644
--- a/lisp/emulation/viper-macs.el
+++ b/lisp/emulation/viper-macs.el
@@ -28,17 +28,20 @@
(defvar vip-custom-file-name)
(defvar vip-current-state)
-(eval-when-compile
- (let ((load-path (cons (expand-file-name ".") load-path)))
- (or (featurep 'viper-util)
- (load "viper-util.el" nil nil 'nosuffix))
- (or (featurep 'viper-keym)
- (load "viper-keym.el" nil nil 'nosuffix))
- (or (featurep 'viper-mous)
- (load "viper-mous.el" nil nil 'nosuffix))
- (or (featurep 'viper-cmd)
- (load "viper-cmd.el" nil nil 'nosuffix))
- ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+ (eval-when-compile
+ (let ((load-path (cons (expand-file-name ".") load-path)))
+ (or (featurep 'viper-util)
+ (load "viper-util.el" nil nil 'nosuffix))
+ (or (featurep 'viper-keym)
+ (load "viper-keym.el" nil nil 'nosuffix))
+ (or (featurep 'viper-mous)
+ (load "viper-mous.el" nil nil 'nosuffix))
+ (or (featurep 'viper-cmd)
+ (load "viper-cmd.el" nil nil 'nosuffix))
+ )))
;; end pacifier
(require 'viper-util)
@@ -317,14 +320,6 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
-(defadvice start-kbd-macro (after vip-kbd-advice activate)
- "Remove Viper's intercepting bindings for C-x ).
-This may be needed if the previous `:map' command terminated abnormally."
- (define-key vip-vi-intercept-map "\C-x)" nil)
- (define-key vip-insert-intercept-map "\C-x)" nil)
- (define-key vip-emacs-intercept-map "\C-x)" nil))
-
-
;;; Recording, unrecording, executing
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el
index b9638175e02..d7e617f8796 100644
--- a/lisp/emulation/viper-mous.el
+++ b/lisp/emulation/viper-mous.el
@@ -32,13 +32,16 @@
(defvar vip-s-string)
(defvar vip-re-search)
-(eval-when-compile
- (let ((load-path (cons (expand-file-name ".") load-path)))
- (or (featurep 'viper-util)
- (load "viper-util.el" nil nil 'nosuffix))
- (or (featurep 'viper-cmd)
- (load "viper-cmd.el" nil nil 'nosuffix))
- ))
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+ (eval-when-compile
+ (let ((load-path (cons (expand-file-name ".") load-path)))
+ (or (featurep 'viper-util)
+ (load "viper-util.el" nil nil 'nosuffix))
+ (or (featurep 'viper-cmd)
+ (load "viper-cmd.el" nil nil 'nosuffix))
+ )))
;; end pacifier
(require 'viper-util)
@@ -427,46 +430,5 @@ bindings in the Viper manual."
vip-current-frame-saved (selected-frame)))
-(cond ((vip-window-display-p)
- (let* ((search-key (if vip-xemacs-p
- [(meta shift button1up)] [M-S-mouse-1]))
- (search-key-catch (if vip-xemacs-p
- [(meta shift button1)] [M-S-down-mouse-1]))
- (insert-key (if vip-xemacs-p
- [(meta shift button2up)] [M-S-mouse-2]))
- (insert-key-catch (if vip-xemacs-p
- [(meta shift button2)] [M-S-down-mouse-2]))
- (search-key-unbound (and (not (key-binding search-key))
- (not (key-binding search-key-catch))))
- (insert-key-unbound (and (not (key-binding insert-key))
- (not (key-binding insert-key-catch))))
- )
-
- (if search-key-unbound
- (global-set-key search-key 'vip-mouse-click-search-word))
- (if insert-key-unbound
- (global-set-key insert-key 'vip-mouse-click-insert-word))
-
- ;; The following would be needed if you want to use the above two
- ;; while clicking in another frame. If you only want to use them
- ;; by clicking in another window, not frame, the bindings below
- ;; aren't necessary.
-
- ;; These must be bound to mouse-down event for the same mouse
- ;; buttons as 'vip-mouse-click-search-word and
- ;; 'vip-mouse-click-insert-word
- (if search-key-unbound
- (global-set-key search-key-catch 'vip-mouse-catch-frame-switch))
- (if insert-key-unbound
- (global-set-key insert-key-catch 'vip-mouse-catch-frame-switch))
-
- (if vip-xemacs-p
- (add-hook 'mouse-leave-frame-hook
- 'vip-remember-current-frame)
- (defadvice handle-switch-frame (before vip-frame-advice activate)
- "Remember the selected frame before the switch-frame event."
- (vip-remember-current-frame (selected-frame))))
- )))
-
;;; viper-mous.el ends here
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index 95ac4476a35..efcb637fe25 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -39,12 +39,12 @@
(require 'cl)
(require 'ring)
-(and noninteractive
- (eval-when-compile
- (let ((load-path (cons (expand-file-name ".") load-path)))
- (or (featurep 'viper-init)
- (load "viper-init.el" nil nil 'nosuffix))
- )))
+(if noninteractive
+ (eval-when-compile
+ (let ((load-path (cons (expand-file-name ".") load-path)))
+ (or (featurep 'viper-init)
+ (load "viper-init.el" nil nil 'nosuffix))
+ )))
;; end pacifier
(require 'viper-init)
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index 6a8e9e4e717..2e33a428ad8 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -8,7 +8,7 @@
;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
-(defconst viper-version "2.94 of June 2, 1997"
+(defconst viper-version "2.94 of June 9, 1997"
"The current version of Viper")
;; This file is part of GNU Emacs.
@@ -300,20 +300,20 @@
(require 'cl)
(require 'ring)
-(eval-when-compile
- (let ((load-path (cons (expand-file-name ".") load-path)))
- (or (featurep 'viper-cmd)
- (load "viper-cmd.el" nil nil 'nosuffix))
- ))
+;; compiler pacifier
+(defvar mark-even-if-inactive)
-(require 'viper-cmd)
+;; loading happens only in non-interactive compilation
+;; in order to spare non-viperized emacs from being viperized
+(if noninteractive
+ (eval-when-compile
+ (let ((load-path (cons (expand-file-name ".") load-path)))
+ (or (featurep 'viper-cmd)
+ (load "viper-cmd.el" nil nil 'nosuffix))
+ )))
+;; end pacifier
-;; Viper version
-(defun viper-version ()
- (interactive)
- (message "Viper version is %s" viper-version))
-
-(defalias 'vip-version 'viper-version)
+(require 'viper-cmd)
;; The following is provided for compatibility with older VIP's
@@ -323,9 +323,34 @@
(defalias 'vip-change-mode-to-emacs 'vip-change-state-to-emacs)
+;;; Here we put things that may affect global emacs behavior.
+;;; This file is not loaded during compilation, so this makes
+;;; interactive compilation of Viper safe for non-viper users.
+
+
+;; This is not local in Emacs, so we make it local.
+;; This must be local because although the stack of minor modes can be the same
+;; for all buffers, the associated *keymaps* can be different. In Viper,
+;; vip-vi-local-user-map, vip-insert-local-user-map, and others can have
+;; different keymaps for different buffers.
+;; Also, the keymaps associated with vip-vi/insert-state-modifier-minor-mode
+;; can be different.
+(make-variable-buffer-local 'minor-mode-map-alist)
+
;; Viper changes the default mode-line-buffer-identification
(setq-default mode-line-buffer-identification '(" %b"))
+;; setup emacs-supported vi-style feel
+(setq next-line-add-newlines nil
+ require-final-newline t)
+
+(make-variable-buffer-local 'require-final-newline)
+
+;; don't bark when mark is inactive
+(setq mark-even-if-inactive t)
+
+(setq scroll-step 1)
+
;; Variable displaying the current Viper state in the mode line.
(vip-deflocalvar vip-mode-string vip-emacs-state-id)
(or (memq 'vip-mode-string global-mode-string)
@@ -333,6 +358,7 @@
(append '("" vip-mode-string) (cdr global-mode-string))))
+
;;; Load set up hooks then load .vip
@@ -560,6 +586,136 @@
"Switch to emacs state when done editing message."
(vip-change-state-to-emacs))
) ; vip-set-hooks
+
+
+;; Defadvices
+
+(defadvice read-key-sequence (around vip-read-keyseq-ad activate)
+ "Harness to work for Viper. This advice is harmless---don't worry!"
+ (let (inhibit-quit event keyseq)
+ (setq keyseq ad-do-it)
+ (setq event (if vip-xemacs-p
+ (elt keyseq 0) ; XEmacs returns vector of events
+ (elt (listify-key-sequence keyseq) 0)))
+ (if (vip-ESC-event-p event)
+ (let (unread-command-events)
+ (vip-set-unread-command-events keyseq)
+ (if (vip-fast-keysequence-p)
+ (let ((vip-vi-global-user-minor-mode nil)
+ (vip-vi-local-user-minor-mode nil)
+ (vip-replace-minor-mode nil) ; actually unnecessary
+ (vip-insert-global-user-minor-mode nil)
+ (vip-insert-local-user-minor-mode nil))
+ (setq keyseq ad-do-it))
+ (setq keyseq ad-do-it))))
+ keyseq))
+
+(defadvice describe-key (before vip-read-keyseq-ad protect activate)
+ "Force to read key via `read-key-sequence'."
+ (interactive (list (vip-events-to-keys
+ (read-key-sequence "Describe key: ")))))
+
+(defadvice describe-key-briefly (before vip-read-keyseq-ad protect activate)
+ "Force to read key via `read-key-sequence'."
+ (interactive (list (vip-events-to-keys
+ (read-key-sequence "Describe key briefly: ")))))
+
+
+;; Advice for use in find-file and read-file-name commands.
+(defadvice exit-minibuffer (before vip-exit-minibuffer-advice activate)
+ "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer."
+ (run-hooks 'vip-minibuffer-exit-hook))
+
+(defadvice find-file (before vip-add-suffix-advice activate)
+ "Use `read-file-name' for reading arguments."
+ (interactive (cons (read-file-name "Find file: " nil default-directory)
+ ;; if Mule and prefix argument, ask for coding system
+ (if (or (boundp 'MULE) ; mule integrated Emacs 19
+ (featurep 'mule)) ; mule integrated XEmacs 20
+ (list
+ (and current-prefix-arg
+ (read-coding-system "Coding-system: "))))
+ )))
+
+(defadvice find-file-other-window (before vip-add-suffix-advice activate)
+ "Use `read-file-name' for reading arguments."
+ (interactive (cons (read-file-name "Find file in other window: "
+ nil default-directory)
+ ;; if Mule and prefix argument, ask for coding system
+ (if (or (boundp 'MULE) ; mule integrated Emacs 19
+ (featurep 'mule)) ; mule integrated XEmacs 20
+ (list
+ (and current-prefix-arg
+ (read-coding-system "Coding-system: "))))
+ )))
+
+(defadvice find-file-other-frame (before vip-add-suffix-advice activate)
+ "Use `read-file-name' for reading arguments."
+ (interactive (cons (read-file-name "Find file in other frame: "
+ nil default-directory)
+ ;; if Mule and prefix argument, ask for coding system
+ (if (or (boundp 'MULE) ; mule integrated Emacs 19
+ (featurep 'mule)) ; mule integrated XEmacs 20
+ (list
+ (and current-prefix-arg
+ (read-coding-system "Coding-system: "))))
+ )))
+
+(defadvice read-file-name (around vip-suffix-advice activate)
+ "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook."
+ (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix))
+ ad-do-it))
+
+(defadvice start-kbd-macro (after vip-kbd-advice activate)
+ "Remove Viper's intercepting bindings for C-x ).
+This may be needed if the previous `:map' command terminated abnormally."
+ (define-key vip-vi-intercept-map "\C-x)" nil)
+ (define-key vip-insert-intercept-map "\C-x)" nil)
+ (define-key vip-emacs-intercept-map "\C-x)" nil))
+
+(cond ((vip-window-display-p)
+ (let* ((search-key (if vip-xemacs-p
+ [(meta shift button1up)] [M-S-mouse-1]))
+ (search-key-catch (if vip-xemacs-p
+ [(meta shift button1)] [M-S-down-mouse-1]))
+ (insert-key (if vip-xemacs-p
+ [(meta shift button2up)] [M-S-mouse-2]))
+ (insert-key-catch (if vip-xemacs-p
+ [(meta shift button2)] [M-S-down-mouse-2]))
+ (search-key-unbound (and (not (key-binding search-key))
+ (not (key-binding search-key-catch))))
+ (insert-key-unbound (and (not (key-binding insert-key))
+ (not (key-binding insert-key-catch))))
+ )
+
+ (if search-key-unbound
+ (global-set-key search-key 'vip-mouse-click-search-word))
+ (if insert-key-unbound
+ (global-set-key insert-key 'vip-mouse-click-insert-word))
+
+ ;; The following would be needed if you want to use the above two
+ ;; while clicking in another frame. If you only want to use them
+ ;; by clicking in another window, not frame, the bindings below
+ ;; aren't necessary.
+
+ ;; These must be bound to mouse-down event for the same mouse
+ ;; buttons as 'vip-mouse-click-search-word and
+ ;; 'vip-mouse-click-insert-word
+ (if search-key-unbound
+ (global-set-key search-key-catch 'vip-mouse-catch-frame-switch))
+ (if insert-key-unbound
+ (global-set-key insert-key-catch 'vip-mouse-catch-frame-switch))
+
+ (if vip-xemacs-p
+ (add-hook 'mouse-leave-frame-hook
+ 'vip-remember-current-frame)
+ (defadvice handle-switch-frame (before vip-frame-advice activate)
+ "Remember the selected frame before the switch-frame event."
+ (vip-remember-current-frame (selected-frame))))
+ )))
+
+
+
;; Set some useful macros
;; These must be before we load .vip, so the user could unrecord them.