[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 26c849f 330/357: [gnugo int] Decruft: Don't decla
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 26c849f 330/357: [gnugo int] Decruft: Don't declare hook and keymap vars. |
Date: |
Sun, 29 Nov 2020 14:51:50 -0500 (EST) |
branch: externals/gnugo
commit 26c849f6bbe53acc5e92e02f46db8f5916fdfc56
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo int] Decruft: Don't declare hook and keymap vars.
We can count on ‘define-derived-mode’ these days for that.
* packages/gnugo/gnugo.el (gnugo-board-mode-map):
Delete defvar; move init to top-level, prior to ‘provide’
form; conditionalize init on expected ‘?’ binding.
(gnugo-board-mode-hook): Delete defvar.
(gnugo-mode): Mention ‘gnugo-board-mode-map’ in docstring.
---
gnugo.el | 120 ++++++++++++++++++++++++++++-----------------------------------
1 file changed, 54 insertions(+), 66 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index 9dd0b61..2c92916 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -107,71 +107,6 @@ This program must accept command line args:
For more information on GTP and GNU Go, please visit:
<http://www.gnu.org/software/gnugo>")
-(defvar gnugo-board-mode-map
- ;; Re <http://lists.gnu.org/archive/html/emacs-devel/2014-04/msg00123.html>,
- ;; ideally we could ‘defvar’ here w/o value and also ‘defvar’ below
- ;; in "load-time actions" w/ value and docstring, to avoid this ugly
- ;; (from the forward references) block early in the file. Unfortunately,
- ;; byte-compiling such a split formulation results in the initial ‘defvar’
- ;; being replaced by:
- ;; (defvar VAR (make-sparse-keymap))
- ;; and the second ‘defvar’ is ignored on load. At least, this is the case
- ;; for Emacs built from repo (trunk) 2014-05-27. --ttn
- (let ((map (make-sparse-keymap)))
- (suppress-keymap map)
- (mapc (lambda (pair)
- (define-key map (car pair) (cdr pair)))
- '(("?" . describe-mode)
- ("S" . gnugo-request-suggestion)
- ("\C-m" . gnugo-move)
- (" " . gnugo-move)
- ("P" . gnugo-pass)
- ("R" . gnugo-resign)
- ("q" . gnugo-quit)
- ("Q" . gnugo-leave-me-alone)
- ("U" . gnugo-fancy-undo)
- ("\M-u" . gnugo-undo-one-move)
- ("u" . gnugo-undo-two-moves)
- ("\C-?" . gnugo-undo-two-moves)
- ("o" . gnugo-oops)
- ("O" . gnugo-okay)
- ("\C-l" . gnugo-refresh)
- ("\M-_" . gnugo-boss-is-near)
- ("_" . gnugo-boss-is-near)
- ("h" . gnugo-move-history)
- ("L" . gnugo-frolic-in-the-leaves)
- ("\C-c\C-l" . gnugo-frolic-in-the-leaves)
- ("i" . gnugo-image-display-mode)
- ("w" . gnugo-worm-stones)
- ("W" . gnugo-worm-data)
- ("d" . gnugo-dragon-stones)
- ("D" . gnugo-dragon-data)
- ("g" . gnugo-grid-mode)
- ("!" . gnugo-estimate-score)
- (":" . gnugo-command)
- (";" . gnugo-command)
- ("=" . gnugo-describe-position)
- ("s" . gnugo-write-sgf-file)
- ("\C-x\C-s" . gnugo-write-sgf-file)
- ("\C-x\C-w" . gnugo-write-sgf-file)
- ("l" . gnugo-read-sgf-file)
- ("F" . gnugo-display-final-score)
- ("A" . gnugo-switch-to-another)
- ("C" . gnugo-comment)
- ("\C-c\C-a" . gnugo-assist-mode)
- ("\C-c\C-z" . gnugo-zombie-mode)
- ;; mouse
- ([(down-mouse-1)] . gnugo-mouse-move)
- ([(down-mouse-2)] . gnugo-mouse-move) ; mitigate accidents
- ([(down-mouse-3)] . gnugo-mouse-pass)
- ;; delving into the curiosities
- ("\C-c\C-p" . gnugo-describe-internal-properties)))
- map)
- "Keymap for GNUGO Board mode.")
-
-(defvar gnugo-board-mode-hook nil
- "Hook run when entering GNUGO Board mode.")
-
(defvar gnugo-start-game-hook nil
"Normal hook run immediately before the first move of the game.
To find out who is to move first, use `gnugo-current-player'.
@@ -2160,7 +2095,7 @@ NOTE: At this time, GTP command handling specification is
still
(define-derived-mode gnugo-board-mode special-mode "GNUGO Board"
"Major mode for playing GNU Go.
Entering this mode runs the normal hook `gnugo-board-mode-hook'.
-In this mode, keys do not self insert."
+In this mode, keys do not self insert (see `gnugo-board-mode-map')."
:syntax-table nil
:abbrev-table nil
(buffer-disable-undo) ; todo: undo undo undoing
@@ -2424,6 +2359,59 @@ See `gnugo-board-mode' for a full list of commands."
((cl-plusp (setq n (string-to-number (car sel)))) n)
(t (validpos (car sel) t)))))))))
+;; Respect user customizations; try not to clobber the keymap on reload.
+;; hacker override: (define-key gnugo-board-mode-map "?" nil)
+(unless (eq 'describe-mode (lookup-key gnugo-board-mode-map "?"))
+ (cl-loop
+ for (key binding . _)
+ on '("?" describe-mode
+ "S" gnugo-request-suggestion
+ "\C-m" gnugo-move
+ " " gnugo-move
+ "P" gnugo-pass
+ "R" gnugo-resign
+ "q" gnugo-quit
+ "Q" gnugo-leave-me-alone
+ "U" gnugo-fancy-undo
+ "\M-u" gnugo-undo-one-move
+ "u" gnugo-undo-two-moves
+ "\C-?" gnugo-undo-two-moves
+ "o" gnugo-oops
+ "O" gnugo-okay
+ "\C-l" gnugo-refresh
+ "\M-_" gnugo-boss-is-near
+ "_" gnugo-boss-is-near
+ "h" gnugo-move-history
+ "L" gnugo-frolic-in-the-leaves
+ "\C-c\C-l" gnugo-frolic-in-the-leaves
+ "i" gnugo-image-display-mode
+ "w" gnugo-worm-stones
+ "W" gnugo-worm-data
+ "d" gnugo-dragon-stones
+ "D" gnugo-dragon-data
+ "g" gnugo-grid-mode
+ "!" gnugo-estimate-score
+ ":" gnugo-command
+ ";" gnugo-command
+ "=" gnugo-describe-position
+ "s" gnugo-write-sgf-file
+ "\C-x\C-s" gnugo-write-sgf-file
+ "\C-x\C-w" gnugo-write-sgf-file
+ "l" gnugo-read-sgf-file
+ "F" gnugo-display-final-score
+ "A" gnugo-switch-to-another
+ "C" gnugo-comment
+ "\C-c\C-a" gnugo-assist-mode
+ "\C-c\C-z" gnugo-zombie-mode
+ ;; mouse
+ [(down-mouse-1)] gnugo-mouse-move
+ [(down-mouse-2)] gnugo-mouse-move ; mitigate accidents
+ [(down-mouse-3)] gnugo-mouse-pass
+ ;; delving into the curiosities
+ "\C-c\C-p" gnugo-describe-internal-properties)
+ by #'cddr
+ do (define-key gnugo-board-mode-map key binding)))
+
(provide 'gnugo)
- [elpa] externals/gnugo 5524a47 262/357: [gnugo int] Maintain current buffer in ‘gnugo--finish-move’., (continued)
- [elpa] externals/gnugo 5524a47 262/357: [gnugo int] Maintain current buffer in ‘gnugo--finish-move’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 2b8d5aa 258/357: [gnugo int] Compute "Abd" in mode-line at time of change., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6a7af2a 274/357: [gnugo int] Decruft: Presume ‘display-images-p’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 35571e3 287/357: [gnugo int] Use private obarray for :all-yy elems, display props., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 0473d72 264/357: [gnugo int] Comment munging; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5b49aad 316/357: [gnugo int] Use ‘line-end-position’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7544ffe 311/357: [gnugo maint] Add copyright policy to HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 1ff7a11 307/357: [gnugo maint] Add ‘URL’ header; trim Hacking URL; drop Tip Jar URL., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 10d29a9 301/357: [gnugo] Only set AP for modified gametrees in the collection., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo da98bc8 288/357: [gnugo int] Replace COND expression w/ IF., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 26c849f 330/357: [gnugo int] Decruft: Don't declare hook and keymap vars.,
Stefan Monnier <=
- [elpa] externals/gnugo b5b3fd6 337/357: [gnugo int] Reduce ‘setq’ usage., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo c885c9c 020/357: [gnugo int] Avoid variable FORMAT for ‘message’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo fce1fb0 077/357: [gnugo sgf] Fix bug: Output subtrees correctly., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5ca7efb 099/357: [gnugo int] Remove redundant game-over condition check., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7fee3b2 104/357: [gnugo] Move "1 or 2" calculation into ‘gnugo-magic-undo’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a86327a 108/357: [gnugo] Add command ‘gnugo-frolic-in-the-leaves’ and keybinding., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f5fbba3 153/357: [gnugo int] Fix bug: Update local var ‘ends’ when branching., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a4dcef8 150/357: [gnugo frolic int] Parameterize, centralize awakening., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 1b69add 160/357: [gnugo int] Decruft: Drop gametree IR element: KIDS, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 891a97a 177/357: [gnugo int] Add abstraction: gnugo--decorate, Stefan Monnier, 2020/11/29