[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] 2 small patches for gnugo.el from gnugo 3.7.2
From: |
Mike FABIAN |
Subject: |
[gnugo-devel] 2 small patches for gnugo.el from gnugo 3.7.2 |
Date: |
Mon, 31 Jan 2005 21:32:13 +0100 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.5 (chestnut, linux) |
First patch "mouse-2-dont-insert-junk.patch":
When accidentally clicking the middle mouse button instead of the left
mouse button to make a move, junk text is inserted into the Goban. I
think the easiest way to prevent this is to bind the middle mouse
button to make a move as well.
Second patch "xemacs.patch":
This is a first try to make gnugo.el (from gnugo 3.7.2) work with
XEmacs.
First problem: 'split-string' apparently behaves differently in XEmacs
and Emacs, for example:
XEmacs:
(split-string "" " ") -> ("")
Emacs
(split-string "" " ") -> nil
I tried to solve that by introducing a compatibility wrapper
around split string.
Second problem:
XEmacs doesn't have a function 'window-edges'. But apparently
'window-edges' isn't really needed in gnugo.el, 'window-width' seems
to work fine for both XEmacs and Emacs.
This patch doesn't yet make the graphical interface work in XEmacs,
the functions for inline-images are quite a bit different as well. But
at least the ASCII text interface works in XEmacs with that patch.
If I have time, I'll try to make the graphics work as well.
diff -ru gnugo-3.7.2.orig/interface/gnugo.el gnugo-3.7.2/interface/gnugo.el
--- gnugo-3.7.2.orig/interface/gnugo.el 2005-01-20 00:25:34.000000000 +0100
+++ gnugo-3.7.2/interface/gnugo.el 2005-01-31 20:41:14.713505572 +0100
@@ -2115,6 +2115,7 @@
("F" . gnugo-display-final-score)
;; mouse
([(down-mouse-1)] . gnugo-mouse-move)
+ ([(down-mouse-2)] . gnugo-mouse-move)
([(down-mouse-3)] . gnugo-mouse-pass))))
(unless (get 'help :gnugo-gtp-command-spec)
diff -ru gnugo-3.7.2.orig/interface/gnugo.el gnugo-3.7.2/interface/gnugo.el
--- gnugo-3.7.2.orig/interface/gnugo.el 2005-01-20 00:25:34.000000000 +0100
+++ gnugo-3.7.2/interface/gnugo.el 2005-01-31 20:28:29.465803797 +0100
@@ -277,6 +277,17 @@
(defvar gnugo-xpms nil))
;;;---------------------------------------------------------------------------
+;;; In case XEmacs/Emacs compatibility
+
+(defun gnugo-split-string (string &optional separators)
+ (if (not (featurep 'xemacs))
+ (split-string string separators)
+ (let ((retval (split-string string separators)))
+ (if (equal retval '(""))
+ nil
+ retval))))
+
+;;;---------------------------------------------------------------------------
;;; In case Emacs is lacking
(unless (fboundp 'delete-dups)
@@ -808,8 +819,8 @@
(flet ((ls (color) (mapcar
(lambda (x)
(cons (list color)
- (split-string x)))
- (split-string
+ (gnugo-split-string x)))
+ (gnugo-split-string
(gnugo-query "worm_stones %s"
color)
"\n"))))
@@ -824,7 +835,7 @@
color (match-string 2 dd)
start (match-end 0)
ent (cons (list color)
- (sort (split-string
+ (sort (gnugo-split-string
(gnugo-query "dragon_stones %s" mem))
'string<)))
(string-match "\nstatus[ ]+\\(\\(ALIVE\\)\\|[A-Z]+\\)\n"
@@ -975,9 +986,7 @@
(round (* size (gnugo-get :hmul)))
1)
-5))
- (edges (window-edges window))
- (right-w-edge (nth 2 edges))
- (avail-width (- right-w-edge (nth 0 edges)))
+ (avail-width (window-width))
(w (/ (- avail-width
(+ (* size (gnugo-get :wmul))
(if (symbol-plist (gnugo-f 'ispc))
@@ -1156,13 +1165,13 @@
(format "%s %s" command (gnugo-position))))))
(unless (= ?= (aref stones 0))
(error stones))
- (setq stones (split-string (substring stones 1)))
+ (setq stones (gnugo-split-string (substring stones 1)))
(message "Computing %s ... %s in group." command (length stones))
(setplist (gnugo-f 'anim) nil)
(let* ((spec (let ((spec
- ;; `(split-string gnugo-animation-string "" t)'
+ ;; `(gnugo-split-string gnugo-animation-string "" t)'
;; works as well, for newer emacs versions
- (delete "" (split-string gnugo-animation-string ""))))
+ (delete "" (gnugo-split-string gnugo-animation-string
""))))
(cond ((gnugo-get :display-using-images)
(let* ((yin (get-text-property (point) 'gnugo-yin))
(yang (gnugo-yang (char-after)))
@@ -1292,8 +1301,8 @@
by how many stones)."
(interactive)
(message "Est.score ...")
- (let ((black (length (split-string (gnugo-query "list_stones black"))))
- (white (length (split-string (gnugo-query "list_stones white"))))
+ (let ((black (length (gnugo-split-string (gnugo-query "list_stones black"))))
+ (white (length (gnugo-split-string (gnugo-query "list_stones white"))))
(black-captures (gnugo-query "captures black"))
(white-captures (gnugo-query "captures white"))
(est (gnugo-query "estimate_score")))
@@ -1348,8 +1357,8 @@
"Start a new sgf tree"
(gnugo-put :sgf-tree (list (list)))
(let ((g-blackp (string= "black" (gnugo-get :gnugo-color)))
- (black-stones (split-string (gnugo-query "list_stones black") " "))
- (white-stones (split-string (gnugo-query "list_stones white") " ")))
+ (black-stones (gnugo-split-string (gnugo-query "list_stones black") "
"))
+ (white-stones (gnugo-split-string (gnugo-query "list_stones white") "
")))
(mapc (lambda (x) (apply 'gnugo-note x))
`((:GM 1)
(:FF 4) ; hmm maybe better: 3
@@ -1390,8 +1399,8 @@
(gnugo-command (format "loadsgf %s" (expand-file-name filename)))
(let* ((colorhistory
(mapcar
- (lambda (x) (split-string x " "))
- (split-string
+ (lambda (x) (gnugo-split-string x " "))
+ (gnugo-split-string
(cdr (gnugo-synchronous-send/return "move_history")) "[=\n]")))
(k (length colorhistory)))
(unless (equal colorhistory '(nil)) ; empty move history gives this
@@ -1418,10 +1427,10 @@
(not
(string= "PASS"
(nth 1
- (split-string (gnugo-query "last_move") " ")))))
+ (gnugo-split-string (gnugo-query "last_move") "
")))))
(if (equal
(car
- (split-string
+ (gnugo-split-string
(cdr (gnugo-synchronous-send/return "undo")) " ")) "?")
(error "cannot undo")
(gnugo-put :future-history
@@ -1590,8 +1599,8 @@
first time the function is run, you will be prompted for the
path to that directory."
(interactive "sTest: ")
- (let* ((file (car (split-string test ":")))
- (testnumber (nth 1 (split-string test ":")))
+ (let* ((file (car (gnugo-split-string test ":")))
+ (testnumber (nth 1 (gnugo-split-string test ":")))
(gnugo-buffer (current-buffer))
(file-already-open nil))
(unless gnugo-regression-directory
@@ -1622,7 +1631,7 @@
(buffer-substring
(line-beginning-position)
(line-end-position))))
- (first-line-split (split-string first-line)))
+ (first-line-split (gnugo-split-string first-line)))
; don't close the file if the user was visiting it
(unless file-already-open (kill-buffer (current-buffer)))
(switch-to-buffer gnugo-buffer)
@@ -1690,8 +1699,8 @@
(terr-q (format "final_status_list %%s_territory %d" seed))
(terr "territory")
(capt "captures")
- (b-terr (length (split-string (gnugo-query terr-q "black"))))
- (w-terr (length (split-string (gnugo-query terr-q "white"))))
+ (b-terr (length (gnugo-split-string (gnugo-query terr-q
"black"))))
+ (w-terr (length (gnugo-split-string (gnugo-query terr-q
"white"))))
(b-capt (string-to-number (gnugo-get :black-captures)))
(w-capt (string-to-number (gnugo-get :white-captures)))
(komi (gnugo-get :komi)))
@@ -1794,7 +1803,7 @@
(interactive "sCommand: ")
(if (string= "" command)
(message "(no command given)")
- (let* ((split (split-string command))
+ (let* ((split (gnugo-split-string command))
(cmd (intern (car split)))
(spec (get cmd :gnugo-gtp-command-spec))
(full (plist-get spec :full))
@@ -1959,7 +1968,7 @@
(gnugo-put :rules (if (string-match "--chinese-rules" args)
"Chinese"
"Japanese"))
- (let ((proc-args (split-string args)))
+ (let ((proc-args (gnugo-split-string args)))
(gnugo-put :proc-args proc-args)
(gnugo-put :proc (apply 'start-process "gnugo" nil name
"--mode" "gtp" "--quiet"
--
Mike FABIAN <address@hidden> http://www.suse.de/~mfabian
睡眠不足はいい仕事の敵だ。
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnugo-devel] 2 small patches for gnugo.el from gnugo 3.7.2,
Mike FABIAN <=