]> code.delx.au - gnu-emacs/blobdiff - lisp/emulation/viper-macs.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / emulation / viper-macs.el
index 0b96793deb794ee3f5aaf6b19b8e07f6341e6c3c..c8626e412b594199b27eb70cc40f5b0f45f525a5 100644 (file)
@@ -1,6 +1,6 @@
 ;;; viper-macs.el --- functions implementing keyboard macros for Viper
 
-;; Copyright (C) 1994-1997, 2000-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1997, 2000-2016 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Package: viper
 (defvar viper-custom-file-name)
 (defvar viper-current-state)
 (defvar viper-fast-keyseq-timeout)
-
-;; loading happens only in non-interactive compilation
-;; in order to spare non-viperized emacs from being viperized
-(if noninteractive
-    (eval-when-compile
-      (require 'viper-cmd)
-      ))
+(require 'viper-mous)
+(require 'viper-ex)
 ;; end pacifier
 
 (require 'viper-util)
@@ -83,6 +78,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
 \f
 ;;; Code
 
+(declare-function viper-change-state-to-insert "viper-cmd" ())
+
 ;; Ex map command
 (defun ex-map ()
   (let ((mod-char "")
@@ -277,6 +274,8 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
     ))
 
 
+(declare-function viper-change-state-to-vi "viper-cmd" (&rest _))
+
 ;; Terminate a Vi kbd macro.
 ;; optional argument IGNORE, if t, indicates that we are dealing with an
 ;; existing macro that needs to be registered, but there is no need to
@@ -323,12 +322,13 @@ a key is a symbol, e.g., `a', `\\1', `f2', etc., or a list, e.g.,
 ;; More general definitions are inherited by more specific scopes:
 ;; global->major mode->buffer. More specific definitions override more general
 (defun viper-record-kbd-macro (macro-name state macro-body &optional scope)
-  "Record a Vi macro.  Can be used in `.viper' file to define permanent macros.
+  "Record a Vi macro.
+Can be used in `viper-custom-file-name' to define permanent macros.
 MACRO-NAME is a string of characters or a vector of keys.  STATE is
 either `vi-state' or `insert-state'.  It specifies the Viper state in which to
 define the macro.  MACRO-BODY is a string that represents the keyboard macro.
-Optional SCOPE says whether the macro should be global \(t\), mode-specific
-\(a major-mode symbol\), or buffer-specific \(buffer name, a string\).
+Optional SCOPE says whether the macro should be global \(t), mode-specific
+\(a major-mode symbol), or buffer-specific \(buffer name, a string).
 If SCOPE is nil, the user is asked to specify the scope."
   (let* (state-name keymap
         (macro-alist-var
@@ -352,8 +352,8 @@ If SCOPE is nil, the user is asked to specify the scope."
        (error "Can't map an empty macro name"))
 
     ;; Macro-name is usually a vector.  However, command history or macros
-    ;; recorded in ~/.viper may be recorded as strings.  So, convert to
-    ;; vectors.
+    ;; recorded in viper-custom-file-name may be recorded as strings.
+    ;; So, convert to vectors.
     (setq macro-name (viper-fixup-macro macro-name))
     (if (viper-char-array-p macro-name)
        (setq macro-name (viper-char-array-to-macro macro-name)))
@@ -369,11 +369,11 @@ If SCOPE is nil, the user is asked to specify the scope."
          (setq scope
                (cond
                 ((y-or-n-p
-                  (format
+                  (format-message
                    "Map this macro for buffer `%s' only? "
                    (buffer-name)))
                  (setq msg
-                       (format
+                       (format-message
                         "%S is mapped to %s for %s in `%s'"
                         (viper-display-macro macro-name)
                         (viper-abbreviate-string
@@ -385,11 +385,11 @@ If SCOPE is nil, the user is asked to specify the scope."
                         state-name (buffer-name)))
                  (buffer-name))
                 ((y-or-n-p
-                  (format
+                  (format-message
                    "Map this macro for the major mode `%S' only? "
                    major-mode))
                  (setq msg
-                       (format
+                       (format-message
                         "%S is mapped to %s for %s in `%S'"
                         (viper-display-macro macro-name)
                         (viper-abbreviate-string
@@ -423,7 +423,7 @@ If SCOPE is nil, the user is asked to specify the scope."
                       ;; 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 .viper.
+                      ;; macros in viper-custom-file-name.
                       ;; 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)
@@ -484,11 +484,11 @@ If SCOPE is nil, the user is asked to specify the scope."
 ;; in effect
 (defun viper-unrecord-kbd-macro (macro-name state)
   "Delete macro MACRO-NAME from Viper STATE.
-MACRO-NAME must be a vector of viper-style keys.  This command is used by Viper
-internally, but the user can also use it in ~/.viper 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 viper-describe-kbd-macros and copy the
-name from there."
+MACRO-NAME must be a vector of viper-style keys.  This command is used
+by Viper internally, but you can also use it in `viper-custom-file-name'
+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
+`viper-describe-kbd-macros' and copy the name from there."
   (let* (state-name keymap
         (macro-alist-var
          (cond ((eq state 'vi-state)
@@ -508,7 +508,8 @@ name from there."
         macro-pair macro-entry)
 
     ;; Macro-name is usually a vector.  However, command history or macros
-    ;; recorded in ~/.viper may appear as strings.  So, convert to vectors.
+    ;; recorded in viper-custom-file-name may appear as strings.
+    ;; So, convert to vectors.
     (setq macro-name (viper-fixup-macro macro-name))
     (if (viper-char-array-p macro-name)
        (setq macro-name (viper-char-array-to-macro macro-name)))
@@ -528,9 +529,9 @@ name from there."
     (cond ((and (cdr buf-mapping)
                (or (and (not (cdr mode-mapping)) (not (cdr global-mapping)))
                    (y-or-n-p
-                    (format "Unmap %S for `%s' only? "
-                            (viper-display-macro macro-name)
-                            (buffer-name)))))
+                    (format-message "Unmap %S for `%s' only? "
+                                    (viper-display-macro macro-name)
+                                    (buffer-name)))))
           (setq macro-pair buf-mapping)
           (message "%S is unmapped for %s in `%s'"
                    (viper-display-macro macro-name)
@@ -538,9 +539,9 @@ name from there."
          ((and (cdr mode-mapping)
                (or (not (cdr global-mapping))
                    (y-or-n-p
-                    (format "Unmap %S for the major mode `%S' only? "
-                            (viper-display-macro macro-name)
-                            major-mode))))
+                    (format-message "Unmap %S for the major mode `%S' only? "
+                                    (viper-display-macro macro-name)
+                                    major-mode))))
           (setq macro-pair mode-mapping)
           (message "%S is unmapped for %s in %S"
                    (viper-display-macro macro-name) state-name major-mode))
@@ -893,7 +894,7 @@ name from there."
   (set-register reg last-kbd-macro))
 
 (defun viper-register-macro (count)
-  "Keyboard macros in registers - a modified \@ command."
+  "Keyboard macros in registers - a modified @ command."
   (interactive "P")
   (let ((reg (downcase (read-char))))
     (cond ((or (and (<= ?a reg) (<= reg ?z)))