-;;; viper-macs.el -- functions implementing keyboard macros for Viper
+;;; viper-macs.el --- functions implementing keyboard macros for Viper
+
+;; 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.")
-(defvar vip-repeat-from-history-key 'f1
+(defvar vip-repeat-from-history-key 'f12
"Prefix key for invocation of vip-repeat-from-history function,
which repeats previous destructive commands from the history of such
commands.
\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
(prin1-to-string (vip-display-macro key-seq))
"")))
(message message)
- (setq event (vip-read-event))
+ (setq event (vip-read-key))
+ ;;(setq event (vip-read-event))
(setq key
(if (vip-mouse-event-p event)
(progn
(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)))
(vip-display-macro key-seq))
"")))
(message message)
- (setq event (vip-read-event))
+ (setq event (vip-read-key))
+ ;;(setq event (vip-read-event))
(setq key
(if (vip-mouse-event-p event)
(progn
))
-
(defun vip-end-mapping-kbd-macro (&optional ignore)
"Terminate kbd macro."
(interactive)
(vip-save-string-in-file
(format "\n(vip-record-kbd-macro %S '%S %s '%S)"
(vip-display-macro macro-name)
- state macro-body scope)
+ state
+ ;; if we don't let vector macro-body through %S,
+ ;; the symbols `\.' `\[' etc will be converted into
+ ;; characters, causing invalid read error on recorded
+ ;; macros in .vip.
+ ;; I am not sure is macro-body can still be a string at
+ ;; this point, but I am preserving this option anyway.
+ (if (vectorp macro-body)
+ (format "%S" macro-body)
+ macro-body)
+ scope)
vip-custom-file-name))
(message msg)
;; 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)
next-event)
(while (and (vip-fast-keysequence-p)
(vip-keyseq-is-a-possible-macro lis macro-alist))
- (setq next-event (vip-read-event))
+ (setq next-event (vip-read-key))
+ ;;(setq next-event (vip-read-event))
(or (vip-mouse-event-p next-event)
(setq lis (vconcat lis (vector next-event)))))
lis))