Subject: Fix drawing the horizontal line

From: Asher Gordon <[email-masked]>
Date: Sun, 22 Mar 2020 23:26:16 -0400

Whoops! I accidentally broke drawing the horizontal line when someone
wins horizontally. Here is the patch below:
--- gomoku.el~	2020-03-21 19:13:36.284656730 -0400
+++ gomoku.el	2020-03-22 23:11:48.313804581 -0400
@@ -1114,7 +1114,7 @@
 	(setq square1 (+ square1 depl))
 	(cond
 	  ((= dy 0)			; Horizontal
-	   (gomoku-move-right)
+	   (forward-char 1)
 	   (insert-char ?- (1- gomoku-square-width) t)
 	   (delete-region (point) (progn
 				    (skip-chars-forward " \t")
And as before, I've also attached the fixed patch so you only have to
apply one patch.

Asher

-- 
One picture is worth 128K words.
                               --------
I prefer to send and receive mail encrypted. Please send me your
public key, and if you do not have my public key, please let me
know. Thanks.

GPG fingerprint: 38F3 975C D173 4037 B397  8095 D4C9 C4FC 5460 8E68
diff -u gomoku.el gomoku.el
--- gomoku.el	2020-03-21 19:13:36.284656730 -0400
+++ gomoku.el	2020-03-22 23:11:48.313804581 -0400
@@ -110,8 +110,8 @@
     (define-key map "u" 'gomoku-move-ne)		    ; u
     (define-key map "b" 'gomoku-move-sw)		    ; b
     (define-key map "n" 'gomoku-move-se)		    ; n
-    (define-key map "h" 'backward-char)			    ; h
-    (define-key map "l" 'forward-char)			    ; l
+    (define-key map "h" 'gomoku-move-left)		    ; h
+    (define-key map "l" 'gomoku-move-right)		    ; l
     (define-key map "j" 'gomoku-move-down)		    ; j
     (define-key map "k" 'gomoku-move-up)		    ; k
 
@@ -119,11 +119,13 @@
     (define-key map [kp-9] 'gomoku-move-ne)
     (define-key map [kp-1] 'gomoku-move-sw)
     (define-key map [kp-3] 'gomoku-move-se)
-    (define-key map [kp-4] 'backward-char)
-    (define-key map [kp-6] 'forward-char)
+    (define-key map [kp-4] 'gomoku-move-left)
+    (define-key map [kp-6] 'gomoku-move-right)
     (define-key map [kp-2] 'gomoku-move-down)
     (define-key map [kp-8] 'gomoku-move-up)
 
+    (define-key map "\C-b" 'gomoku-move-left)		    ; C-b
+    (define-key map "\C-f" 'gomoku-move-right)		    ; C-f
     (define-key map "\C-n" 'gomoku-move-down)		    ; C-n
     (define-key map "\C-p" 'gomoku-move-up)		    ; C-p
 
@@ -146,6 +148,10 @@
     (define-key map [mouse-2] 'gomoku-mouse-play)
     (define-key map [drag-mouse-2] 'gomoku-mouse-play)
 
+    (define-key map [remap backward-char] 'gomoku-move-left)
+    (define-key map [remap left-char] 'gomoku-move-left)
+    (define-key map [remap forward-char] 'gomoku-move-right)
+    (define-key map [remap right-char] 'gomoku-move-right)
     (define-key map [remap previous-line] 'gomoku-move-up)
     (define-key map [remap next-line] 'gomoku-move-down)
     (define-key map [remap move-beginning-of-line] 'gomoku-beginning-of-line)
@@ -954,6 +960,11 @@
 	 ;; 2 instead of 1 because WINDOW-HEIGHT includes the mode line !
 	 gomoku-square-height)))
 
+(defun gomoku-point-x ()
+  "Return the board column where point is."
+  (1+ (/ (- (current-column) gomoku-x-offset)
+	 gomoku-square-width)))
+
 (defun gomoku-point-y ()
   "Return the board row where point is."
   (1+ (/ (- (count-lines (point-min) (point))
@@ -1143,13 +1154,28 @@
           (skip-chars-forward gomoku--intangible-chars)
           (when (eobp)
             (skip-chars-backward gomoku--intangible-chars)
-            (forward-char -1)))
+            (gomoku-move-left)))
       (skip-chars-backward gomoku--intangible-chars)
       (if (bobp)
           (skip-chars-forward gomoku--intangible-chars)
-        (forward-char -1))))
+        (gomoku-move-left))))
   (setq gomoku--last-pos (point)))
 
+;; forward-char and backward-char don't always move the right number
+;; of characters. Also, these functions check if you're on the edge of
+;; the screen.
+(defun gomoku-move-right ()
+  "Move point right one column on the Gomoku board."
+  (interactive)
+  (when (< (gomoku-point-x) gomoku-board-width)
+    (forward-char gomoku-square-width)))
+
+(defun gomoku-move-left ()
+  "Move point left one column on the Gomoku board."
+  (interactive)
+  (when (> (gomoku-point-x) 1)
+    (backward-char gomoku-square-width)))
+
 ;; previous-line and next-line don't work right with intangible newlines
 (defun gomoku-move-down ()
   "Move point down one row on the Gomoku board."
@@ -1171,25 +1197,25 @@
   "Move point North East on the Gomoku board."
   (interactive)
   (gomoku-move-up)
-  (forward-char))
+  (gomoku-move-right))
 
 (defun gomoku-move-se ()
   "Move point South East on the Gomoku board."
   (interactive)
   (gomoku-move-down)
-  (forward-char))
+  (gomoku-move-right))
 
 (defun gomoku-move-nw ()
   "Move point North West on the Gomoku board."
   (interactive)
   (gomoku-move-up)
-  (backward-char))
+  (gomoku-move-left))
 
 (defun gomoku-move-sw ()
   "Move point South West on the Gomoku board."
   (interactive)
   (gomoku-move-down)
-  (backward-char))
+  (gomoku-move-left))
 
 (defun gomoku-beginning-of-line ()
   "Move point to first square on the Gomoku board row."