changeset 70419:c18be7440465

(kmacro-push-ring): Use add-to-history. (kmacro-ring-length): Remove unused defun. (kmacro-start-macro): Use kmacro-push-ring.
author Kim F. Storm <storm@cua.dk>
date Fri, 05 May 2006 23:37:37 +0000
parents 4e1a43edc7bc
children 718312081ce0
files lisp/kmacro.el
diffstat 1 files changed, 3 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/kmacro.el	Fri May 05 23:37:31 2006 +0000
+++ b/lisp/kmacro.el	Fri May 05 23:37:37 2006 +0000
@@ -349,10 +349,7 @@
 (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)))))
+    (add-to-history 'kmacro-ring elt kmacro-ring-max t)))
 
 
 (defun kmacro-split-ring-element (elt)
@@ -377,11 +374,6 @@
     (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."
@@ -577,13 +569,8 @@
     (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)