[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lmc a5fe8d2 04/14: * lmc.el: Make it work on Emacs-22.
From: |
Stefan Monnier |
Subject: |
[elpa] externals/lmc a5fe8d2 04/14: * lmc.el: Make it work on Emacs-22. |
Date: |
Sat, 28 Nov 2020 23:22:15 -0500 (EST) |
branch: externals/lmc
commit a5fe8d2b66170a45adc9da27fb6e126e5517c7e7
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* lmc.el: Make it work on Emacs-22.
(lmc--with-silent-modifications): Compatibility macro.
(lmc-store-word): Use it.
(lmc): New group.
(lmc-store-flash): Make into a defcustom.
---
lmc.el | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/lmc.el b/lmc.el
index 82142d1..2e6e34e 100644
--- a/lmc.el
+++ b/lmc.el
@@ -64,6 +64,10 @@
(eval-when-compile (require 'cl))
(require 'hexl)
+(defgroup lmc ()
+ "Customization group for the Little Man Computer simulator."
+ :group 'languages)
+
;;; The LMC-Simulator
(defvar lmc--pc 0 "Program counter for LMC.")
@@ -72,6 +76,27 @@
(defvar lmc-acc 0 "Accumulator for LMC.")
(make-variable-buffer-local 'lmc--acc)
+;; Emacs-22 backward compatibility.
+(defmacro lmc--with-silent-modifications (&rest body)
+ (declare (debug t) (indent 0))
+ (if (fboundp 'with-silent-modifications)
+ `(with-silent-modifications ,@body)
+ (let ((modified (make-symbol "modified")))
+ `(let* ((,modified (buffer-modified-p))
+ (buffer-undo-list t)
+ (inhibit-read-only t)
+ (inhibit-modification-hooks t)
+ deactivate-mark
+ ;; Avoid setting and removing file locks and checking
+ ;; buffer's uptodate-ness w.r.t the underlying file.
+ buffer-file-name
+ buffer-file-truename)
+ (unwind-protect
+ (progn
+ ,@body)
+ (unless ,modified
+ (restore-buffer-modified-p nil)))))))
+
;; (defun lmc-check (cmds)
;; (dolist (cmd cmds)
;; (pcase cmd
@@ -506,7 +531,9 @@
(setq addr (1+ addr))))
(lmc-update-pc))
-(defvar lmc-store-flash t)
+(defcustom lmc-store-flash t
+ "If non-nil, memory words blink when modified."
+ :type 'boolean)
(defun lmc-store-word (addr word)
(save-excursion
@@ -514,18 +541,18 @@
(if (not (re-search-forward "\t.*\t\\(.*\\)$" (line-end-position) t))
(error "Missing memory cell %S" addr)
(when lmc-store-flash
- (with-silent-modifications
+ (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)
- (with-silent-modifications
+ (lmc--with-silent-modifications
(put-text-property (match-beginning 1) (point)
'face 'region))
(sit-for 0.1)
- (with-silent-modifications
+ (lmc--with-silent-modifications
(put-text-property (match-beginning 1) (point)
'face nil))
(sit-for 0.1)))))
- [elpa] branch externals/lmc created (now cb110db), Stefan Monnier, 2020/11/28
- [elpa] externals/lmc 2e56da4 02/14: * lmc.el: Add a few more commands, and a tool-bar., Stefan Monnier, 2020/11/28
- [elpa] externals/lmc d248525 01/14: New package lmc., Stefan Monnier, 2020/11/28
- [elpa] externals/lmc a5fe8d2 04/14: * lmc.el: Make it work on Emacs-22.,
Stefan Monnier <=
- [elpa] externals/lmc b7cbf14 07/14: * lmc.el (lmc--sit-for): Fix last change., Stefan Monnier, 2020/11/28
- [elpa] externals/lmc 3b26656 08/14: * lmc.el (lmc-asm-indentation): Indent to tab-width by default., Stefan Monnier, 2020/11/28
- [elpa] externals/lmc 6cd76ac 05/14: * packages/lmc/lmc.el (lmc-store-word): match-data can change in sit-for., Stefan Monnier, 2020/11/28
- [elpa] externals/lmc 0604c74 09/14: Add "rudel" to the list of externals., Stefan Monnier, 2020/11/28
- [elpa] externals/lmc cb110db 14/14: * .gitignore: New file, Stefan Monnier, 2020/11/28
- [elpa] externals/lmc 4e16a02 10/14: * packages/lmc/lmc.el (lmc--load-word): Remove unused vars., Stefan Monnier, 2020/11/28
- [elpa] externals/lmc 47cc7a9 11/14: * lmc.el: Use cl-lib, Stefan Monnier, 2020/11/28
- [elpa] externals/lmc d0ca555 03/14: 2011-09-29 Stefan Monnier <address@hidden>, Stefan Monnier, 2020/11/28
- [elpa] externals/lmc 5a8a6a3 06/14: * lmc.el (lmc-turbo): New option., Stefan Monnier, 2020/11/28
- [elpa] externals/lmc b65ac80 12/14: * lmc.el: Mention dependencies & bumpp version, Stefan Monnier, 2020/11/28