emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/gnugo 3540673 272/357: [gnugo] Make SGF I/O commands c


From: Stefan Monnier
Subject: [elpa] externals/gnugo 3540673 272/357: [gnugo] Make SGF I/O commands change ‘default-directory’.
Date: Sun, 29 Nov 2020 14:51:37 -0500 (EST)

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

    [gnugo] Make SGF I/O commands change ‘default-directory’.
    
    * packages/gnugo/gnugo.el (gnugo--ok-file): New func.
    (gnugo-write-sgf-file, gnugo-read-sgf-file): Don't
    clear buffer-modified state; instead, call ‘gnugo--ok-file’.
---
 NEWS     |  1 +
 gnugo.el | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 026d67d..1650be8 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,7 @@ NB: "RCS: X..Y " means that the particular release includes
   - GNUGO Board mode now derived from Special mode
   - position arg validated for direct GTP commands ‘undo’, ‘gg-undo’
   - undo commands no longer signal error on overkill
+  - SGF I/O commands change ‘default-directory’
   - 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 a01ae63..4a6d002 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1897,6 +1897,12 @@ by how many stones)."
     (message "Est.score ... B %s %s | W %s %s | %s"
              black black-captures white white-captures est)))
 
+(defun gnugo--ok-file (filename)
+  (setq default-directory
+        (file-name-directory
+         (expand-file-name filename)))
+  (set-buffer-modified-p nil))
+
 (defun gnugo-write-sgf-file (filename)
   "Save the game history to FILENAME (even if unfinished).
 If FILENAME already exists, Emacs confirms that you wish to overwrite it."
@@ -1905,7 +1911,7 @@ If FILENAME already exists, Emacs confirms that you wish 
to overwrite it."
              (not (y-or-n-p "File exists. Continue? ")))
     (user-error "Not writing %s" filename))
   (gnugo/sgf-write-file (gnugo-get :sgf-collection) filename)
-  (set-buffer-modified-p nil))
+  (gnugo--ok-file filename))
 
 (defun gnugo--dance-dance (karma)
   (destructuring-bind (dance btw)
@@ -2000,7 +2006,7 @@ If FILENAME already exists, Emacs confirms that you wish 
to overwrite it."
     (gnugo-put :last-user-bpos
       (gnugo-move-history 'bpos (gnugo-get :user-color)))
     (gnugo-refresh t)
-    (set-buffer-modified-p nil)
+    (gnugo--ok-file filename)
     (gnugo--who-is-who wait play samep)))
 
 (defun gnugo--mem-with-played-stone (pos &optional noerror)



reply via email to

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