I've read What is inhibit-point-motion-hooks?.
Assume some minor-mode
my-mode that wants to do point-motion-y
my--point-left functions that work
fine in Emacs < 25, when
point-left props to use them.
Assume I'd like to have the mode keep working on Emacs < 25, but also do the right thing if it finds itself on 25+. What is the right thing to do?
(setq-local inhibit-point-motion-hooks nil) and call it a day. But that var is described as "obsolete", which seems stronger than
"deprecated". So that seems like not the right thing.
Is the following a good template to use instead?
;; When mode is enabled (when (fboundp 'cursor-sensor-mode) (cursor-sensor-mode 1)) ;; When mode is disabled (when (fboundp 'cursor-sensor-mode) (cursor-sensor-mode -1)) (defun my--cursor-sensor-function (window old dir) (let ((new (window-point window))) ;is this correct ??? (pcase dir (`entered (my--point-entered old new)) (`left (my--point-left old new))))) ;; where my--point-* are existing point motion functions ;; Where the props are added: (let ((motion-props (if (fboundp 'cursor-sensor-mode) (list 'cursor-sensor-functions (list #'my--cursor-sensor-function)) (list 'point-entered #'my--point-entered 'point-left #'my--point-left)))) (add-text-properties beg end (append (list 'some-other-prop some-val) motion-props)))
Or if that's not a good approach, what is the recommended way to work with both older and newer versions of Emacs?