Function: cursor-sensor-mode

cursor-sensor-mode is an autoloaded, interactive and byte-compiled function defined in cursor-sensor.el.gz.

Signature

(cursor-sensor-mode &optional ARG)

Documentation

Handle the cursor-sensor-functions text property.

This property should hold a list of functions which react to the motion of the cursor. They're called with three arguments (WINDOW OLDPOS DIR) where WINDOW is the affected window, OLDPOS is the last known position of the cursor and DIR can be entered or left depending on whether the cursor is entering the area covered by the text-property property or leaving it.

This is a minor mode. If called interactively, toggle the Cursor-Sensor 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 cursor-sensor-mode(var)/cursor-sensor-mode(fun).

The mode's hook is called both when the mode is enabled and when it is disabled.

Probably introduced at or before Emacs version 25.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cursor-sensor.el.gz
;;;###autoload
(define-minor-mode cursor-sensor-mode
  "Handle the `cursor-sensor-functions' text property.
This property should hold a list of functions which react to the motion
of the cursor.  They're called with three arguments (WINDOW OLDPOS DIR)
where WINDOW is the affected window, OLDPOS is the last known position of
the cursor and DIR can be `entered' or `left' depending on whether the cursor
is entering the area covered by the text-property property or leaving it."
  :global nil
  (cond
   (cursor-sensor-mode
    ;; Also add ourselves to `post-command-hook' because
    ;; `pre-redisplay-functions' are sometimes called too late (after
    ;; adjust_point_for_property has moved point, which makes it
    ;; "impossible" for cursor-sensor-functions to do things like
    ;; revealing invisible text).
    (add-hook 'post-command-hook #'cursor-sensor--detect nil t)
    (add-hook 'pre-redisplay-functions #'cursor-sensor--detect
              nil t))
   (t
    (remove-hook 'post-command-hook #'cursor-sensor--detect t)
    (remove-hook  'pre-redisplay-functions #'cursor-sensor--detect
                t))))