[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 08f11af 339/357: [gnugo int] Incorporate ‘gnugo-
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 08f11af 339/357: [gnugo int] Incorporate ‘gnugo-toggle-image-display’ into unique caller. |
Date: |
Sun, 29 Nov 2020 14:51:52 -0500 (EST) |
branch: externals/gnugo
commit 08f11af7a2b24d0ff4a73a232d68722c840326b6
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo int] Incorporate ‘gnugo-toggle-image-display’ into unique caller.
* packages/gnugo/gnugo.el (gnugo-put): Update docstring
to ‘s/gnugo-toggle-image-display/gnugo-image-display-mode/g’.
(gnugo-toggle-image-display): Delete func, moving body from here...
(gnugo-image-display-mode): ...to here; do ‘s/new/bool/g’;
move ‘act’ let-binding to the smallest useful scope;
move dead-group overlays deletion kludge later,
immediately prior to the ‘gnugo-refresh’ call.
---
gnugo.el | 94 +++++++++++++++++++++++++++++++---------------------------------
1 file changed, 46 insertions(+), 48 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index 2bdfbfd..ccec370 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -272,14 +272,14 @@ you may never really understand to any degree of personal
satisfaction\".
than they are worth!)
:display-using-images -- XPMs, to be precise; see functions `gnugo-yy',
- `gnugo-toggle-image-display' and `gnugo-refresh',
+ `gnugo-image-display-mode' and `gnugo-refresh',
as well as gnugo-xpms.el (available elsewhere)
:all-yy -- list of 46 symbols used as the `category' text property
(so that their plists, typically w/ property `display' or
`do-not-display') are consulted by the Emacs display engine;
46 = 9 places * (4 moku + 1 empty) + 1 hoshi; see functions
- `gnugo-toggle-image-display', `gnugo-yy' and `gnugo-yang'
+ `gnugo-image-display-mode', `gnugo-yy' and `gnugo-yang'
:paren-ov -- a pair (left and right) of overlays shuffled about to indicate
the last move; only one is used when displaying using images
@@ -532,51 +532,6 @@ Return final buffer position (i.e., point)."
(momentaryp (cdr yang))
(t (car yang))))))
-(defun gnugo-toggle-image-display ()
- (unless (display-images-p)
- (user-error "Display does not support images, sorry"))
- (let ((fresh (if (functionp gnugo-xpms)
- (funcall gnugo-xpms (gnugo-get :SZ))
- gnugo-xpms)))
- (unless fresh
- (user-error "Sorry, `gnugo-xpms' unset"))
- (unless (eq fresh (gnugo-get :xpms))
- (gnugo-put :xpms fresh)
- (gnugo--forget :all-yy)))
- (let* ((new (not (gnugo-get :display-using-images)))
- (act (if new 'display 'do-not-display)))
- (mapc (lambda (yy)
- (setcar (symbol-plist yy) act))
- (or (gnugo-get :all-yy)
- (gnugo-put :all-yy
- (prog1 (mapcar (lambda (ent)
- (let* ((k (car ent))
- (yy (gnugo-yy (cdr k) (car k))))
- (setplist yy `(not-yet ,(cdr ent)))
- yy))
- (gnugo-get :xpms))
- (gnugo-put :imul
- (image-size (get (gnugo-yy 5 (gnugo-yang ?+))
- 'not-yet)))))))
- (setplist (gnugo-f 'ispc) (and new '(display (space :width 0))))
- (gnugo-put :highlight-last-move-spec
- (if new
- `(,(lambda (p)
- (get (gnugo-yy (get-text-property p 'gnugo-yin)
- (get-text-property p 'gnugo-yang)
- t)
- 'display))
- 0 delete-overlay)
- (gnugo-get :default-highlight-last-move-spec)))
- ;; a kludge to be reworked another time perhaps by another gnugo.el lover
- (dolist (group (gnugo-aqr 'dead (gnugo-get :game-over)))
- (mapc 'delete-overlay (cdar group))
- (setcdr (car group) nil))
- (gnugo-put :mul (if new
- (gnugo-get :imul)
- '(1 . 1)))
- (gnugo-put :display-using-images new)))
-
(define-minor-mode gnugo-grid-mode
"If enabled, display grid around the board."
:variable
@@ -1932,7 +1887,50 @@ See function `display-images-p' and variable
`gnugo-xpms'."
.
(lambda (bool)
(unless (eq bool (gnugo-get :display-using-images))
- (gnugo-toggle-image-display)
+ (unless (display-images-p)
+ (user-error "Display does not support images, sorry"))
+ (let ((fresh (if (functionp gnugo-xpms)
+ (funcall gnugo-xpms (gnugo-get :SZ))
+ gnugo-xpms)))
+ (unless fresh
+ (user-error "Sorry, `gnugo-xpms' unset"))
+ (unless (eq fresh (gnugo-get :xpms))
+ (gnugo-put :xpms fresh)
+ (gnugo--forget :all-yy)))
+ (mapc (let ((act (if bool
+ 'display
+ 'do-not-display)))
+ (lambda (yy)
+ (setcar (symbol-plist yy) act)))
+ (or (gnugo-get :all-yy)
+ (gnugo-put :all-yy
+ (prog1 (mapcar (lambda (ent)
+ (let* ((k (car ent))
+ (yy (gnugo-yy (cdr k) (car k))))
+ (setplist yy `(not-yet ,(cdr ent)))
+ yy))
+ (gnugo-get :xpms))
+ (gnugo-put :imul
+ (image-size (get (gnugo-yy 5 (gnugo-yang ?+))
+ 'not-yet)))))))
+ (setplist (gnugo-f 'ispc) (and bool '(display (space :width 0))))
+ (gnugo-put :highlight-last-move-spec
+ (if bool
+ `(,(lambda (p)
+ (get (gnugo-yy (get-text-property p 'gnugo-yin)
+ (get-text-property p 'gnugo-yang)
+ t)
+ 'display))
+ 0 delete-overlay)
+ (gnugo-get :default-highlight-last-move-spec)))
+ (gnugo-put :mul (if bool
+ (gnugo-get :imul)
+ '(1 . 1)))
+ (gnugo-put :display-using-images bool)
+ ;; a kludge to be reworked another time perhaps by another gnugo.el
lover
+ (dolist (group (gnugo-aqr 'dead (gnugo-get :game-over)))
+ (mapc 'delete-overlay (cdar group))
+ (setcdr (car group) nil))
(save-excursion (gnugo-refresh))))))
(defsubst gnugo--node-with-played-stone (pos &optional noerror)
- [elpa] externals/gnugo c6eb3d1 325/357: [gnugo maint] Add people from ttn-pers-elisp THANKS file; nfc., (continued)
- [elpa] externals/gnugo c6eb3d1 325/357: [gnugo maint] Add people from ttn-pers-elisp THANKS file; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 981d75e 341/357: [gnugo] Fix bug: Don't clobber dead-group indication on refresh., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e4344ac 350/357: [gnugo] Release: 3.1.0, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo af82527 356/357: [gnugo] Release: 3.1.1, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 53da06f 329/357: [gnugo] Make ‘gnugo-comment’ fall back to root node., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 781a385 332/357: [gnugo] Drop trailing fullstop for "... done" messages., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo c5ef13d 334/357: [gnugo] Make ‘gnugo-goto-pos’ return buffer position., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6170d2a 333/357: [gnugo] Make ‘C-c C-p’ output more spacious., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 0320a5c 335/357: [gnugo int] Decruft: Don't bother w/ ‘group’ text property., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 8123275 338/357: [gnugo] Drop trailing fullstop in animation message., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 08f11af 339/357: [gnugo int] Incorporate ‘gnugo-toggle-image-display’ into unique caller.,
Stefan Monnier <=
- [elpa] externals/gnugo 1e01c65 340/357: [gnugo] When sorry, say "Sorry" first., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3541ccf 343/357: [gnugo int] Lift redundant pall of death computation., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 38b2529 124/357: [gnugo int] Add abstraction: gnugo--mkht, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 0f9f540 125/357: [gnugo int] Maintain tree MNUM., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7211950 346/357: [gnugo] Indicate seki groups on the board., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 35c4645 347/357: [gnugo] Make ‘C-u F’ store additional SGF properties., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 0c4b37b 349/357: [gnugo] Document new ‘C-u F’ behavior., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e66bfa0 352/357: [gnugo int] Gate ‘cursor-intangible-mode’ call precisely, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 2f73382 353/357: [gnugo] Add some docstrings to some vars/funcs., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo eb9748f 355/357: [gnugo maint] Update years in copyright notice; nfc., Stefan Monnier, 2020/11/29