From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Weiner Newsgroups: gmane.emacs.devel Subject: Suggestion to add before and after hooks to posn-set-point. Date: Mon, 18 Sep 2017 18:32:20 -0400 Message-ID: Reply-To: rswgnu@gmail.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a113bfbeeab989e05597e52ef" X-Trace: blaine.gmane.org 1505774017 977 195.159.176.226 (18 Sep 2017 22:33:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 18 Sep 2017 22:33:37 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 19 00:33:32 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1du4bb-0008Op-T2 for ged-emacs-devel@m.gmane.org; Tue, 19 Sep 2017 00:33:32 +0200 Original-Received: from localhost ([::1]:39175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du4bj-0003hP-33 for ged-emacs-devel@m.gmane.org; Mon, 18 Sep 2017 18:33:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du4b1-0003gy-B7 for emacs-devel@gnu.org; Mon, 18 Sep 2017 18:32:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1du4ay-0007MH-7A for emacs-devel@gnu.org; Mon, 18 Sep 2017 18:32:55 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:55834) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du4ay-0007MB-3m for emacs-devel@gnu.org; Mon, 18 Sep 2017 18:32:52 -0400 Original-Received: from mail-qt0-f173.google.com ([209.85.216.173]:48150) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1du4ax-0001e3-QP for emacs-devel@gnu.org; Mon, 18 Sep 2017 18:32:51 -0400 Original-Received: by mail-qt0-f173.google.com with SMTP id q8so2109462qtb.5 for ; Mon, 18 Sep 2017 15:32:51 -0700 (PDT) X-Gm-Message-State: AHPjjUhCchwQMQSsN8AoHvlmEufNtYVTXq4Jk3o0Do2JqXjpW+8h69zM yALPE4cJOlyFKg8s8QVGJA2vuGmdywO5II1PLKc= X-Google-Smtp-Source: AOwi7QC2IgR1SSgJ44t1WCT5yu9Pl43wlE2CMoFxVGB6Q5/yyEBZlkmChzDZnycT5a7xwX3/vZIXSNR7GmBgYztxJfU= X-Received: by 10.200.42.99 with SMTP id l32mr52585219qtl.121.1505773971280; Mon, 18 Sep 2017 15:32:51 -0700 (PDT) Original-Received: by 10.200.28.3 with HTTP; Mon, 18 Sep 2017 15:32:20 -0700 (PDT) X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218497 Archived-At: --001a113bfbeeab989e05597e52ef Content-Type: text/plain; charset="UTF-8" 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 --001a113bfbeeab989e05597e52ef Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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.=C2=A0 How = about modifying posn-set-point like so:

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

I can imagine both global and buffer-local uses of such hooks, suc= h as logging where point has been and highlighting elements selected within= a buffer.=C2=A0 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 i= s in core code.

Bob



--001a113bfbeeab989e05597e52ef--