[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 03/04: [gnugo int] Add abstraction: gnugo--as-cc-func
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 03/04: [gnugo int] Add abstraction: gnugo--as-cc-func |
Date: |
Sat, 12 Apr 2014 10:27:40 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 08ee2783101ad8f8499f400e18660dbf643fc17a
Author: Thien-Thi Nguyen <address@hidden>
Date: Sat Apr 12 12:17:40 2014 +0200
[gnugo int] Add abstraction: gnugo--as-cc-func
* packages/gnugo/gnugo.el (gnugo--as-cc-func): New func.
(gnugo-note): Use ‘gnugo--as-cc-func’.
---
packages/gnugo/gnugo.el | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 900fcb2..3b7b326 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1115,17 +1115,22 @@ This fails if the monkey is on the current branch
(eq (aref ends (aref monkey 1))
(aref monkey 0)))
+(defun gnugo--as-cc-func ()
+ (lexical-let ((size (gnugo-get :SZ)))
+ (lambda (pos)
+ (let* ((col (aref pos 0))
+ (one (+ ?a (- col (if (< ?H col) 1 0) ?A)))
+ (two (+ ?a (- size (string-to-number
+ (substring pos 1))))))
+ (format "%c%c" one two)))))
+
(defun gnugo-note (property value &optional mogrifyp)
(when mogrifyp
- (let ((sz (gnugo-get :SZ)))
+ (let ((as-cc (gnugo--as-cc-func)))
(cl-flet
((mog (pos) (if (gnugo--passp pos)
""
- (let* ((col (aref pos 0))
- (one (+ ?a (- col (if (< ?H col) 1 0) ?A)))
- (two (+ ?a (- sz (string-to-number
- (substring pos 1))))))
- (format "%c%c" one two)))))
+ (funcall as-cc pos))))
(setq value (if (consp value)
(mapcar #'mog value)
(mog value))))))