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

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

[elpa] 03/07: [gnugo gtp int] Use :post-thunk instead of :post-hook.


From: Thien-Thi Nguyen
Subject: [elpa] 03/07: [gnugo gtp int] Use :post-thunk instead of :post-hook.
Date: Thu, 06 Feb 2014 10:39:44 +0000

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

commit 66637919eaf07222d25d6113cd1d6a58cdf7e4b2
Author: Thien-Thi Nguyen <address@hidden>
Date:   Wed Feb 5 11:34:00 2014 +0100

    [gnugo gtp int] Use :post-thunk instead of :post-hook.
    
    * packages/gnugo/gnugo.el (gnugo-command):
    Consult :post-thunk, if set, ‘funcall’ the value.
    (:gnugo-gtp-command-spec add): Delete.
    (:gnugo-gtp-command-spec defgtp): Use ‘jam’ unconditionally.
    (:gnugo-gtp-command-spec): Do ‘s/:post-hook/:post-thunk/g’.
---
 packages/gnugo/ChangeLog |   10 ++++++++++
 packages/gnugo/gnugo.el  |   26 ++++++++------------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/packages/gnugo/ChangeLog b/packages/gnugo/ChangeLog
index af50d1e..c4cfe76 100644
--- a/packages/gnugo/ChangeLog
+++ b/packages/gnugo/ChangeLog
@@ -1,3 +1,13 @@
+2014-02-05  Thien-Thi Nguyen  <address@hidden>
+
+       [gnugo gtp int] Use :post-thunk instead of :post-hook.
+
+       * gnugo.el (gnugo-command):
+       Consult :post-thunk, if set, ‘funcall’ the value.
+       (:gnugo-gtp-command-spec add): Delete.
+       (:gnugo-gtp-command-spec defgtp): Use ‘jam’ unconditionally.
+       (:gnugo-gtp-command-spec): Do ‘s/:post-hook/:post-thunk/g’.
+
 2014-02-05  Thien-Thi Nguyen  <address@hidden>
 
        [gnugo int] Avoid variable FORMAT for ‘message’.
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 7d82e29..a10994d 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1499,7 +1499,7 @@ Also, add the `:RE' SGF property to the root node of the 
game tree."
 ;;            "*gnugo command output*" if the output has a newline,
 ;;            otherwise use `message'.
 ;;
-;; :post-hook -- normal hook run after output processing (at the very end).
+;; :post-thunk -- run after output processing (at the very end).
 
 (defun gnugo-command (command)
   "Send the Go Text Protocol COMMAND (a string) to GNU Go.
@@ -1538,10 +1538,8 @@ NOTE: At this time, GTP command handling specification 
is still
                      (erase-buffer)
                      (insert ans)
                      (message "Doing %s ... done." command)))
-            (let ((hook
-                   ;; do not elide this binding; `run-hooks' needs it
-                   (plist-get spec :post-hook)))
-              (run-hooks 'hook))))))))
+            (let ((thunk (plist-get spec :post-thunk)))
+              (when thunk (funcall thunk)))))))))
 
 ;;;---------------------------------------------------------------------------
 ;;; Major mode for interacting with a GNUGO subprocess
@@ -1832,18 +1830,10 @@ starting a new one.  See `gnugo-board-mode' 
documentation for more info."
       ((sget (x) (get x :gnugo-gtp-command-spec))
        (jam (cmd prop val) (put cmd :gnugo-gtp-command-spec
                                 (plist-put (sget cmd) prop val)))
-       (add (cmd prop val) (jam cmd prop (let ((cur (plist-get
-                                                     (sget cmd)
-                                                     prop)))
-                                           (append (delete val cur)
-                                                   (list val)))))
        (defgtp (x &rest props) (dolist (cmd (if (symbolp x) (list x) x))
                                  (let ((ls props))
                                    (while ls
-                                     (funcall (if (eq :post-hook (car ls))
-                                                  #'add
-                                                #'jam)
-                                              cmd (car ls) (cadr ls))
+                                     (jam cmd (car ls) (cadr ls))
                                      (setq ls (cddr ls)))))))
 
     (defgtp 'help :full
@@ -1887,10 +1877,10 @@ starting a new one.  See `gnugo-board-mode' 
documentation for more info."
               clear_board
               fixed_handicap)
       :output :discard
-      :post-hook (lambda ()
-                   (gnugo-put :game-over nil)
-                   (gnugo-put :last-mover nil)
-                   (gnugo-refresh t)))
+      :post-thunk (lambda ()
+                    (gnugo-put :game-over nil)
+                    (gnugo-put :last-mover nil)
+                    (gnugo-refresh t)))
 
     (defgtp 'loadsgf :full
       (lambda (sel) (gnugo-read-sgf-file (car sel))))



reply via email to

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