aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-02-07 06:05:31 +0000
committerRichard M. Stallman1994-02-07 06:05:31 +0000
commit0720cc69b6468b0050ef4b22967c53cb52bbbdd4 (patch)
tree5bbb714ed524813f27ce473b69efd9c4f75dbe4a
parent628d6cef6eef07ddb0907d628cdf2a95502968e3 (diff)
downloademacs-0720cc69b6468b0050ef4b22967c53cb52bbbdd4.tar.gz
emacs-0720cc69b6468b0050ef4b22967c53cb52bbbdd4.zip
(gomoku-init-display, gomoku-put-char):
Bind inhibit-read-only; don't set buffer-read-only.
-rw-r--r--lisp/play/gomoku.el64
1 files changed, 31 insertions, 33 deletions
diff --git a/lisp/play/gomoku.el b/lisp/play/gomoku.el
index 0bc047682b5..0d9920f7730 100644
--- a/lisp/play/gomoku.el
+++ b/lisp/play/gomoku.el
@@ -910,43 +910,41 @@ If the game is finished, this command requests for another game."
910 910
911(defun gomoku-put-char (char) 911(defun gomoku-put-char (char)
912 "Draw CHAR on the Gomoku screen." 912 "Draw CHAR on the Gomoku screen."
913 (if buffer-read-only (toggle-read-only)) 913 (let ((inhibit-read-only t))
914 (insert char) 914 (insert char)
915 (delete-char 1) 915 (delete-char 1)
916 (backward-char 1) 916 (backward-char 1)))
917 (toggle-read-only))
918 917
919(defun gomoku-init-display (n m) 918(defun gomoku-init-display (n m)
920 "Display an N by M Gomoku board." 919 "Display an N by M Gomoku board."
921 (buffer-disable-undo (current-buffer)) 920 (buffer-disable-undo (current-buffer))
922 (if buffer-read-only (toggle-read-only)) 921 (let ((inhibit-read-only t))
923 (erase-buffer) 922 (erase-buffer)
924 (let (string1 string2 string3 string4) 923 (let (string1 string2 string3 string4)
925 ;; We do not use gomoku-plot-square which would be too slow for 924 ;; We do not use gomoku-plot-square which would be too slow for
926 ;; initializing the display. Rather we build STRING1 for lines where 925 ;; initializing the display. Rather we build STRING1 for lines where
927 ;; board squares are to be found, and STRING2 for empty lines. STRING1 is 926 ;; board squares are to be found, and STRING2 for empty lines. STRING1 is
928 ;; like STRING2 except for dots every DX squares. Empty lines are filled 927 ;; like STRING2 except for dots every DX squares. Empty lines are filled
929 ;; with spaces so that cursor moving up and down remains on the same 928 ;; with spaces so that cursor moving up and down remains on the same
930 ;; column. 929 ;; column.
931 (setq string1 (concat (make-string (1- gomoku-square-width) ? ) ".") 930 (setq string1 (concat (make-string (1- gomoku-square-width) ? ) ".")
932 string1 (apply 'concat 931 string1 (apply 'concat
933 (make-list (1- n) string1)) 932 (make-list (1- n) string1))
934 string1 (concat (make-string gomoku-x-offset ? ) "." string1 "\n") 933 string1 (concat (make-string gomoku-x-offset ? ) "." string1 "\n")
935 string2 (make-string (+ 1 gomoku-x-offset 934 string2 (make-string (+ 1 gomoku-x-offset
936 (* (1- n) gomoku-square-width)) 935 (* (1- n) gomoku-square-width))
937 ? ) 936 ? )
938 string2 (concat string2 "\n") 937 string2 (concat string2 "\n")
939 string3 (apply 'concat 938 string3 (apply 'concat
940 (make-list (1- gomoku-square-height) string2)) 939 (make-list (1- gomoku-square-height) string2))
941 string3 (concat string3 string1) 940 string3 (concat string3 string1)
942 string3 (apply 'concat 941 string3 (apply 'concat
943 (make-list (1- m) string3)) 942 (make-list (1- m) string3))
944 string4 (apply 'concat 943 string4 (apply 'concat
945 (make-list gomoku-y-offset string2))) 944 (make-list gomoku-y-offset string2)))
946 (insert string4 string1 string3)) 945 (insert string4 string1 string3))
947 (toggle-read-only) 946 (gomoku-goto-xy (/ (1+ n) 2) (/ (1+ m) 2)) ; center of the board
948 (gomoku-goto-xy (/ (1+ n) 2) (/ (1+ m) 2)) ; center of the board 947 (sit-for 0))) ; Display NOW
949 (sit-for 0)) ; Display NOW
950 948
951(defun gomoku-display-statistics () 949(defun gomoku-display-statistics ()
952 "Obnoxiously display some statistics about previous games in mode line." 950 "Obnoxiously display some statistics about previous games in mode line."