Function: type-break-mode
type-break-mode is an autoloaded, interactive and byte-compiled
function defined in type-break.el.gz.
Signature
(type-break-mode &optional ARG)
Documentation
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(var)/type-break-mode-line-message-mode(fun)
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(var)/type-break-query-mode(fun)
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.
This is a global minor mode. If called interactively, toggle the
Type-Break mode mode. If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate (default-value \=type-break-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
Key Bindings
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)
(time-convert nil 'integer)))
;; 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 (time-convert nil 'integer))
(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))))))