emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 02/06: [gnugo int] Use internal macros more.


From: Thien-Thi Nguyen
Subject: [elpa] 02/06: [gnugo int] Use internal macros more.
Date: Sat, 22 Feb 2014 12:52:29 +0000

ttn pushed a commit to branch ttn-gnugo
in repository elpa.

commit 6c7a24b2e2b124cbc523b070652bea53d3d23b2c
Author: Thien-Thi Nguyen <address@hidden>
Date:   Thu Feb 20 12:50:30 2014 +0100

    [gnugo int] Use internal macros more.
    
    * packages/gnugo/gnugo.el
    (:gnugo-gtp-command-spec deffull): New macro.
    (:gnugo-gtp-command-spec): Use it for ‘:full’ specs.
---
 packages/gnugo/gnugo.el |   53 ++++++++++++++++++++++++----------------------
 1 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 7e39431..6bc6e46 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1850,9 +1850,12 @@ starting a new one.  See `gnugo-board-mode' 
documentation for more info."
                                    (while ls
                                      (jam cmd (car ls) (cadr ls))
                                      (setq ls (cddr ls)))))))
+    (cl-macrolet ((deffull (who &body body)
+                    (declare (indent 1))
+                    `(defgtp ',who :full (lambda (sel)
+                                           ,@body))))
 
-    (defgtp 'help :full
-      (lambda (sel)
+      (deffull help
         (info "(gnugo)GTP command reference")
         (when sel (setq sel (intern (car sel))))
         (let (buffer-read-only pad cur spec output found)
@@ -1883,29 +1886,29 @@ starting a new one.  See `gnugo-board-mode' 
documentation for more info."
                   (setq found (match-beginning 0))))))
           (cond (found (goto-char found))
                 ((not sel))
-                (t (message "(no such command: %s)" sel))))))
-
-    (defgtp 'final_score :full
-      (lambda (sel) (gnugo-display-final-score)))
-
-    (defgtp '(boardsize
-              clear_board
-              fixed_handicap)
-      :output :discard
-      :post-thunk (lambda ()
-                    (gnugo--unclose-game)
-                    (gnugo-put :last-mover nil)
-                    (gnugo-refresh t)))
-
-    (defgtp 'loadsgf :full
-      (lambda (sel) (gnugo-read-sgf-file (car sel))))
-
-    (defgtp '(undo gg-undo) :full
-      (lambda (sel) (gnugo-magic-undo
-                     (let (n)
-                       (cond ((not sel) 1)
-                             ((cl-plusp (setq n (string-to-number (car sel)))) 
n)
-                             (t (car sel)))))))))
+                (t (message "(no such command: %s)" sel)))))
+
+      (deffull final_score
+        (gnugo-display-final-score))
+
+      (defgtp '(boardsize
+                clear_board
+                fixed_handicap)
+        :output :discard
+        :post-thunk (lambda ()
+                      (gnugo--unclose-game)
+                      (gnugo-put :last-mover nil)
+                      (gnugo-refresh t)))
+
+      (deffull loadsgf
+        (gnugo-read-sgf-file (car sel)))
+
+      (deffull (undo gg-undo)
+        (gnugo-magic-undo
+         (let (n)
+           (cond ((not sel) 1)
+                 ((cl-plusp (setq n (string-to-number (car sel)))) n)
+                 (t (car sel)))))))))
 
 (provide 'gnugo)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]