[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 5566285 026/357: [gnugo] Give names and docstrin
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 5566285 026/357: [gnugo] Give names and docstrings to ‘lambda’ commands. |
Date: |
Sun, 29 Nov 2020 14:50:40 -0500 (EST) |
branch: externals/gnugo
commit 55662852fd825457e8d7445829cacd5a9b4a5d64
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo] Give names and docstrings to ‘lambda’ commands.
* packages/gnugo/gnugo.el (gnugo-quit, gnugo-leave-me-alone)
(gnugo-fancy-undo, gnugo-toggle-image-display-command)
(gnugo-describe-position): New commands.
(gnugo-board-mode-map): Bind ‘q’, ‘Q’, ‘U’, ‘i’, ‘=’ to them.
---
gnugo.el | 59 ++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 42 insertions(+), 17 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index 5673360..4ca0da0 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1478,6 +1478,43 @@ Also, add the `:RE' SGF property to the root node of the
game tree."
(erase-buffer)
(insert blurb)))
+(defun gnugo-quit ()
+ "Kill the current buffer, assumed to be in GNUGO Board mode, maybe.
+If the game is not over, ask for confirmation first."
+ (interactive)
+ (if (or (gnugo-get :game-over)
+ (y-or-n-p "Quit? "))
+ (kill-buffer nil)
+ (message "(not quitting)")))
+
+(defun gnugo-leave-me-alone ()
+ "Kill the current buffer unconditionally."
+ (interactive)
+ (kill-buffer nil))
+
+(defun gnugo-fancy-undo (count)
+ "Rewind the game tree in various ways.
+Prefix arg COUNT means to undo that many moves.
+Otherwise, undo repeatedly up to and including the move
+which placed the stone at point."
+ (interactive "P")
+ (gnugo-magic-undo
+ ;; TODO: Move this into `gnugo-magic-undo' proper.
+ (cond ((numberp count) count)
+ ((consp count) (car count))
+ (t (gnugo-position)))))
+
+(defun gnugo-toggle-image-display-command () ; ugh
+ "Toggle use of images to display the board, then refresh."
+ (interactive)
+ (gnugo-toggle-image-display)
+ (save-excursion (gnugo-refresh)))
+
+(defun gnugo-describe-position ()
+ "Display the board position under cursor in the echo area."
+ (interactive)
+ (message "%s" (gnugo-position)))
+
;;;---------------------------------------------------------------------------
;;; Command properties and gnugo-command
@@ -1781,26 +1818,15 @@ starting a new one. See `gnugo-board-mode'
documentation for more info."
(" " . gnugo-move)
("P" . gnugo-pass)
("R" . gnugo-resign)
- ("q" . (lambda () (interactive)
- (if (or (gnugo-get :game-over)
- (y-or-n-p "Quit? "))
- (kill-buffer nil)
- (message "(not quitting)"))))
- ("Q" . (lambda () (interactive)
- (kill-buffer nil)))
- ("U" . (lambda (x) (interactive "P")
- (gnugo-magic-undo
- (cond ((numberp x) x)
- ((consp x) (car x))
- (t (gnugo-position))))))
+ ("q" . gnugo-quit)
+ ("Q" . gnugo-leave-me-alone)
+ ("U" . gnugo-fancy-undo)
("u" . gnugo-undo-two-moves)
("\C-l" . gnugo-refresh)
("\M-_" . bury-buffer)
("_" . bury-buffer)
("h" . gnugo-move-history)
- ("i" . (lambda () (interactive)
- (gnugo-toggle-image-display)
- (save-excursion (gnugo-refresh))))
+ ("i" . gnugo-toggle-image-display-command)
("w" . gnugo-worm-stones)
("W" . gnugo-worm-data)
("d" . gnugo-dragon-stones)
@@ -1810,8 +1836,7 @@ starting a new one. See `gnugo-board-mode' documentation
for more info."
("!" . gnugo-estimate-score)
(":" . gnugo-command)
(";" . gnugo-command)
- ("=" . (lambda () (interactive)
- (message (gnugo-position))))
+ ("=" . gnugo-describe-position)
("s" . gnugo-write-sgf-file)
("\C-x\C-s" . gnugo-write-sgf-file)
("\C-x\C-w" . gnugo-write-sgf-file)
- [elpa] externals/gnugo a667440 298/357: [gnugo int] Fix up gnugo-frolic.el ‘require’ forms., (continued)
- [elpa] externals/gnugo a667440 298/357: [gnugo int] Fix up gnugo-frolic.el ‘require’ forms., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo abd1fa0 315/357: [gnugo int] Use ‘replace-regexp-in-string’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 2e6bbe5 300/357: [gnugo int] Whitespace, comment munging; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo c0f6ed5 328/357: [gnugo int] Comment munging; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo cf36ccd 331/357: [gnugo int] Whitespace munging; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a70a854 336/357: [gnugo] Add abstraction: gnugo-aqr, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 1eb43f1 342/357: [gnugo int] Add abstraction: gnugo--zonk-ovs, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo abb12ef 345/357: [gnugo] Include seki groups in game-over data., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 82c5b64 351/357: [gnugo imgen] New fit func to ignore bottom grid line, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 152c53c 354/357: [gnugo] Move two funcs internal., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5566285 026/357: [gnugo] Give names and docstrings to ‘lambda’ commands.,
Stefan Monnier <=
- [elpa] externals/gnugo 62a7c8d 052/357: [gnugo slog] Specify second arg to ‘unintern’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo eae8444 113/357: [gnugo int] Specify STREAM to ‘pp’ directly., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 00ae088 120/357: [gnugo int] Use ‘gnugo--tree-ends’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo fa99b79 134/357: [gnugo int] Make ‘gnugo-board-buffer-p’ precise., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 8f99c83 151/357: [gnugo frolic int] Don't bother to awake w/ ‘col’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 283534a 157/357: [gnugo sgf int] Consolidate loops., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 671d7aa 147/357: [gnugo frolic] Sync column headers w/ buffer text; handle offsets., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 45fe672 169/357: [gnugo int] Move :SZ access into ‘gnugo--as-pos-func’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5e24ee5 182/357: [gnugo int] Use GTP ‘reg_genmove’ instead of ‘genmove’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e387d96 193/357: [gnugo int] Accept color for ‘gnugo-push-move’ 1st arg., Stefan Monnier, 2020/11/29