X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/cf8a2dae5ddd1178066dca0524080fde2fdd43df..21f8fcfd24dc96790589ad578c7ee54593fcfd10:/lisp/type-break.el diff --git a/lisp/type-break.el b/lisp/type-break.el index b51a74ea37..beb7e6f372 100644 --- a/lisp/type-break.el +++ b/lisp/type-break.el @@ -1,6 +1,7 @@ ;;; type-break.el --- encourage rests from typing at appropriate intervals -;; Copyright (C) 1994, 95, 97, 2000, 2004 Free Software Foundation, Inc. +;; Copyright (C) 1994, 1995, 1997, 2000, 2002, 2003, +;; 2004, 2005, 2006 Free Software Foundation, Inc. ;; Author: Noah Friedman ;; Maintainer: Noah Friedman @@ -22,8 +23,8 @@ ;; 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., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -229,7 +230,8 @@ key is pressed." :group 'type-break) (defcustom type-break-file-name (convert-standard-filename "~/.type-break") - "*Name of file used to save state across sessions." + "*Name of file used to save state across sessions. +If this is nil, no data will be saved across sessions." :type 'file :group 'type-break) @@ -389,6 +391,10 @@ problems." (and (interactive-p) (message "Type Break mode is already enabled"))) (type-break-mode + (when type-break-file-name + (with-current-buffer (find-file-noselect type-break-file-name 'nowarn) + (setq buffer-save-without-query t))) + (or global-mode-string (setq global-mode-string '(""))) (or (assq 'type-break-mode-line-message-mode @@ -399,7 +405,9 @@ problems." (type-break-keystroke-reset) (type-break-mode-line-countdown-or-break nil) - (setq type-break-time-last-break (type-break-get-previous-time)) + (setq type-break-time-last-break + (or (type-break-get-previous-time) + (current-time))) ;; schedule according to break time from session file (type-break-schedule @@ -431,12 +439,12 @@ problems." (type-break-mode-line-countdown-or-break nil) (type-break-cancel-schedule) (do-auto-save) - (with-current-buffer (find-file-noselect type-break-file-name - 'nowarn) - (setq buffer-save-without-query t) - (set-buffer-modified-p nil) - (unlock-buffer) - (kill-this-buffer)) + (when type-break-file-name + (with-current-buffer (find-file-noselect type-break-file-name + 'nowarn) + (set-buffer-modified-p nil) + (unlock-buffer) + (kill-this-buffer))) (and (interactive-p) (message "Type Break mode is disabled"))))) type-break-mode) @@ -496,7 +504,8 @@ variable of the same name." (defun type-break-file-time (&optional time) "File break time in `type-break-file-name', unless the file is locked." - (if (not (stringp (file-locked-p type-break-file-name))) + (if (and type-break-file-name + (not (stringp (file-locked-p type-break-file-name)))) (with-current-buffer (find-file-noselect type-break-file-name 'nowarn) (let ((inhibit-read-only t)) @@ -507,7 +516,8 @@ variable of the same name." (defun type-break-file-keystroke-count () "File keystroke count in `type-break-file-name', unless the file is locked." - (if (not (stringp (file-locked-p type-break-file-name))) + (if (and type-break-file-name + (not (stringp (file-locked-p type-break-file-name)))) ;; Prevent deactivation of the mark in some other buffer. (let (deactivate-mark) (with-current-buffer (find-file-noselect type-break-file-name @@ -534,6 +544,8 @@ return TIME, else return nil." (defun type-break-choose-file () "Return file to read from." (cond + ((not type-break-file-name) + nil) ((and (file-exists-p type-break-auto-save-file-name) (file-readable-p type-break-auto-save-file-name)) type-break-auto-save-file-name)