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

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

[elpa] externals/gnugo dd6b6f8 186/357: [gnugo] New command: ‘C’ (gnugo


From: Stefan Monnier
Subject: [elpa] externals/gnugo dd6b6f8 186/357: [gnugo] New command: ‘C’ (gnugo-comment)
Date: Sun, 29 Nov 2020 14:51:18 -0500 (EST)

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

    [gnugo] New command: ‘C’ (gnugo-comment)
    
    * packages/gnugo/gnugo.el (gnugo-comment): New command.
    (gnugo-board-mode-map): Add binding for ‘C’.
---
 HACKING  |  1 -
 NEWS     |  1 +
 gnugo.el | 20 ++++++++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/HACKING b/HACKING
index 9110ef0..0051b85 100644
--- a/HACKING
+++ b/HACKING
@@ -20,7 +20,6 @@ This file is both a guide for newcomers and a todo list for 
oldstayers.
 *** using assist minor mode, gnugo-v-gnugo (ibid)
 *** make gnugo (the external program) support query (read-only) thread
 *** extend GNUGO Board mode to manage another subprocess for analysis only
-*** command ‘C’ to add a comment to the SGF tree
 *** command ‘C-u =’ to label a position
 *** SGF tree traversal
 *** "undo undo undoing"; integrate Emacs undo, GTP undo, subgame branching
diff --git a/NEWS b/NEWS
index 8a97a25..12ef38d 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,7 @@ NB: "RCS: X..Y " means that the particular release includes
   - ‘=’ also displays move number of the stone (if any) at that position
   - new keybinding for ‘gnugo-undo-one-move’: M-u
   - ‘gnugo-undo-one-move’ can optionally arrange for you to play next
+  - new command: ‘C’ (gnugo-comment)
   - new command: ‘o’ (gnugo-oops)
   - new command: ‘O’ (gnugo-okay)
   - new command: ‘L’ (gnugo-frolic-in-the-leaves)
diff --git a/gnugo.el b/gnugo.el
index 7c52087..632d2bf 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -2162,6 +2162,25 @@ If there a stone at that position, also display its move 
number."
                  (switch-to-buffer buf))
         finally do (message "(only one)")))
 
+(defun gnugo-comment (node comment)
+  "Add to NODE a COMMENT (string) property.
+Called interactively, NODE is the one corresponding to the
+stone at point, and any previous comment is inserted as the
+initial-input (see `read-string').
+
+If COMMENT is nil or the empty string, remove the property entirely."
+  (interactive
+   (let* ((pos (gnugo-position))
+          (node (or (gnugo--node-with-played-stone pos)
+                    (user-error "No stone at %s" pos))))
+     (list node
+           (read-string (format "Comment for %s: "
+                                (gnugo-describe-position))
+                        (cdr (assq :C node))))))
+  (setq node (delq (assq :C node) node))
+  (unless (zerop (length comment))
+    (gnugo--decorate node `((:C . ,comment)))))
+
 ;;;---------------------------------------------------------------------------
 ;;; Command properties and gnugo-command
 
@@ -2473,6 +2492,7 @@ starting a new one.  See `gnugo-board-mode' documentation 
for more info."
           ("l"        . gnugo-read-sgf-file)
           ("F"        . gnugo-display-final-score)
           ("A"        . gnugo-switch-to-another)
+          ("C"        . gnugo-comment)
           ;; mouse
           ([(down-mouse-1)] . gnugo-mouse-move)
           ([(down-mouse-2)] . gnugo-mouse-move) ; mitigate accidents



reply via email to

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