* lisp/emacs-lisp/cursor-sensor.el: Make it possible to reveal invisible text
(cursor-sensor-mode): Hook into post-command-hook as well. (cursor-sensor--detect): Make argument optional.
This commit is contained in:
parent
cf294d78a1
commit
7f5db3f40c
1 changed files with 18 additions and 8 deletions
|
@ -132,7 +132,7 @@ By convention, this is a list of symbols where each symbol stands for the
|
|||
;;;###autoload
|
||||
(define-minor-mode cursor-intangible-mode
|
||||
"Keep cursor outside of any `cursor-intangible' text property."
|
||||
nil nil nil
|
||||
:global nil
|
||||
(if cursor-intangible-mode
|
||||
(add-hook 'pre-redisplay-functions #'cursor-sensor--move-to-tangible
|
||||
nil t)
|
||||
|
@ -140,7 +140,7 @@ By convention, this is a list of symbols where each symbol stands for the
|
|||
|
||||
;;; Detect cursor movement.
|
||||
|
||||
(defun cursor-sensor--detect (window)
|
||||
(defun cursor-sensor--detect (&optional window)
|
||||
(unless cursor-sensor-inhibit
|
||||
(let* ((point (window-point window))
|
||||
;; It's often desirable to make the cursor-sensor-functions property
|
||||
|
@ -178,7 +178,8 @@ By convention, this is a list of symbols where each symbol stands for the
|
|||
(unless (memq f (get-char-property
|
||||
pos 'cursor-sensor-functions))
|
||||
(setq missing t)))
|
||||
missing))))
|
||||
missing)))
|
||||
(window (selected-window)))
|
||||
(dolist (f (cdr old))
|
||||
(unless (and (memq f new) (not (funcall missing-p f)))
|
||||
(funcall f window oldpos 'left)))
|
||||
|
@ -203,12 +204,21 @@ 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."
|
||||
nil nil nil
|
||||
(if cursor-sensor-mode
|
||||
(add-hook 'pre-redisplay-functions #'cursor-sensor--detect
|
||||
nil t)
|
||||
: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)))
|
||||
t))))
|
||||
|
||||
(provide 'cursor-sensor)
|
||||
;;; cursor-sensor.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue