all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Weiner <rsw@gnu.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Suggestion to add before and after hooks to posn-set-point.
Date: Mon, 18 Sep 2017 18:32:20 -0400	[thread overview]
Message-ID: <CA+OMD9j_hS-Dz3_esY4y7sEV96GEADszGB3wVJgygjptb=uR8w@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2114 bytes --]

             reply	other threads:[~2017-09-18 22:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 22:32 Robert Weiner [this message]
2017-09-19  2:21 ` Suggestion to add before and after hooks to posn-set-point Stefan Monnier
2017-09-19  3:07   ` Robert Weiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+OMD9j_hS-Dz3_esY4y7sEV96GEADszGB3wVJgygjptb=uR8w@mail.gmail.com' \
    --to=rsw@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rswgnu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.