[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 806a2f2 133/357: [gnugo] Add some navigation comm
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 806a2f2 133/357: [gnugo] Add some navigation commands for GNUGO Frolic mode. |
Date: |
Sun, 29 Nov 2020 14:51:06 -0500 (EST) |
branch: externals/gnugo
commit 806a2f2bd2df856aceffd44503e2f36d80dea7ce
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo] Add some navigation commands for GNUGO Frolic mode.
* packages/gnugo/gnugo.el (gnugo-frolic-parent-buffer)
(gnugo-frolic-origin): New defvars.
(gnugo-frolic-mode): Don't invoke ‘view-mode’.
(gnugo-frolic-quit, gnugo-frolic-return-to-origin): New commands.
(gnugo-frolic-in-the-leaves): Set as local vars
‘gnugo-frolic-in-the-leaves’, ‘gnugo-frolic-origin’;
use ‘gnugo-frolic-return-to-origin’.
(gnugo-frolic-mode-map): Add bindings for ‘q’, ‘C’, ‘o’.
---
gnugo.el | 37 +++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index 0c7e682..4706b83 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -172,6 +172,9 @@ For ~t, the value is a snapshot, use `gnugo-refresh' to
update it.")
(eval-when-compile
(defvar gnugo-xpms nil))
+(defvar gnugo-frolic-parent-buffer nil)
+(defvar gnugo-frolic-origin nil)
+
;;;---------------------------------------------------------------------------
;;; Support functions
@@ -716,9 +719,24 @@ For all other values of RSEL, do nothing and return nil."
Initially View minor mode is active.
\\{gnugo-frolic-mode-map}"
- (buffer-disable-undo)
- ;; Is this idio{ma}tic?
- (view-mode 1))
+ (buffer-disable-undo))
+
+(defun gnugo-frolic-quit ()
+ "Kill GNUGO Frolic buffer and switch to its parent buffer."
+ (interactive)
+ (let ((bye (current-buffer)))
+ (switch-to-buffer (when (buffer-live-p gnugo-frolic-parent-buffer)
+ gnugo-frolic-parent-buffer))
+ (kill-buffer bye)))
+
+(defun gnugo-frolic-return-to-origin ()
+ "Move point to the board's current position."
+ (interactive)
+ (if (not gnugo-frolic-origin)
+ (message "No origin")
+ (goto-char gnugo-frolic-origin)
+ (recenter (- (count-lines (line-beginning-position)
+ (point-max))))))
(defun gnugo-frolic-in-the-leaves ()
"Display the game tree in a *GNUGO Frolic* buffer.
@@ -752,6 +770,7 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(interactive)
(let* ((buf (get-buffer-create (concat (gnugo-get :diamond)
"*GNUGO Frolic*")))
+ (from (current-buffer))
;; todo: use defface once we finally succumb to ‘customize’
(dimmed-node-face (list :inherit 'default
:foreground "gray50"))
@@ -808,6 +827,7 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(format "%-5s" n))
lanes
" ")))
+ (set (make-local-variable 'gnugo-frolic-parent-buffer) from)
(loop
for n ; move number
from max-move-num downto 1
@@ -902,9 +922,8 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(- (1+ (length forks))))
(point))))))))
(when finish
- (goto-char finish)
- (recenter (- (count-lines (line-beginning-position)
- (point-max)))))))
+ (set (make-local-variable 'gnugo-frolic-origin) finish)
+ (gnugo-frolic-return-to-origin))))
(defun gnugo-boss-is-near ()
"Do `bury-buffer' until the current one is not a GNU Board."
@@ -2158,6 +2177,12 @@ starting a new one. See `gnugo-board-mode'
documentation for more info."
;;;---------------------------------------------------------------------------
;;; Load-time actions
+(mapc (lambda (pair)
+ (define-key gnugo-frolic-mode-map (car pair) (cdr pair)))
+ '(("q" . gnugo-frolic-quit)
+ ("C" . gnugo-frolic-quit) ; like ‘View-kill-and-leave’
+ ("o" . gnugo-frolic-return-to-origin)))
+
(unless gnugo-board-mode-map
(setq gnugo-board-mode-map (make-sparse-keymap))
(suppress-keymap gnugo-board-mode-map)
- [elpa] externals/gnugo a708759 110/357: [gnugo int] Use ‘cl-labels’ less., (continued)
- [elpa] externals/gnugo a708759 110/357: [gnugo int] Use ‘cl-labels’ less., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a35f657 115/357: [gnugo] Support SGF[4] parsing from string data., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3d8db48 119/357: [gnugo] Declare dependency on ‘ascii-art-to-unicode’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 4b866c7 127/357: [gnugo int] Avoid lower move-num candidates in déjà-vu search., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5b51e4f 129/357: [gnugo int] Decruft: Consolidate "breathe in" loops., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo fda0ca5 130/357: [gnugo int] Move precise fanout computation to "breathe in"., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo cbf99df 131/357: [gnugo int] Insert frolic xrep starting w/ the leaves., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5c87b11 141/357: [gnugo frolic int] Use ‘move-to-column’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo d62412f 144/357: [gnugo int] Add abstraction: gnugo--move-to-bcol, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 4680536 143/357: [gnugo int] Fix bug: Unbreak SGF file output., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 806a2f2 133/357: [gnugo] Add some navigation commands for GNUGO Frolic mode.,
Stefan Monnier <=
- [elpa] externals/gnugo c6795aa 140/357: [gnugo frolic int] Assign ‘pop’ rv to avoid byte-compiler warning., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 13c8f82 149/357: [gnugo frolic] Doc fix., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo de40b22 152/357: [gnugo int] Move vectorization into ‘gnugo--set-tree-ends’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e8833a9 161/357: [gnugo int] Fix syntax error in ‘loop’ destructuring., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3e3fbea 155/357: [gnugo sgf] Fix bug: Preserve whitespace for ‘text’ values., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 0f3f4b6 165/357: [gnugo int] Use ‘ignore’ to avoid byte-compiler warnings., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 082d56c 178/357: [gnugo int] Use ‘gnugo--decorate’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e382633 190/357: [gnugo] Drop var: gnugo-inhibit-refresh, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo dd6b6f8 186/357: [gnugo] New command: ‘C’ (gnugo-comment), Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo cba406b 176/357: [gnugo] Include root node in :sgf-gametree description., Stefan Monnier, 2020/11/29