From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#22404: 25.1.50; Forcing `window-scroll-functions` to run. Date: Thu, 28 Jan 2016 19:08:22 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by - "") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1454036969 1664 80.91.229.3 (29 Jan 2016 03:09:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 Jan 2016 03:09:29 +0000 (UTC) Cc: 22404@debbugs.gnu.org To: "John Wiegley" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 29 04:09:15 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1aOzQs-0007eX-Ab for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Jan 2016 04:09:10 +0100 Original-Received: from localhost ([::1]:59541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOzQr-0002In-Jb for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Jan 2016 22:09:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOzQn-0002G6-GX for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2016 22:09:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOzQk-0006K6-Af for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2016 22:09:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51959) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOzQk-0006K2-7j for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2016 22:09:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aOzQj-0005TW-VE for bug-gnu-emacs@gnu.org; Thu, 28 Jan 2016 22:09:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Jan 2016 03:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22404 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22404-submit@debbugs.gnu.org id=B22404.145403691121007 (code B ref 22404); Fri, 29 Jan 2016 03:09:01 +0000 Original-Received: (at 22404) by debbugs.gnu.org; 29 Jan 2016 03:08:31 +0000 Original-Received: from localhost ([127.0.0.1]:40179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aOzQF-0005Sl-CP for submit@debbugs.gnu.org; Thu, 28 Jan 2016 22:08:31 -0500 Original-Received: from cobb.liquidweb.com ([50.28.13.150]:59667) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aOzQD-0005SY-T5 for 22404@debbugs.gnu.org; Thu, 28 Jan 2016 22:08:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date; bh=oUfAtJAH5HCCCUuEI2zq3Ie1s63nwTMs2U09cW05dBs=; b=Nit7t4CI9YnIdW8G9Xt8Ryb1CRw4Bcj2MouJ7rr51coN7eT4aBVFQ3VkGYCVGeskGRuyS5vOn8QCBMt7ha7HEvJZMP21Uj0oqUgLiYLZn8vgEgY5GteNojzvv/T4Q8n8; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:53099 helo=server.private.localhost) by cobb.liquidweb.com with esmtp (Exim 4.82) (envelope-from ) id 1aOzQ5-0002sn-5f; Thu, 28 Jan 2016 22:08:21 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cobb.liquidweb.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-Get-Message-Sender-Via: cobb.liquidweb.com: acl_c_relayhosts_text_entry: lawlist|lawlist.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:112072 Archived-At: Thanks, John, for taking another look at #22404. Let's say for example that someone has a function named `foo` which uses `window-start` and `window-end`, and the user wants that function to run every command loop. Everyone will immediately think of the `post-command-hook` because the buffer or position may have been modified by `this-command` (whatever that may be). The way Emacs is presently designed, people are needlessly calling `foo` multiple times when scrolling occurs because the `post-command-hook` can't provide correct numbers. Most people probably don't care because `foo` is trivial in terms of the time it takes to run -- so if it runs 3 times per command loop, no problem. I personally think calling `foo` 3 times per command loop, when it only needed to run once, is a poor design. There is no 100% guaranteed test from the `post-command-hook` to know whether the `window-scroll-functions` hook will run, and if so, whether it will run 2 times (instead of just one). Here is an excerpt from `window.h` that tells us what `optional_new_start` is currently used for: /* True means we have explicitly changed the value of start, but that the next redisplay is not obliged to use the new value. This is used in Fdelete_other_windows to force a call to Vwindow_scroll_functions; also by Frecenter with argument. */ bool_bf optional_new_start : 1; It is also used for `set-window-buffer`; so perhaps that should be added to the doc-string. By setting `optional_new_start` to `true`, we force the `window_scroll_functions` hook to run every command loop (during redisplay). If that happens, then the `post-command-hook` is no longer needed to run `foo`. So we have just reduced `foo` being called 2 to 3 times, to 1 to 2 times instead. I have been studying `xdisp.c` and have concluded that it is extremely difficult to know whether the `window-scroll-functions` hook will run 1 or 2 times, because that hook can modify the buffer and there are some other hooks that may modify the buffer too -- thus requiring a second call to the WSF. So, the moral of the story is whether it is a good thing to call `foo` 2 to 3 times per command loop, instead of 1 to 2 times per command loop. And, it boils down to whether `foo` is costly. It is costly for me because I use `vertical-motion`. It may be costly to other users for a different reason. Another idea would be to create a new animal that permits users to THROW_ANY_SWITCH from `elisp`. It doesn't have to be `optional_new_start` specifically. If users have an `elisp` mechanism to THROW_ANY_SWITCH, they can throw it from anywhere -- `pre-command-hook`, `post-command-hook`, etc. [By switch, I mean the bool_bf items in `window.h`.] Keith ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; At Thu, 28 Jan 2016 18:14:43 -0800, John Wiegley wrote: > > >>>>> Keith David Bershatsky writes: > > >> What do you need from window-scroll-functions? Only the correct values of > >> window-start and window-end? Or something else? > > > Correct, I just need the 100% accurate `window-start` and > > `window-end`. :) :) > > Keith, your use case here does strike me as a bit exotic. I'm not saying it's > not a bug, but I'm wondering if your suggested solution is really the best > path to the final result you're reaching for. The cost of `vertical-motion', > for example, seems to be a driving force behind your request.