unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Asher Gordon <AsDaGo@posteo.net>
To: 40169@debbugs.gnu.org
Subject: bug#40169: Fix gomoku-plot-square
Date: Sat, 21 Mar 2020 19:22:58 -0400	[thread overview]
Message-ID: <87pnd58f8t.fsf_-_@posteo.net> (raw)
In-Reply-To: <875zexfrs5.fsf_-_@posteo.net> (Asher Gordon's message of "Sat, 21 Mar 2020 15:10:18 -0400")


[-- Attachment #1.1: Type: text/plain, Size: 683 bytes --]

Hi,

It turns out that `backward-char' in `gomoku-plot-square' should not be
replaced. I have attached a patch (gomoku-plot-square.patch) to fix
that.

For your convenience, I've also attached another patch (gomoku.patch)
which combines the previous two patches and this one (with `combinediff'
from `patchutils'). I tested it to make sure it applies cleanly.

Asher

-- 
Only fools are quoted.
		-- Anonymous
                               --------
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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: Fix `gomoku-plot-square' --]
[-- Type: text/x-patch, Size: 366 bytes --]

--- gomoku.el~	2020-03-21 15:06:52.145727337 -0400
+++ gomoku.el	2020-03-21 19:13:36.284656730 -0400
@@ -1000,7 +1000,7 @@
 	  (1- (point)) (point)
 	  '(mouse-face highlight help-echo "mouse-2: play at this square")))
     (delete-char 1)
-    (gomoku-move-left))
+    (backward-char 1))
   (sit-for 0))	; Display NOW
 
 (defun gomoku-init-display (n m)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: Combination of all three patches --]
[-- Type: text/x-patch, Size: 4469 bytes --]

diff -u gomoku.el gomoku.el
--- gomoku.el	2020-03-21 15:06:52.145727337 -0400
+++ gomoku.el	2020-03-21 19:13:36.284656730 -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))
@@ -1103,7 +1114,7 @@
 	(setq square1 (+ square1 depl))
 	(cond
 	  ((= dy 0)			; Horizontal
-	   (forward-char 1)
+	   (gomoku-move-right)
 	   (insert-char ?- (1- gomoku-square-width) t)
 	   (delete-region (point) (progn
 				    (skip-chars-forward " \t")
@@ -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."

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

  reply	other threads:[~2020-03-21 23:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-21 17:20 bug#40169: 26.1; gomoku.el: Fix character movement Asher Gordon
     [not found] ` <handler.40169.B.15848125491336.ack@debbugs.gnu.org>
2020-03-21 19:10   ` bug#40169: Add missing keymaps Asher Gordon
2020-03-21 23:22     ` Asher Gordon [this message]
2020-03-23  3:26       ` bug#40169: Fix drawing the horizontal line Asher Gordon
2020-03-28  8:13         ` Eli Zaretskii
     [not found]           ` <87a740gw4d.fsf@>
2020-04-03 11:51             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pnd58f8t.fsf_-_@posteo.net \
    --to=asdago@posteo.net \
    --cc=40169@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).