emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Suggestion to add before and after hooks to posn-set-point.


From: Robert Weiner
Subject: Suggestion to add before and after hooks to posn-set-point.
Date: Mon, 18 Sep 2017 18:32:20 -0400

It seems as of Emacs 25, there are no hooks in posn-set-point to do something custom before or after point has been set/moved.  How about modifying posn-set-point like so:

(defun posn-set-point (position)
  "Move point to POSITION.
Select the corresponding window as well."
  (if (not (windowp (posn-window position)))
      (error "Position not in text area of window"))
  (run-hooks 'before-set-point-hook) ; <-- ADD
  (select-window (posn-window position))
  (if (numberp (posn-point position))
      (goto-char (posn-point position)))
  (run-hooks 'after-set-point-hook)) ; <-- AD

I can imagine both global and buffer-local uses of such hooks, such as logging where point has been and highlighting elements selected within a buffer.  I have done some testing with it and I like it.

If this is to be added, I would prefer that a core committer add it since it is in core code.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]