+(defun type-break-force-mode-line-update (&optional all)
+ "Force the mode-line of the current buffer to be redisplayed.
+With optional non-nil ALL, force redisplay of all mode-lines."
+ (and all (save-excursion (set-buffer (other-buffer))))
+ (set-buffer-modified-p (buffer-modified-p)))
+
+;; If an exception occurs in emacs while running the post command hook, the
+;; value of that hook is clobbered. This is because the value of the
+;; variable is temporarily set to nil while it's running to prevent
+;; recursive application, but it also means an exception aborts the routine
+;; of restoring it. This function is called from the timers to restore it,
+;; just in case.
+(defun type-break-check-post-command-hook ()
+ (add-hook 'post-command-hook 'type-break-run-tb-post-command-hook 'append))
+
+\f
+;;; Timer wrapper functions
+;;;
+;;; These shield type-break from variations in the interval timer packages
+;;; for different versions of emacs.
+
+(defun type-break-run-at-time (time repeat function)
+ (cond ((eq type-break-emacs-variant 'standard19)
+ (require 'timer)
+ (funcall 'run-at-time time repeat function))
+ ((eq type-break-emacs-variant 'lucid-19-8)
+ (let ((name (if (symbolp function)
+ (symbol-name function)
+ "type-break")))
+ (require 'timer)
+ (funcall 'start-timer name function time repeat)))
+ ((memq type-break-emacs-variant '(xemacs lucid))
+ (let ((name (if (symbolp function)
+ (symbol-name function)
+ "type-break")))
+ (require 'itimer)
+ (funcall 'start-itimer name function time repeat)))))
+
+(defun type-break-cancel-function-timers (function)
+ (cond ((eq type-break-emacs-variant 'standard19)
+ (let ((timer-dont-exit t))
+ (funcall 'cancel-function-timers function)))
+ ((eq type-break-emacs-variant 'lucid-19-8)
+ (let ((list timer-list))
+ (while list
+ (and (eq (funcall 'timer-function (car list)) function)
+ (funcall 'delete-timer (car list)))
+ (setq list (cdr list)))))
+ ((memq type-break-emacs-variant '(xemacs lucid))
+ (let ((list itimer-list))
+ (while list
+ (and (eq (funcall 'itimer-function (car list)) function)
+ (funcall 'delete-itimer (car list)))
+ (setq list (cdr list)))))))
+