diff options
| author | John Wiegley <johnw@newartisans.com> | 2002-03-11 20:57:21 +0000 |
|---|---|---|
| committer | John Wiegley <johnw@newartisans.com> | 2002-03-11 20:57:21 +0000 |
| commit | 871e9bb270b35c621265fc56ec582bdd39900e2a (patch) | |
| tree | 0f031b50dba5beb8a49e697f2488831a32f69655 /chess-pgn.el | |
| parent | 442c62fd96d5cb79ab34faf1d8108d86372e96c3 (diff) | |
changes
Diffstat (limited to 'chess-pgn.el')
| -rw-r--r-- | chess-pgn.el | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/chess-pgn.el b/chess-pgn.el index 841cccb..36ce3f0 100644 --- a/chess-pgn.el +++ b/chess-pgn.el @@ -18,7 +18,7 @@ ((looking-at chess-algebraic-regexp) (goto-char (match-end 0)) (setq prevpos position) - (let ((ply (chess-algebraic-to-ply position (match-string 0)))) + (let ((ply (chess-game-algebraic-to-ply game (match-string 0)))) (setq position (chess-ply-next-pos ply)) (nconc plies (list ply)))) ((and top-level @@ -64,30 +64,30 @@ (chess-pos-copy chess-starting-position)) t))) game))) -(defun chess-pgn-insert-annotations (index ply) +(defun chess-pgn-insert-annotations (game index ply) (dolist (ann (chess-pos-annotations (chess-ply-pos ply))) (if (stringp ann) (insert (format " {%s}" ann)) (assert (listp ann)) - (chess-pgn-insert-plies index ann)))) + (chess-pgn-insert-plies game index ann)))) -(defun chess-pgn-insert-plies (index plies &optional +(defun chess-pgn-insert-plies (game index plies &optional for-black indented no-annotations) "NYI: Still have to implement INDENTED argument." (while plies (unless for-black (insert (format "%d. %s" index - (chess-ply-to-algebraic (car plies)))) + (chess-game-ply-to-algebraic game (car plies)))) (unless no-annotations - (chess-pgn-insert-annotations index (car plies))) + (chess-pgn-insert-annotations game index (car plies))) (setq plies (cdr plies) index (1+ index))) (when plies (when for-black (insert (format "%d. ..." index)) (setq for-black nil)) - (insert (format " %s" (chess-ply-to-algebraic (car plies)))) + (insert (format " %s" (chess-game-ply-to-algebraic game (car plies)))) (unless no-annotations - (chess-pgn-insert-annotations index (car plies))) + (chess-pgn-insert-annotations game index (car plies))) (setq plies (cdr plies))) (if plies (insert ? )))) @@ -107,7 +107,7 @@ If INDENTED is non-nil, indent the move texts." (insert (format "[%s \"%s\"]\n" (car tag) (cdr tag)))) (insert ?\n) (let ((begin (point))) - (chess-pgn-insert-plies 1 (chess-game-plies game)) + (chess-pgn-insert-plies game 1 (chess-game-plies game)) (insert (or (chess-game-tag game "Result") "*") ?\n) (fill-region begin (point)))) @@ -116,54 +116,54 @@ If INDENTED is non-nil, indent the move texts." ;; PGN-mode for editing and browsing PGN files. ;; -(defvar chess-pgn-mode-map - (let ((map (make-sparse-keymap))) - (define-key map [??] 'describe-mode) - (define-key map [?T] 'text-mode) - (define-key map [return] 'chess-pgn-move) - (define-key map [(control ?m)] 'chess-pgn-move) - map) - "Keymap used by Chess PGN mode.") - -(define-derived-mode chess-pgn-mode text-mode "Chess" - "A mode for editing Chess PGN files.") - -(defun chess-pgn-move () - "Make a move from a PGN buffer." - (interactive) - (let ((end (point)) - coords move) - (save-excursion - (skip-chars-backward "^ ") - (setq move (buffer-substring-no-properties (point) end) - coords (chess-algebraic-to-ply chess-display-position move)) - ;; it will just get reinserted again - (delete-region (point) end)) - (chess-session-event chess-current-session 'move - (chess-algebraic-to-ply chess-display-position)))) - -(defun chess-pgn-insert-move (move &optional color sequence) - "Insert an algebraic move description into a PGN buffer. -If move is the symbol `wait', it means reflect that we are now waiting -for the opponent to make his move. If move is the symbol `ready', it -means our opponent is now waiting for us to move our move. Otherwise, -move should be a string representing the algebraic notation for the -move." - (while (= (char-before) ?.) - (delete-backward-char 1)) - (cond - ((eq move 'wait) - (insert "...")) - ((eq move 'ready) t) - (t - (if (= (char-syntax (char-before)) ? ) - (insert move)) - (if color - (move-to-column 11 t) - (insert ?\n (format "%d. " (1+ sequence)))))) - (let ((wind (get-buffer-window (current-buffer)))) - (if wind - (set-window-point wind (point))))) +;; (defvar chess-pgn-mode-map +;; (let ((map (make-sparse-keymap))) +;; (define-key map [??] 'describe-mode) +;; (define-key map [?T] 'text-mode) +;; (define-key map [return] 'chess-pgn-move) +;; (define-key map [(control ?m)] 'chess-pgn-move) +;; map) +;; "Keymap used by Chess PGN mode.") +;; +;; (define-derived-mode chess-pgn-mode text-mode "Chess" +;; "A mode for editing Chess PGN files.") +;; +;; (defun chess-pgn-move () +;; "Make a move from a PGN buffer." +;; (interactive) +;; (let ((end (point)) +;; coords move) +;; (save-excursion +;; (skip-chars-backward "^ ") +;; (setq move (buffer-substring-no-properties (point) end) +;; coords (chess-algebraic-to-ply chess-display-position move)) +;; ;; it will just get reinserted again +;; (delete-region (point) end)) +;; (chess-session-event chess-current-session 'move +;; (chess-algebraic-to-ply chess-display-position)))) +;; +;; (defun chess-pgn-insert-move (move &optional color sequence) +;; "Insert an algebraic move description into a PGN buffer. +;; If move is the symbol `wait', it means reflect that we are now waiting +;; for the opponent to make his move. If move is the symbol `ready', it +;; means our opponent is now waiting for us to move our move. Otherwise, +;; move should be a string representing the algebraic notation for the +;; move." +;; (while (= (char-before) ?.) +;; (delete-backward-char 1)) +;; (cond +;; ((eq move 'wait) +;; (insert "...")) +;; ((eq move 'ready) t) +;; (t +;; (if (= (char-syntax (char-before)) ? ) +;; (insert move)) +;; (if color +;; (move-to-column 11 t) +;; (insert ?\n (format "%d. " (1+ sequence)))))) +;; (let ((wind (get-buffer-window (current-buffer)))) +;; (if wind +;; (set-window-point wind (point))))) (provide 'chess-pgn) |
