]> code.delx.au - gnu-emacs/blobdiff - lisp/type-break.el
(struct group): Add gr_gid member.
[gnu-emacs] / lisp / type-break.el
index 98851bcab204ee76789810cbb2b9c3ac0da97b7c..b8b6f48e6f27d1026a3c0f9534dbdcd681b81705 100644 (file)
@@ -1,7 +1,7 @@
 ;;; type-break.el --- encourage rests from typing at appropriate intervals
 
 ;; Copyright (C) 1994, 1995, 1997, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Noah Friedman
 ;; Maintainer: Noah Friedman <friedman@splode.com>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,9 +22,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -562,9 +560,12 @@ Returns nil if the file is missing or if the time breaks with the
     (if file
         (timep ;; returns expected format, else nil
          (with-current-buffer (find-file-noselect file 'nowarn)
-           (save-excursion
-             (goto-char (point-min))
-             (read (current-buffer))))))))
+          (condition-case nil
+              (save-excursion
+                (goto-char (point-min))
+                (read (current-buffer)))
+            (end-of-file
+             (error "End of file in `%s'" file))))))))
 
 (defun type-break-get-previous-count ()
   "Get previous keystroke count from `type-break-file-name'.
@@ -576,10 +577,13 @@ integer."
               (setq file
                     (with-current-buffer
                         (find-file-noselect file 'nowarn)
-                      (save-excursion
-                        (goto-char (point-min))
-                        (forward-line 1)
-                        (read (current-buffer)))))))
+                    (condition-case nil
+                        (save-excursion
+                          (goto-char (point-min))
+                          (forward-line 1)
+                          (read (current-buffer)))
+                      (end-of-file
+                       (error "End of file in `%s'" file)))))))
         file
       0)))
 
@@ -1120,6 +1124,13 @@ With optional non-nil ALL, force redisplay of all mode-lines."
 \f
 ;;; Demo wrappers
 
+(defun type-break-catch-up-event ()
+  ;; If the last input event is a down-event, read and discard the
+  ;; corresponding up-event too, to avoid triggering another prompt.
+  (and (eventp last-input-event)
+       (memq 'down (event-modifiers last-input-event))
+       (read-event)))
+
 ;; This is a wrapper around hanoi that calls it with an arg large enough to
 ;; make the largest discs possible that will fit in the window.
 ;; Also, clean up the *Hanoi* buffer after we're done.
@@ -1132,9 +1143,11 @@ With optional non-nil ALL, force redisplay of all mode-lines."
         (hanoi (/ (window-width) 8))
         ;; Wait for user to come back.
         (read-event)
+       (type-break-catch-up-event)
         (kill-buffer "*Hanoi*"))
     (quit
      (read-event)
+     (type-break-catch-up-event)
      (and (get-buffer "*Hanoi*")
           (kill-buffer "*Hanoi*")))))
 
@@ -1153,12 +1166,14 @@ With optional non-nil ALL, force redisplay of all mode-lines."
             (life 3)
             ;; wait for user to return
             (read-event)
+           (type-break-catch-up-event)
             (kill-buffer "*Life*"))
         (life-extinct
          (message "%s" (get 'life-extinct 'error-message))
          ;; restart demo
          (setq continue t))
         (quit
+        (type-break-catch-up-event)
          (and (get-buffer "*Life*")
               (kill-buffer "*Life*")))))))
 
@@ -1244,7 +1259,8 @@ With optional non-nil ALL, force redisplay of all mode-lines."
                      message))))
             (goto-char (point-min))
             (sit-for 60))
-          (read-event)
+         (read-event)
+         (type-break-catch-up-event)
           (kill-buffer buffer-name))
       (quit
        (and (get-buffer buffer-name)
@@ -1256,5 +1272,5 @@ With optional non-nil ALL, force redisplay of all mode-lines."
 (if type-break-mode
     (type-break-mode 1))
 
-;;; arch-tag: 943a2eb3-07e6-420b-993f-96e4796f5fd0
+;; arch-tag: 943a2eb3-07e6-420b-993f-96e4796f5fd0
 ;;; type-break.el ends here