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: Wed, 20 Jan 2016 18:32:40 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by - "") Content-Type: multipart/mixed; boundary="Multipart_Wed_Jan_20_18:32:39_2016-1" X-Trace: ger.gmane.org 1453343600 4675 80.91.229.3 (21 Jan 2016 02:33:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Jan 2016 02:33:20 +0000 (UTC) Cc: 22404@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 21 03:33:09 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 1aM53d-0001SW-3x for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Jan 2016 03:33:09 +0100 Original-Received: from localhost ([::1]:45801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aM53c-0003x1-EL for geb-bug-gnu-emacs@m.gmane.org; Wed, 20 Jan 2016 21:33:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aM53Z-0003wn-5G for bug-gnu-emacs@gnu.org; Wed, 20 Jan 2016 21:33:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aM53V-0006Vn-Uu for bug-gnu-emacs@gnu.org; Wed, 20 Jan 2016 21:33:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39238) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aM53V-0006Vh-S3 for bug-gnu-emacs@gnu.org; Wed, 20 Jan 2016 21:33:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aM53V-0003c2-Mm for bug-gnu-emacs@gnu.org; Wed, 20 Jan 2016 21:33: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: Thu, 21 Jan 2016 02:33: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.145334357013869 (code B ref 22404); Thu, 21 Jan 2016 02:33:01 +0000 Original-Received: (at 22404) by debbugs.gnu.org; 21 Jan 2016 02:32:50 +0000 Original-Received: from localhost ([127.0.0.1]:55691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aM53J-0003bd-OS for submit@debbugs.gnu.org; Wed, 20 Jan 2016 21:32:49 -0500 Original-Received: from cobb.liquidweb.com ([50.28.13.150]:41975) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aM53I-0003bP-P7 for 22404@debbugs.gnu.org; Wed, 20 Jan 2016 21:32:49 -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=tzunJn7d/AW9pyuVSgrB6BGFsc3rtrzF5qCoFu2A6+8=; b=k972R6108FkXKpGiaYHoyzrjmv4KQzi/8FxxubrnyoXIgpNCr+F4sZwvybQIwP+tSmhsOW057dZI4XkMEqwXgaofYjyYqnBnx2/JhPMF0pwQ6ErglaUs0RRLyKpbBcK2; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:54898 helo=server.local.localhost) by cobb.liquidweb.com with esmtp (Exim 4.82) (envelope-from ) id 1aM538-0000vA-Qx; Wed, 20 Jan 2016 21:32:39 -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:111818 Archived-At: --Multipart_Wed_Jan_20_18:32:39_2016-1 Content-Type: text/plain; charset=US-ASCII `set-window-start` (without the third option) would indeed trigger the WSF because it contains a key ingredient: `w->force_start = true`. Because the second argument (i.e., POS) cannot be known from the PCH when point has moved beyond the visible window, `set-window-start` is not a viable substitute for this feature request. The attached patch is an example of an implementation of this feature request. I created a new function called `force-wsf`, whose sole purpose is to trigger the WSF to run during redisplay -- after the PCH has already finished. As noted in a previous e-mail, `run-window-scroll-functions` doesn't accomplish what `force-wsf` can achieve because the former runs the function attached to the WSF immediately -- instead of waiting until later on during redisplay when the correct values of `window-start` and `window-end` are ascertainable. This is my first attempt at writing something like this, and I'm not sure exactly if everything is correct. It does, however, appear to achieve the desired affect -- i.e., run the WSF at least once every command loop (even if no scrolling occurs) so we can always know the correct values for `window-start` and `window-end`. It is no longer necessary to guess with `elisp` from the PCH regarding whether WSF will run. I would, however, still like to come up with a test at the C-source code level that tells me whether the WSF will run more than one time -- because I only care about the last call on the WSF when the final values for `window-start` and `window-end` become available. The usage for the new function `force-wsf` is as follows: (defun pch-fn () (force-wsf (selected-window))) (add-hook 'post-command-hook 'pch-fn nil 'local) (defun wsf-fn (win start) (message "point: %s | win: %s | start: %s | end: %s" ;; A better test at the C-source code level appears to be needed to ascertain whether ;; the WSF will run more than one time -- because we want the value for `window-start` ;; and `window-end win t` based on the LAST time WSF runs during the command loop. (if (pos-visible-in-window-p nil nil nil) "visible" "NOT visible") win start (window-end win t))) (add-hook 'window-scroll-functions 'wsf-fn nil 'local) The new function in window.c looks like this: DEFUN ("force-wsf", Fforce_wsf, Sforce_wsf, 0, 1, 0, doc: /* Set force_start so that redisplay_window will run the window-scroll-functions. */) (Lisp_Object window) { register struct window *w = decode_live_window (window); w->optional_new_start = true; return; } And, the there is one additional line that may also be required further on down in window.d: defsubr (&Sforce_wsf); Thanks, Keith ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; At Wed, 20 Jan 2016 15:34:41 +0200, Eli Zaretskii wrote: > > > . . . you need to call set-window-start with its 3rd > argument omitted or nil. Does that solve your problem? --Multipart_Wed_Jan_20_18:32:39_2016-1 Content-Type: application/diff; type=patch Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3NyYy93aW5kb3cuYyBiL3NyYy93aW5kb3cuYwppbmRleCA0YWViOGIzLi5m OTlhMWI1IDEwMDY0NAotLS0gYS9zcmMvd2luZG93LmMKKysrIGIvc3JjL3dpbmRvdy5jCkBAIC0z MzIzLDYgKzMzMjMsMTYgQEAgc2V0X3dpbmRvd19idWZmZXIgKExpc3BfT2JqZWN0IHdpbmRvdywg TGlzcF9PYmplY3QgYnVmZmVyLAogICB1bmJpbmRfdG8gKGNvdW50LCBRbmlsKTsKIH0KIAorREVG VU4gKCJmb3JjZ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