From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.devel Subject: Re: Use cases for post-redisplay hooks Date: Thu, 07 Jul 2016 10:53:29 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by - "") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1467914053 29096 80.91.229.3 (7 Jul 2016 17:54:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Jul 2016 17:54:13 +0000 (UTC) Cc: Michael Heerdegen , Stefan Monnier , emacs-devel@gnu.org To: =?UTF-8?B?Q2zDqW1lbnQ=?= Pit--Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 07 19:54:03 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bLDUw-0004Ms-3F for ged-emacs-devel@m.gmane.org; Thu, 07 Jul 2016 19:54:02 +0200 Original-Received: from localhost ([::1]:41538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLDUv-0007X8-9a for ged-emacs-devel@m.gmane.org; Thu, 07 Jul 2016 13:54:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLDUk-0007UX-OG for emacs-devel@gnu.org; Thu, 07 Jul 2016 13:53:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLDUi-0002BY-Q7 for emacs-devel@gnu.org; Thu, 07 Jul 2016 13:53:49 -0400 Original-Received: from black.tulip.relay.mailchannels.net ([23.83.218.19]:45916) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLDUd-0002Ae-9L; Thu, 07 Jul 2016 13:53:44 -0400 X-Sender-Id: _forwarded-from|45.48.239.195 Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 960DD100C68; Thu, 7 Jul 2016 17:53:34 +0000 (UTC) Original-Received: from cobb.liquidweb.com (ip-10-37-2-55.us-west-2.compute.internal [10.37.2.55]) by relay.mailchannels.net (Postfix) with ESMTPA id CE1D31004D5; Thu, 7 Jul 2016 17:53:33 +0000 (UTC) X-Sender-Id: _forwarded-from|45.48.239.195 Original-Received: from cobb.liquidweb.com (cobb.liquidweb.com [10.135.9.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA) by 0.0.0.0:2500 (trex/5.6.15); Thu, 07 Jul 2016 17:53:34 +0000 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|45.48.239.195 X-MailChannels-Auth-Id: liquidweb X-MC-Loop-Signature: 1467914014260:611967896 X-MC-Ingress-Time: 1467914014259 Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50457 helo=server.local.localhost) by cobb.liquidweb.com with esmtp (Exim 4.82) (envelope-from ) id 1bLDUR-0006Js-8H; Thu, 07 Jul 2016 13:53:31 -0400 X-AuthUser: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 23.83.218.19 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:205364 Archived-At: Yes, a `needs-recalculation` flag would be very useful -- i.e., when the = values for `window-start` and `window-end` are correct and not going to c= hange, then run the Lisp function (attached to the hook) that depends upo= n those values being correct. A counter, however, may not be a reliable = indicator of the above test. [My assumption is that overlays could be placed before the screen visuall= y refreshes, so that the overlays are visually present when redisplay fin= ishes.] Keith ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; At Thu, 7 Jul 2016 12:08:09 -0400, Cl=C3=A9ment Pit--Claudel wrote: >=20 > On 2016-07-04 18:50, Keith David Bershatsky wrote: > > The reason I mentioned the `window-scroll-functions` hook was an > > assumption (on my part) that Cl=C3=A9ment had initially categorized m= y > > potential usage of the proposed `post-redisplay-hook` as only > > relating to scrolling. I just wanted to clarify / differentiate my > > proposed use case as needing `window-start` and `window-end` each > > command loop. >=20 > IIUC then the post-redisplay-hook thing wouldn't work very nicely: in g= eneral, it's going to run more often than once per command loop cycle. >=20 > > With respect to the hook running more than once each command loop, it > > is only a problem for me because my calculations are costly time-wise > > (e.g., `vertical-motion'). So, I only want to do it one time each > > command loop. >=20 > Would registering a post-command hook and incrementing a counter in the= re help? You would then predicate your costly calculations on the value o= f that counter having changed since the last time the calculations ran. >=20 > Even simpler: in a pre/post-command hook switch a `needs-recalculation'= flag to t, and after completing the calculations (from whichever other h= ook you're using for them) switch `needs-recalculation' to nil. If the fu= nction doing the calculations is called when `needs-recalculation' is nil= , then can exit immediately. >=20 > Or is there something more complex that I'm missing? >=20 > Cl=C3=A9ment. >=20 > [2 OpenPGP digital signature ]