[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/gnugo 1d6b241 214/357: [gnugo] Use ‘define-derived-mod

From: Stefan Monnier
Subject: [elpa] externals/gnugo 1d6b241 214/357: [gnugo] Use ‘define-derived-mode’ for GNUGO Board mode.
Date: Sun, 29 Nov 2020 14:51:24 -0500 (EST)

branch: externals/gnugo
commit 1d6b24123337a75b0d11fec21a11534bf7599fdb
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [gnugo] Use ‘define-derived-mode’ for GNUGO Board mode.
    This exposes ‘gnugo-board-mode-hook’ to the vagaries
    of Special mode (in particular ‘special-mode-hook’).
    * packages/gnugo/gnugo.el (gnugo-board-mode):
    ...here, removing now-redundant stuff accordingly,
    as well as ‘(put 'gnugo-board-mode 'mode-class 'special)’;
    also, clear ‘buffer-read-only’.
 NEWS     |  1 +
 gnugo.el | 13 ++++---------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index 22c447d..c2da1c4 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,7 @@ NB: "RCS: X..Y " means that the particular release includes
   - new command: ‘C-c C-a’ (gnugo-toggle-abdication)
   - new major mode: GNUGO Frolic (gnugo-frolic-mode)
   - ‘gnugo-move-history’ returns last two moves w/ RSEL ‘two’
+  - GNUGO Board mode now derived from Special mode
   - performance improvements
   - of interest to hackers (see source, BI => backward incompatible)
     - dropped var: ‘gnugo-inhibit-refresh’ (BI)
diff --git a/gnugo.el b/gnugo.el
index 14969c7..28fcec5 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -2378,26 +2378,21 @@ NOTE: At this time, GTP command handling specification 
is still
 ;;; Major mode for interacting with a GNUGO subprocess
-(put 'gnugo-board-mode 'mode-class 'special)
-(defun gnugo-board-mode ()
+(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.
   (buffer-disable-undo)                 ; todo: undo undo undoing
-  (kill-all-local-variables)
-  (use-local-map gnugo-board-mode-map)
+  (setq buffer-read-only nil)           ; todo: make everything else DTRT
   (set (make-local-variable 'font-lock-defaults)
        '(gnugo-font-lock-keywords t))
-  (setq major-mode 'gnugo-board-mode
-        mode-name "GNUGO Board"
-        truncate-lines t)
+  (setq truncate-lines t)
   (add-hook 'kill-buffer-hook 'gnugo-cleanup nil t)
   (set (make-local-variable 'gnugo-state)
        (gnugo--mkht :size (1- 42)))
-  (add-to-invisibility-spec :nogrid)
-  (run-hooks 'gnugo-board-mode-hook))
+  (add-to-invisibility-spec :nogrid))
 ;;; Entry point

reply via email to

[Prev in Thread] Current Thread [Next in Thread]