[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 02/03: [gnugo] New command: ‘ C’ (gnugo-comment)
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 02/03: [gnugo] New command: ‘ C’ (gnugo-comment) |
Date: |
Mon, 14 Apr 2014 13:32:56 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit d63a2a069bbeea338112d4b436100609ba6cdf8a
Author: Thien-Thi Nguyen <address@hidden>
Date: Mon Apr 14 15:05:10 2014 +0200
[gnugo] New command: ‘C’ (gnugo-comment)
* packages/gnugo/gnugo.el (gnugo-comment): New command.
(gnugo-board-mode-map): Add binding for ‘C’.
---
packages/gnugo/HACKING | 1 -
packages/gnugo/NEWS | 1 +
packages/gnugo/gnugo.el | 20 ++++++++++++++++++++
3 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/packages/gnugo/HACKING b/packages/gnugo/HACKING
index 9110ef0..0051b85 100644
--- a/packages/gnugo/HACKING
+++ b/packages/gnugo/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/packages/gnugo/NEWS b/packages/gnugo/NEWS
index 8a97a25..12ef38d 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/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/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 7c52087..632d2bf 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/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