emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ELPA-diffs] /srv/bzr/emacs/elpa r368: * packages/lmc/lmc.el (lmc-store-


From: Stefan Monnier
Subject: [ELPA-diffs] /srv/bzr/emacs/elpa r368: * packages/lmc/lmc.el (lmc-store-word): match-data can change in sit-for.
Date: Wed, 20 Mar 2013 14:13:49 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 368
committer: Stefan Monnier <address@hidden>
branch nick: elpa
timestamp: Wed 2013-03-20 14:13:49 -0400
message:
  * packages/lmc/lmc.el (lmc-store-word): match-data can change in sit-for.
  Reported by William L├ęchelle <address@hidden>.
modified:
  packages/lmc/lmc.el
=== modified file 'packages/lmc/lmc.el'
--- a/packages/lmc/lmc.el       2011-10-12 04:18:07 +0000
+++ b/packages/lmc/lmc.el       2013-03-20 18:13:49 +0000
@@ -1,9 +1,9 @@
 ;;; lmc.el --- Little Man Computer in Elisp
 
-;; Copyright (C) 2011  Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2013  Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
-;; Version: 1.0
+;; Version: 1.1
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -540,22 +540,21 @@
     (lmc-addr->point addr)
     (if (not (re-search-forward "\t.*\t\\(.*\\)$" (line-end-position) t))
         (error "Missing memory cell %S" addr)
-      (when lmc-store-flash
-        (lmc--with-silent-modifications
-          (put-text-property (match-beginning 1) (point)
-                             'face 'region))
-        (sit-for 0.2))
-      (replace-match (format "  %03d" word) t t nil 1)
-      (when lmc-store-flash
-        (sit-for 0.1)
-        (lmc--with-silent-modifications
-          (put-text-property (match-beginning 1) (point)
-                             'face 'region))
-        (sit-for 0.1)
-        (lmc--with-silent-modifications
-          (put-text-property (match-beginning 1) (point)
-                             'face nil))
-        (sit-for 0.1)))))
+      (let ((mb1 (match-beginning 1)))
+        (when lmc-store-flash
+          (lmc--with-silent-modifications
+           (put-text-property mb1 (point) 'face 'region))
+          (sit-for 0.2))
+        (let ((me1 (point)))
+          (insert (format "  %03d" word)) (delete-region mb1 me1))
+        (when lmc-store-flash
+          (sit-for 0.1)
+          (lmc--with-silent-modifications
+           (put-text-property mb1 (point) 'face 'region))
+          (sit-for 0.1)
+          (lmc--with-silent-modifications
+           (put-text-property mb1 (point) 'face nil))
+          (sit-for 0.1))))))
 
 (defun lmc-step ()
   "Execute one LMC instruction."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]