Variable: type-break-mode-hook
type-break-mode-hook is a customizable variable defined in
type-break.el.gz.
Value
nil
Documentation
Hook run after entering or leaving type-break-mode(var)/type-break-mode(fun).
No problems result if this variable is not bound.
add-hook automatically binds it. (This is true for all hook variables.)
Source Code
;; Defined in /usr/src/emacs/lisp/type-break.el.gz
;;;###autoload
(define-minor-mode type-break-mode
"Enable or disable typing-break mode.
This is a minor mode, but it is global to all buffers by default.
When this mode is enabled, the user is encouraged to take typing breaks at
appropriate intervals; either after a specified amount of time or when the
user has exceeded a keystroke threshold. When the time arrives, the user
is asked to take a break. If the user refuses at that time, Emacs will ask
again in a short period of time. The idea is to give the user enough time
to find a good breaking point in his or her work, but be sufficiently
annoying to discourage putting typing breaks off indefinitely.
The user may enable or disable this mode by setting the variable of the
same name, though setting it in that way doesn't reschedule a break or
reset the keystroke counter.
If the mode was previously disabled and is enabled as a consequence of
calling this function, it schedules a break with `type-break-schedule' to
make sure one occurs (the user can call that command to reschedule the
break at any time). It also initializes the keystroke counter.
The variable `type-break-interval' specifies the number of seconds to
schedule between regular typing breaks. This variable doesn't directly
affect the time schedule; it simply provides a default for the
`type-break-schedule' command.
If set, the variable `type-break-good-rest-interval' specifies the minimum
amount of time which is considered a reasonable typing break. Whenever
that time has elapsed, typing breaks are automatically rescheduled for
later even if Emacs didn't prompt you to take one first. Also, if a break
is ended before this much time has elapsed, the user will be asked whether
or not to continue. A nil value for this variable prevents automatic
break rescheduling, making `type-break-interval' an upper bound on the time
between breaks. In this case breaks will be prompted for as usual before
the upper bound if the keystroke threshold is reached.
If `type-break-good-rest-interval' is nil and
`type-break-good-break-interval' is set, then confirmation is required to
interrupt a break before `type-break-good-break-interval' seconds
have passed. This provides for an upper bound on the time between breaks
together with confirmation of interruptions to these breaks.
The variable `type-break-keystroke-threshold' is used to determine the
thresholds at which typing breaks should be considered. You can use
the command `type-break-guesstimate-keystroke-threshold' to try to
approximate good values for this.
There are several variables that affect how or when warning messages about
imminent typing breaks are displayed. They include:
`type-break-mode-line-message-mode'
`type-break-time-warning-intervals'
`type-break-keystroke-warning-intervals'
`type-break-warning-repeat'
`type-break-warning-countdown-string'
`type-break-warning-countdown-string-type'
There are several variables that affect if, how, and when queries to begin
a typing break occur. They include:
`type-break-query-mode'
`type-break-query-function'
`type-break-query-interval'
The command `type-break-statistics' prints interesting things.
Finally, a file (named `type-break-file-name') is used to store information
across Emacs sessions. This provides recovery of the break status between
sessions and after a crash. Manual changes to the file may result in
problems."
:lighter type-break-mode-line-format
:global t
(type-break-check-post-command-hook)
(cond
;; ((and already-enabled type-break-mode)
;; (and (called-interactively-p 'interactive)
;; (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 '(""))) ;FIXME: Why?
(type-break-keystroke-reset)
(type-break-mode-line-countdown-or-break nil)
(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
(let (diff)
(if (and type-break-time-last-break
(< (setq diff (type-break-time-difference
type-break-time-last-break
nil))
type-break-interval))
;; Use the file's value.
(progn
(setq type-break-keystroke-count
(type-break-get-previous-count))
;; File the time, in case it was read from the auto-save file.
(type-break-file-time type-break-interval-start)
(setq type-break-interval-start type-break-time-last-break)
(- type-break-interval diff))
;; Schedule from now.
(setq type-break-interval-start (current-time))
(type-break-file-time type-break-interval-start)
type-break-interval))
type-break-interval-start
type-break-interval))
(t
(type-break-keystroke-reset)
(type-break-mode-line-countdown-or-break nil)
(type-break-cancel-schedule)
(do-auto-save)
(when type-break-file-name
(with-current-buffer (find-file-noselect type-break-file-name
'nowarn)
(set-buffer-modified-p nil)
(unlock-buffer)
(kill-current-buffer))))))