(skkdic-convert): Insert a relative
[bpt/emacs.git] / lisp / kmacro.el
index 6bb1ab6..bfc0edb 100644 (file)
@@ -1,6 +1,7 @@
 ;;; kmacro.el --- enhanced keyboard macros
 
-;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006,
+;;   2007 Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <storm@cua.dk>
 ;; Keywords: keyboard convenience
 
 ;;; Commentary:
 
-;; The kmacro package is an alternative user interface to emacs'
-;; keyboard macro functionality.  This functionality is normally bound
-;; to C-x (, C-x ), and C-x e, but these bindings are too hard to
-;; type to be really useful for doing small repeated tasks.
+;; The kmacro package provides the user interface to emacs' basic
+;; keyboard macro functionality.  With kmacro, two function keys are
+;; dedicated to keyboard macros, by default F3 and F4.
+
+;; Note: The traditional bindings C-x (, C-x ), and C-x e are still
+;; supported, but for some users these bindings are too hard to type
+;; to be really useful for doing small repeated tasks.
 
-;; With kmacro, two function keys are dedicated to keyboard macros,
-;; by default F3 and F4.  Personally, I prefer F1 and F2, but those
-;; keys already have default bindings.
-;;
 ;; To start defining a keyboard macro, use F3.  To end the macro,
 ;; use F4, and to call the macro also use F4.  This makes it very
 ;; easy to repeat a macro immediately after defining it.
@@ -55,7 +55,6 @@
 ;; elements with C-x C-k C-t.  To delete the first element in the
 ;; macro ring, use C-x C-k C-d.
 ;;
-;;
 ;; You can also use C-x C-k C-s to start a macro, and C-x C-k C-k to
 ;; end it; then use C-k to execute it immediately, or C-x C-k C-k to
 ;; execute it later.
@@ -257,7 +256,7 @@ macro to be executed before appending to it."
 
 (defun kmacro-insert-counter (arg)
   "Insert macro counter and increment with ARG or 1 if missing.
-With \\[universal-argument], insert previous kmacro-counter (but do not modify counter)."
+With \\[universal-argument], insert previous `kmacro-counter' (but do not modify counter)."
   (interactive "P")
   (if kmacro-initial-counter-value
       (setq kmacro-counter kmacro-initial-counter-value
@@ -285,7 +284,7 @@ With \\[universal-argument], insert previous kmacro-counter (but do not modify c
 
 
 (defun kmacro-set-counter (arg)
-  "Set kmacro-counter to ARG or prompt if missing.
+  "Set `kmacro-counter' to ARG or prompt if missing.
 With \\[universal-argument] prefix, reset counter to its value prior to this iteration of the macro."
   (interactive "NMacro counter value: ")
   (if (not (or defining-kbd-macro executing-kbd-macro))
@@ -349,10 +348,8 @@ and `kmacro-counter-format'.")
 (defun kmacro-push-ring (&optional elt)
   "Push ELT or current macro onto `kmacro-ring'."
   (when (setq elt (or elt (kmacro-ring-head)))
-    (let ((len (length kmacro-ring)))
-      (setq kmacro-ring (cons elt kmacro-ring))
-      (if (>= len kmacro-ring-max)
-         (setcdr (nthcdr len kmacro-ring) nil)))))
+    (let ((history-delete-duplicates nil))
+      (add-to-history 'kmacro-ring elt kmacro-ring-max))))
 
 
 (defun kmacro-split-ring-element (elt)
@@ -377,11 +374,6 @@ Non-nil arg RAW means just return raw first element."
     (kmacro-pop-ring1 raw)))
 
 
-(defun kmacro-ring-length ()
-  "Return length of macro ring, including pseudo head."
-  (+ (if last-kbd-macro 1 0) (length kmacro-ring)))
-
-
 (defun kmacro-ring-empty-p (&optional none)
   "Tell user and return t if `last-kbd-macro' is nil or `kmacro-ring' is empty.
 Check only `last-kbd-macro' if optional arg NONE is non-nil."
@@ -416,7 +408,7 @@ Optional arg EMPTY is message to print if no macros are defined."
 
 
 (defun kmacro-repeat-on-last-key (keys)
-  "Process kmacro commands keys immidiately after cycling the ring."
+  "Process kmacro commands keys immediately after cycling the ring."
   (setq keys (vconcat keys))
   (let ((n (1- (length keys)))
        cmd done repeat)
@@ -462,14 +454,14 @@ Optional arg EMPTY is message to print if no macros are defined."
 
 
 (defun kmacro-call-ring-2nd (arg)
-  "Execute second keyboard macro at in macro ring."
+  "Execute second keyboard macro in macro ring."
   (interactive "P")
   (unless (kmacro-ring-empty-p)
     (kmacro-exec-ring-item (car kmacro-ring) arg)))
 
 
 (defun kmacro-call-ring-2nd-repeat (arg)
-  "Execute second keyboard macro at in macro ring.
+  "Execute second keyboard macro in macro ring.
 This is like `kmacro-call-ring-2nd', but allows repeating macro commands
 without repeating the prefix."
   (interactive "P")
@@ -577,13 +569,8 @@ Use \\[kmacro-bind-to-key] to bind it to a key sequence."
     (let ((append (and arg (listp arg))))
       (unless append
        (if last-kbd-macro
-           (let ((len (length kmacro-ring)))
-             (setq kmacro-ring
-                   (cons
-                    (list last-kbd-macro kmacro-counter kmacro-counter-format-start)
-                    kmacro-ring))
-             (if (>= len kmacro-ring-max)
-                 (setcdr (nthcdr len kmacro-ring) nil))))
+           (kmacro-push-ring
+            (list last-kbd-macro kmacro-counter kmacro-counter-format-start)))
        (setq kmacro-counter (or (if arg (prefix-numeric-value arg))
                                 kmacro-initial-counter-value
                                 0)
@@ -684,7 +671,7 @@ the current value of `kmacro-counter').
 
 When defining/executing macro, inserts macro counter and increments
 the counter with ARG or 1 if missing.  With \\[universal-argument],
-inserts previous kmacro-counter (but do not modify counter).
+inserts previous `kmacro-counter' (but do not modify counter).
 
 The macro counter can be modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
 The format of the counter can be modified via \\[kmacro-set-format]."
@@ -955,7 +942,7 @@ following additional answers: `insert', `insert-1', `replace', `replace-1',
 (defvar kmacro-step-edit-prefix-commands
   '(universal-argument universal-argument-more universal-argument-minus
                       digit-argument negative-argument)
-  "Commands which builds up a prefix arg for the current command")
+  "Commands which build up a prefix arg for the current command.")
 
 (defun kmacro-step-edit-prompt (macro index)
   ;; Show step-edit prompt