]> code.delx.au - gnu-emacs-elpa/commitdiff
[gnugo] Only set AP for modified gametrees in the collection.
authorThien-Thi Nguyen <ttn@gnu.org>
Tue, 27 May 2014 09:56:16 +0000 (11:56 +0200)
committerThien-Thi Nguyen <ttn@gnu.org>
Tue, 27 May 2014 09:56:16 +0000 (11:56 +0200)
* packages/gnugo/gnugo.el (gnugo-write-sgf-file):
Set root node property :AP here, but only if buffer-modified.
(gnugo, gnugo/sgf-write-file): Don't set root node property :AP.

packages/gnugo/NEWS
packages/gnugo/gnugo.el

index da45ca6f08f3da976f2bb9afd249cbf2710c65d9..91047fb792ed8da077743d3f1df76105abfaca1b 100644 (file)
@@ -46,6 +46,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 prop ‘AP’ set only for modified gametrees
   - SGF I/O commands change ‘default-directory’
   - performance improvements
   - of interest to hackers (see source, BI => backward incompatible)
index 3097ce1fe0321db5f238bc770a8664dbc065d3da..e42db339ab4b8c77c9bffabcd686cdeee7634d7f 100644 (file)
@@ -1561,6 +1561,9 @@ If FILENAME already exists, Emacs confirms that you wish to overwrite it."
   (when (and (file-exists-p filename)
              (not (y-or-n-p "File exists. Continue? ")))
     (user-error "Not writing %s" filename))
+  (when (buffer-modified-p)
+    ;; take responsibility for our actions
+    (gnugo--set-root-prop :AP (cons "gnugo.el" gnugo-version)))
   (gnugo/sgf-write-file (gnugo-get :sgf-collection) filename)
   (gnugo--ok-file filename))
 
@@ -2280,7 +2283,6 @@ See `gnugo-board-mode' for a full list of commands."
                 :RU (if (member "--chinese-rules" args)
                         "Chinese"
                       "Japanese")
-                :AP (cons "gnugo.el" gnugo-version)
                 :KM komi)
             (let ((ub (gnugo--blackp user-color)))
               (r! (if ub :PW :PB) (concat "GNU Go " (gnugo-query "version"))
@@ -2655,7 +2657,6 @@ A collection is a list of gametrees, each a vector of four elements:
 
 (defun gnugo/sgf-write-file (collection filename)
   (let ((aft-newline-appreciated '(:AP :GN :PB :PW :HA :KM :RU :RE))
-        (me (cons "gnugo.el" gnugo-version))
         (specs (mapcar (lambda (full)
                          (cons (intern (format ":%s" (car full)))
                                (cl-cdddr full)))
@@ -2723,8 +2724,6 @@ A collection is a list of gametrees, each a vector of four elements:
                  (insert ")")))
       (with-temp-buffer
         (dolist (tree collection)
-          ;; take responsibility for our actions
-          (gnugo--set-root-prop :AP me tree)
           ;; write it out
           (let ((ht (gnugo--mkht))
                 (leaves (append (gnugo--tree-ends tree) nil)))