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, 21 Jan 2016 11:54:30 -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 1453406124 5506 80.91.229.3 (21 Jan 2016 19:55:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Jan 2016 19:55:24 +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 20:55:12 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 1aMLK2-0005Pg-3o for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Jan 2016 20:55:10 +0100 Original-Received: from localhost ([::1]:49557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMLK1-0008K3-B6 for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Jan 2016 14:55:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMLJx-0008Hw-7f for bug-gnu-emacs@gnu.org; Thu, 21 Jan 2016 14:55:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMLJu-0006b5-0B for bug-gnu-emacs@gnu.org; Thu, 21 Jan 2016 14:55:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMLJt-0006b1-S4 for bug-gnu-emacs@gnu.org; Thu, 21 Jan 2016 14:55:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aMLJt-0005xm-JJ for bug-gnu-emacs@gnu.org; Thu, 21 Jan 2016 14:55: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 19:55: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.145340608122872 (code B ref 22404); Thu, 21 Jan 2016 19:55:01 +0000 Original-Received: (at 22404) by debbugs.gnu.org; 21 Jan 2016 19:54:41 +0000 Original-Received: from localhost ([127.0.0.1]:56694 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aMLJZ-0005wq-2Y for submit@debbugs.gnu.org; Thu, 21 Jan 2016 14:54:41 -0500 Original-Received: from cobb.liquidweb.com ([50.28.13.150]:35050) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aMLJY-0005wa-3q for 22404@debbugs.gnu.org; Thu, 21 Jan 2016 14:54:40 -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=RkyARdFMZqfMuaUm+xBBiv3O5PZkIEKjr2M6xuzMY0U=; b=fGTKPG2QLh4MU8oQX1YBvrzSZWZ/JuAMR+VWmoxbA/g+MwevnJFlLH9u8Fxy8bGmZH+ia/O5bv4QnwYvRot2C1yI5nym+T2p432/6KtgF/oHjDo3gU6IP2/gxGdbw7RO; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50522 helo=server.local.localhost) by cobb.liquidweb.com with esmtp (Exim 4.82) (envelope-from ) id 1aMLJN-00062p-HE; Thu, 21 Jan 2016 14:54:29 -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:111833 Archived-At: I have a minor mode that draws overlays from `window-start` to `window-end`, and those two values are mission critical to making sure that the overlays are placed correctly. I have `word-wrap` set to `t`. I have a function that makes relevant calculations in the visible window, which begins at `window-start` and uses `vertical-motion` for every visual line until `window-end`. Along the way, I gather 22 different elements of a list for EACH visible line: points at the beginning/ending of visual line (pbovl/peovl); points at beginning/ending of full line (bol/eol); column at the end of visual line (col-at-eovl); line number `(format-mode-line "%l")`; and all of the following in a vertical line (from top to bottom of the window) where the cursor is: column, point, character, foreground/b ackground colors of character. When the list is assembled, I then take that list and place overlays to create a horizontal and vertical line compatible with `word-wrap` -- the result is a visual cross-hairs spanning the entire length and width of the visible window. I am using XPM images for the vertical line, which permits me to achieve a thin vertical line to the left of each character -- it looks just like a thin vbar cursor. I control the color of the vertical line -- the letters remain the same color they were, but the line color varies -- yellow for even column number; red for odd column number; green for when I am beyond the fill-column on the first visual line; a medium blue for a line that is visually wrapped when point is on a visual line subsequent to the first wrapped line; and a cyan color when point is a t the right window boundary. The horizontal line stretches the entire length of the window, even for the word-wrapped lines. I have some fancy XPM images that change depending upon where point is. It works with active regions too. I have line numbering (in the left-hand margin) for each line. I placer certain bitmap images in the right fringe depending when point is at the last character at the window edge, or when there is a hard return at the right window edge. Each line-end (eol) has a pilcrow symbol that is XPM, except when cursor is at eol, in which case it is a different XPM image. The end of the buffer has a different XPM image and the vertical line extends to the last visual line, even if the point at the end of the buffer is a few inches to the left of the vertical line. The calculations (primarily because of `vertical-motion`) are too costly time-wise to perform more than once during each command loop because it slows down performance. If I run the calculations from the `post-command-hook`, I will have wasted precious time IF the `window-scroll-functions` hook will be running. IF the `window-scroll-functions` hook will be running, then the `window-start` and `window-end` obtained from the `post-command-hook` will be wrong -- so there is no point using those PCH wrong numbers. If I run the calculations from the INITIAL run of the `window-scroll-functions` hook, I will have wasted precious time IF the WSF hook will be running a SECOND time. [WSF runs a SECOND time if point was PARTIALLY visible.] IF the WSF will be running more than one time, then the INITIAL values for `window-start` and `window-end` will be wrong -- so there is no point using those WSF wrong numbers. Instead, I have to wait until the LAST call on the WSF when the final correct values for `window-start` and `window-end` can be truly ascertained. Without the benefit of feature request 22404, there are a couple of options that are not ideal. OPTION # 1(a): Devise an efficient/accurate test that can be called from the `post-command-hook` to ascertain whether the `window-scroll-functions` hook will be running one or more times. [Without a forced trigger, WSF only runs SOME of the time.] If the WSF will be running one or more times, then do NOT perform the overlay calculations because the PCH values for `window-start` and `window-end` are wrong. If the WSF will NOT be running, then go ahead and perform the time-costly calculations and place the overlays immediately. OPTION # 1(b): When the `window-scroll-functions` hook runs, I need to figure out whether it will be running one more time (subsequently) because point was only partially visible. The only test I am aware of is `(pos-visible-in-window-p nil nil nil)`. The LAST call on the WSF is the mission critical because that produces the correct values for `window-start` and `window-end`. If WSF will only be running once, then go ahead and perform the time-costly calculations and place the overlays immediately. If the WSF will be running more than once, then the *initial* WSF values for `window-start and `window-end` are wrong -- in that case, wait until the last call of WSF to perform the calculations and place overlays. OPTION # 2: Call `set-window-buffer` from the `post-command-hook` as a means of forcing WSF to run during the latter part of redisplay. In this case, we never use the PCH values of `window-start` and `window-end` -- instead, we wait for WSF to give us the correct values. This solution is not preferred because `set-window-buffer` was not designed to be used solely as a WSF trigger. In the context of my example, I don't need to set the window buffer and I don't need to run the `window-configuration-change-hook` -- I just want to force WSF to run during the latter part of redisplay. OPTION # 3: Trigger the WSF without all the hoopla -- e.g., w->optional_new_start = true;. E.g., my sample C-function `force_wsf`. OPTION # 4 (ideal): Create an entirely new animal that knows whether WSF will run more than once, and only produces the correct values for `window-start` and `window-end` in ALL circumstances, and then permits the user to run a custom function that takes advantage of those values. Thanks, Keith