]> code.delx.au - gnu-emacs/blobdiff - lisp/emulation/viper-macs.el
(tempo-local-tags, tempo-user-elements, tempo-use-tag-list):
[gnu-emacs] / lisp / emulation / viper-macs.el
index 289cfd9d0a37ad6173b9f9a500bfb152639e52e8..39130edef69073061f88a25d25da0b8cfc7f6905 100644 (file)
@@ -1,4 +1,6 @@
-;;; 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.
@@ -60,8 +62,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
 \f
 ;;; Code
 
+;; Ex map command
 (defun ex-map ()
-  "Ex map command."
   (let ((mod-char "")
        macro-name macro-body map-args ins)
     (save-window-excursion
@@ -91,8 +93,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
     ))
     
 
+;; Ex unmap
 (defun ex-unmap ()
-  "Ex unmap."
   (let ((mod-char "")
        temp macro-name ins)
     (save-window-excursion
@@ -153,7 +155,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
                             (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
@@ -176,8 +179,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
               (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)))
     
 
 
@@ -227,7 +230,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
                                   (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
@@ -249,7 +253,6 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
     ))
     
     
-    
 (defun vip-end-mapping-kbd-macro (&optional ignore)
   "Terminate kbd macro."
   (interactive)
@@ -393,7 +396,17 @@ If SCOPE is nil, the user is asked to specify the scope."
              (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)
@@ -442,6 +455,12 @@ If SCOPE is nil, the user is asked to specify the scope."
     
 ;; 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)
@@ -519,7 +538,7 @@ If SCOPE is nil, the user is asked to specify the scope."
          ))
     ))
     
-;; 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)
@@ -749,8 +768,8 @@ If SCOPE is nil, the user is asked to specify the scope."
     (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 ""))
@@ -761,7 +780,7 @@ If SCOPE is nil, the user is asked to specify the scope."
 (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)
@@ -841,7 +860,8 @@ If SCOPE is nil, the user is asked to specify the scope."
        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))