;;; viper-keym.el -- Main Viper keymaps
-
-;; Copyright (C) 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; This keymap should stay empty
(defvar vip-empty-keymap (make-sparse-keymap))
+;; This was the main Vi mode in old versions of VIP which may have been
+;; extensively used by VIP users. We declare it as a global var
+;; and, after .vip is loaded, we add this keymap to vip-vi-basic-map.
+(defvar vip-mode-map (make-sparse-keymap))
+
;;; Variables used by minor modes
(define-key vip-vi-basic-map "t" 'vip-goto-char-forward)
(define-key vip-vi-basic-map "u" 'vip-undo)
(define-key vip-vi-basic-map "v" 'find-file)
-(define-key vip-vi-basic-map "\C-v" 'vip-find-file-other-frame)
+(define-key vip-vi-basic-map "\C-v" 'find-file-other-frame)
(define-key vip-vi-basic-map "w" 'vip-forward-word)
(define-key vip-vi-basic-map "x" 'vip-delete-char)
(define-key vip-vi-basic-map "y" 'vip-command-argument)
(vip-set-mode-vars-for vip-current-state)))
+;; Displays variables that control Viper's keymaps
(defun vip-debug-keymaps ()
- "Displays variables that control Viper's keymaps."
(interactive)
(with-output-to-temp-buffer " *vip-debug*"
(princ (format "Buffer name: %s\n\n" (buffer-name)))
;;; viper-macs.el -- functions implementing keyboard macros for Viper
-
-;; Copyright (C) 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
"Vector of keys representing the name of last Viper keyboard macro.")
(defconst vip-fast-keyseq-timeout 200
- "*Key sequences separated by this many miliseconds are interpreted as a macro, if such a macro is defined.
+ "*Key sequence separated by no more than this many milliseconds is viewed as a macro, if such a macro is defined.
This also controls ESC-keysequences generated by keyboard function keys.")
\f
;;; Code
+;; Ex map command
(defun ex-map ()
- "Ex map command."
(let ((mod-char "")
macro-name macro-body map-args ins)
(save-window-excursion
))
+;; Ex unmap
(defun ex-unmap ()
- "Ex unmap."
(let ((mod-char "")
temp macro-name ins)
(save-window-excursion
(setq macro-body (vip-char-array-to-macro macro-body)))
((vectorp macro-body) nil)
(t (error "map: Invalid syntax in macro definition"))))
- (cons macro-name macro-body)
- ))
+ (setq cursor-in-echo-area nil)(sit-for 0) ; this overcomes xemacs tty bug
+ (cons macro-name macro-body)))
;; macro name must be a vector of vip-style keys
(defun vip-unrecord-kbd-macro (macro-name state)
+ "Delete macro MACRO-NAME from Viper STATE.
+MACRO-NAME must be a vector of vip-style keys. This command is used by Viper
+internally, but the user can also use it in ~/.vip to delete pre-defined macros
+supplied with Viper. The best way to avoid mistakes in macro names to be passed
+to this function is to use vip-describe-kbd-macros and copy the name from
+there."
(let* (state-name keymap
(macro-alist-var
(cond ((eq state 'vi-state)
))
))
-;; Checks if MACRO-ALIST has an entry for a macro name starting with
+;; Check if MACRO-ALIST has an entry for a macro name starting with
;; CHAR. If not, this indicates that the binding for this char
;; in vip-vi/insert-kbd-map can be released.
(defun vip-can-release-key (char macro-alist)
(setq candidates (delq nil candidates))))
-;; if seq of key symbols can be converted to a string--do so. Otherwise, do
-;; nothing.
+;; if seq of Viper key symbols (representing a macro) can be converted to a
+;; string--do so. Otherwise, do nothing.
(defun vip-display-macro (macro-name)
(cond ((vip-char-symbol-sequence-p macro-name)
(mapconcat 'symbol-name macro-name ""))
(defun vip-events-to-macro (event-seq)
(vconcat (mapcar 'vip-event-key event-seq)))
-;; convert strings of characters or arrays of characters to Viper macro form
+;; convert strings or arrays of characters to Viper macro form
(defun vip-char-array-to-macro (array)
(let ((vec (vconcat array))
macro)
;;; viper-mous.el -- Mouse support for Viper
-
-;; Copyright (C) 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
(defvar vip-frame-of-focus nil)
;; Frame that was selected before the switch-frame event.
-(defconst vip-pre-click-frame (vip-selected-frame))
+(defconst vip-current-frame-saved (selected-frame))
(defvar vip-surrounding-word-function 'vip-surrounding-word
"*Function that determines what constitutes a word for clicking events.
\f
;;; Code
-(defun vip-multiclick-p ()
+(defsubst vip-multiclick-p ()
(not (vip-sit-for-short vip-multiclick-timeout t)))
(defun vip-surrounding-word (count click-count)
(error "Click must be over a window."))
click-word))))
-(defun vip-mouse-click-frame (click)
- "Returns window where click occurs."
- (vip-window-frame (vip-mouse-click-window click)))
+;; Returns window where click occurs
+(defsubst vip-mouse-click-frame (click)
+ (window-frame (vip-mouse-click-window click)))
-(defun vip-mouse-click-window (click)
- "Returns window where click occurs."
+;; Returns window where click occurs
+(defsubst vip-mouse-click-window (click)
(if vip-xemacs-p
(event-window click)
(posn-window (event-start click))))
-(defun vip-mouse-click-window-buffer (click)
- "Returns the buffer of the window where click occurs."
+;; Returns the buffer of the window where click occurs
+(defsubst vip-mouse-click-window-buffer (click)
(window-buffer (vip-mouse-click-window click)))
-(defun vip-mouse-click-window-buffer-name (click)
- "Returns the name of the buffer in the window where click occurs."
+;; Returns the name of the buffer in the window where click occurs
+(defsubst vip-mouse-click-window-buffer-name (click)
(buffer-name (vip-mouse-click-window-buffer click)))
-(defun vip-mouse-click-posn (click)
- "Returns position of a click."
- (interactive "e")
+;; Returns position of a click
+(defsubst vip-mouse-click-posn (click)
(if vip-xemacs-p
(event-point click)
(posn-point (event-start click))))
See `vip-surrounding-word' for the definition of a word in this case."
(interactive "e\nP")
(if vip-frame-of-focus ;; to handle clicks in another frame
- (vip-select-frame vip-frame-of-focus))
+ (select-frame vip-frame-of-focus))
;; turn arg into a number
(cond ((numberp arg) nil)
this command."
(interactive "e\nP")
(if vip-frame-of-focus ;; to handle clicks in another frame
- (vip-select-frame vip-frame-of-focus))
+ (select-frame vip-frame-of-focus))
(let (click-word click-count
(previous-search-string vip-s-string))
;; pass prefix arg along to vip-mouse-click-search/insert-word
(setq prefix-arg arg)
(if (eq last-command 'handle-switch-frame)
- (setq vip-frame-of-focus vip-pre-click-frame))
+ (setq vip-frame-of-focus vip-current-frame-saved))
;; make Emacs forget that it executed vip-mouse-catch-frame-switch
(setq this-command last-command))
;; until you do something other than vip-mouse-click-* command.
;; In XEmacs, you have to manually select frame B (with the mouse click) in
;; order to shift focus to frame B.
-(defun vip-save-pre-click-frame (frame)
- (setq last-command 'handle-switch-frame)
- (setq vip-pre-click-frame (vip-selected-frame)))
+(defsubst vip-remember-current-frame (frame)
+ (setq last-command 'handle-switch-frame
+ vip-current-frame-saved (selected-frame)))
-(cond (window-system
+(cond ((vip-window-display-p)
(let* ((search-key (if vip-xemacs-p [(meta button1up)] [S-mouse-1]))
(search-key-catch (if vip-xemacs-p
[(meta button1)] [S-down-mouse-1]))
(global-set-key insert-key-catch 'vip-mouse-catch-frame-switch))
(if vip-xemacs-p
- (add-hook 'mouse-leave-screen-hook
- 'vip-save-pre-click-frame)
+ (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-save-pre-click-frame (vip-selected-frame))))
+ (vip-remember-current-frame (selected-frame))))
)))