]> code.delx.au - gnu-emacs/blobdiff - lisp/play/gametree.el
Merge from emacs-24; up to 2012-12-25T11:37:21Z!dmantipov@yandex.ru
[gnu-emacs] / lisp / play / gametree.el
index d0ba9b037e7f9b5bab6c63d211a6c2a4d9cafb25..3daf9d5f784ae7da126011adccca7e1e7157764f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; gametree.el --- manage game analysis trees in Emacs
 
-;; Copyright (C) 1997, 1999, 2001-201 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2013 Free Software Foundation, Inc.
 
 ;; Author: Ian T Zimmerman <itz@rahul.net>
 ;; Created: Wed Dec 10 07:41:46 PST 1997
@@ -258,23 +258,20 @@ This value is simply the outline heading level of the current line."
 
 (defun gametree-children-shown-p ()
   (save-excursion
-    (condition-case nil
+    (ignore-errors
         (let ((depth (gametree-current-branch-depth)))
           (outline-next-visible-heading 1)
-          (< depth (gametree-current-branch-depth)))
-      (error nil))))
+          (< depth (gametree-current-branch-depth))))))
 
-(defun gametree-current-layout (depth &optional top-level)
+(defun gametree-current-layout (depth &optional from-top-level)
   (let ((layout nil) (first-time t))
     (while (save-excursion
-             (condition-case nil
-                 (progn
-                   (or (and first-time top-level
-                            (bolp) (looking-at outline-regexp))
-                       (setq first-time nil)
-                       (outline-next-visible-heading 1))
-                   (< depth (gametree-current-branch-depth)))
-               (error nil)))
+             (ignore-errors
+               (or (and first-time from-top-level
+                        (bolp) (looking-at outline-regexp))
+                   (setq first-time nil)
+                   (outline-next-visible-heading 1))
+               (< depth (gametree-current-branch-depth))))
       (if (not first-time)
           (outline-next-visible-heading 1))
       (setq first-time nil)
@@ -297,18 +294,16 @@ This value is simply the outline heading level of the current line."
     (goto-char (point-min))
     (setq gametree-local-layout (gametree-current-layout 0 t))))
 
-(defun gametree-apply-layout (layout depth &optional top-level)
+(defun gametree-apply-layout (layout depth &optional from-top-level)
   (let ((first-time t))
     (while (and layout
                 (save-excursion
-                  (condition-case nil
-                      (progn
-                        (or (and first-time top-level
-                                 (bolp) (looking-at outline-regexp))
-                            (setq first-time nil)
-                            (outline-next-visible-heading 1))
-                        (< depth (gametree-current-branch-depth)))
-                    (error nil))))
+                  (ignore-errors
+                    (or (and first-time from-top-level
+                             (bolp) (looking-at outline-regexp))
+                        (setq first-time nil)
+                        (outline-next-visible-heading 1))
+                    (< depth (gametree-current-branch-depth)))))
       (if (not first-time)
           (outline-next-visible-heading 1))
       (setq first-time nil)
@@ -375,9 +370,7 @@ Subnodes which have been manually scored are honored."
             (while (not done)           ;handle subheadings
               (setq running (funcall minmax running
                                      (gametree-compute-reduced-score)))
-              (setq done (condition-case nil
-                             (outline-forward-same-level 1)
-                           (error nil)))))
+              (setq done (ignore-errors (outline-forward-same-level 1)))))
           running)))))
 \f
 ;;;; Commands
@@ -442,7 +435,7 @@ only work of Black's moves are explicitly numbered, for instance
                 gametree-half-ply-regexp)) limit))
           (goto-char (match-beginning 0))))
   (gametree-transpose-following-leaves)
-  (let* ((pt (set-marker (make-marker) (point)))
+  (let* ((pt (point-marker))
          (plys (gametree-current-branch-ply))
          (depth (gametree-current-branch-depth))
          (old-depth depth))
@@ -556,7 +549,7 @@ Argument is a character, naming the register."
 (defun gametree-save-and-hack-layout ()
   "Save the current tree layout and hack the file local variable spec.
 This function saves the current layout in `gametree-local-layout' and,
-if a local file varible specification for this variable exists in the
+if a local file variable specification for this variable exists in the
 buffer, it is replaced by the new value.  See the documentation for
 `gametree-local-layout' for more information."
   (interactive)
@@ -565,6 +558,20 @@ buffer, it is replaced by the new value.  See the documentation for
     (gametree-hack-file-layout))
   nil)
 
+;;;; Key bindings
+(defvar gametree-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\C-c\C-j" 'gametree-break-line-here)
+    (define-key map "\C-c\C-v" 'gametree-insert-new-leaf)
+    (define-key map "\C-c\C-m" 'gametree-merge-line)
+    (define-key map "\C-c\C-r " 'gametree-layout-to-register)
+    (define-key map "\C-c\C-r/" 'gametree-layout-to-register)
+    (define-key map "\C-c\C-rj" 'gametree-apply-register-layout)
+    (define-key map "\C-c\C-y" 'gametree-save-and-hack-layout)
+    (define-key map "\C-c;" 'gametree-insert-score)
+    (define-key map "\C-c^" 'gametree-compute-and-insert-score)
+    map))
+
 (define-derived-mode gametree-mode outline-mode "GameTree"
   "Major mode for managing game analysis trees.
 Useful to postal and email chess (and, it is hoped, also checkers, go,
@@ -575,18 +582,6 @@ shogi, etc.) players, it is a slightly modified version of Outline mode.
   (make-local-variable 'write-contents-hooks)
   (add-hook 'write-contents-hooks 'gametree-save-and-hack-layout))
 
-;;;; Key bindings
-
-(define-key gametree-mode-map "\C-c\C-j" 'gametree-break-line-here)
-(define-key gametree-mode-map "\C-c\C-v" 'gametree-insert-new-leaf)
-(define-key gametree-mode-map "\C-c\C-m" 'gametree-merge-line)
-(define-key gametree-mode-map "\C-c\C-r " 'gametree-layout-to-register)
-(define-key gametree-mode-map "\C-c\C-r/" 'gametree-layout-to-register)
-(define-key gametree-mode-map "\C-c\C-rj" 'gametree-apply-register-layout)
-(define-key gametree-mode-map "\C-c\C-y" 'gametree-save-and-hack-layout)
-(define-key gametree-mode-map "\C-c;" 'gametree-insert-score)
-(define-key gametree-mode-map "\C-c^" 'gametree-compute-and-insert-score)
-
 ;;;; Goodies for mousing users
 (and (fboundp 'track-mouse)
      (defun gametree-mouse-break-line-here (event)