[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 26/51: [gnugo] Give names and docstr ings to ‘lambda’ commands.
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 26/51: [gnugo] Give names and docstr ings to ‘lambda’ commands. |
Date: |
Mon, 24 Feb 2014 12:30:21 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 04f45c531a97bfbb9f86ee4ad4d21311a399dd0e
Author: Thien-Thi Nguyen <address@hidden>
Date: Fri Feb 7 10:17:52 2014 +0100
[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.
---
packages/gnugo/gnugo.el | 59 +++++++++++++++++++++++++++++++++-------------
1 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 5673360..4ca0da0 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/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] 18/51: [gnugo maint] Update a musing item in HACKING; nfc., (continued)
- [elpa] 18/51: [gnugo maint] Update a musing item in HACKING; nfc., Thien-Thi Nguyen, 2014/02/24
- [elpa] 25/51: [gnugo int] Use cl-{plus,minus}p more., Thien-Thi Nguyen, 2014/02/24
- [elpa] 27/51: [gnugo int] Hang the sync-return-stash on the process object., Thien-Thi Nguyen, 2014/02/24
- [elpa] 22/51: [gnugo maint] Add .dir-locals.el file, link in HACKING; nfc., Thien-Thi Nguyen, 2014/02/24
- [elpa] 29/51: [gnugo] Indicate buffer not modified after load., Thien-Thi Nguyen, 2014/02/24
- [elpa] 30/51: [gnugo maint] Update NEWS file; nfc., Thien-Thi Nguyen, 2014/02/24
- [elpa] 34/51: [gnugo int] Use ‘set-p rocess-query-on-exit-flag’., Thien-Thi Nguyen, 2014/02/24
- [elpa] 33/51: [gnugo int] Zonk unused local var., Thien-Thi Nguyen, 2014/02/24
- [elpa] 35/51: [gnugo int] Use ‘dolis t’ and ‘destructuring-bind’., Thien-Thi Nguyen, 2014/02/24
- [elpa] 28/51: [gnugo int] Drop leading "*" in docstrings., Thien-Thi Nguyen, 2014/02/24
- [elpa] 26/51: [gnugo] Give names and docstr ings to ‘lambda’ commands.,
Thien-Thi Nguyen <=
- [elpa] 38/51: [gnugo] Fix bug: Relax sync regexp., Thien-Thi Nguyen, 2014/02/24
- [elpa] 39/51: [gnugo] Don't show underscore in group-animation message., Thien-Thi Nguyen, 2014/02/24
- [elpa] 36/51: [gnugo int] Revamp gnugo-{put, get} doc / indentation decl., Thien-Thi Nguyen, 2014/02/24
- [elpa] 37/51: [gnugo maint] Update "next" in HACKING; nfc., Thien-Thi Nguyen, 2014/02/24
- [elpa] 32/51: [gnugo] Use ‘user-erro r’., Thien-Thi Nguyen, 2014/02/24
- [elpa] 02/51: Import gnugo.el from ttn-pers-elisp 1.59., Thien-Thi Nguyen, 2014/02/24
- [elpa] 40/51: [gnugo] Use special constructs for keybindings in docstrings., Thien-Thi Nguyen, 2014/02/24
- [elpa] 21/51: [gnugo gtp int] Use :post-thunk instead of :post-hook., Thien-Thi Nguyen, 2014/02/24
- [elpa] 31/51: [gnugo int] Add abstraction: gnugo--unclose-game, Thien-Thi Nguyen, 2014/02/24
- [elpa] 45/51: [gnugo] New command: ‘ A’ (gnugo-switch-to-another), Thien-Thi Nguyen, 2014/02/24