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

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

[elpa] externals/gnugo 8cabdfa 042/357: [gnugo int] Use internal macros


From: Stefan Monnier
Subject: [elpa] externals/gnugo 8cabdfa 042/357: [gnugo int] Use internal macros more.
Date: Sun, 29 Nov 2020 14:50:44 -0500 (EST)

branch: externals/gnugo
commit 8cabdfa9b14e82e722ec2e3810d38b04cc28c430
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [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.
---
 gnugo.el | 53 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 7e39431..6bc6e46 100644
--- a/gnugo.el
+++ b/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]