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 13:11:48 -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 1453410742 16793 80.91.229.3 (21 Jan 2016 21:12:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Jan 2016 21:12:22 +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 22:12:10 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 1aMMWX-00006g-Md for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Jan 2016 22:12:09 +0100 Original-Received: from localhost ([::1]:49754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMMWW-00019P-MZ for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Jan 2016 16:12:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMMWR-00019F-MX for bug-gnu-emacs@gnu.org; Thu, 21 Jan 2016 16:12:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMMWQ-0000Oq-E5 for bug-gnu-emacs@gnu.org; Thu, 21 Jan 2016 16:12:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40350) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMMWQ-0000Om-9q for bug-gnu-emacs@gnu.org; Thu, 21 Jan 2016 16:12:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aMMWQ-0006Cw-4i for bug-gnu-emacs@gnu.org; Thu, 21 Jan 2016 16:12:02 -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 21:12:02 +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.145341072023855 (code B ref 22404); Thu, 21 Jan 2016 21:12:02 +0000 Original-Received: (at 22404) by debbugs.gnu.org; 21 Jan 2016 21:12:00 +0000 Original-Received: from localhost ([127.0.0.1]:56803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aMMWO-0006Ch-DL for submit@debbugs.gnu.org; Thu, 21 Jan 2016 16:12:00 -0500 Original-Received: from cobb.liquidweb.com ([50.28.13.150]:37166) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aMMWM-0006CU-UF for 22404@debbugs.gnu.org; Thu, 21 Jan 2016 16:11:59 -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=dqNV8W82rnHx+xxEoStjzNVnFhQGRNxLjjDx68jY+Ro=; b=keaWfFncZlIdTEAox6l4HodtfROXsMrbfEjEE7/QjnieJ/znEE09dQkcp2zOz/LGJwMl535fvXw+S/mpWSWbVF9DjLqfpQ1CEq2wMndbr/8Fpn6wVz4vyjYjc4QQxDDW; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:51101 helo=server.local.localhost) by cobb.liquidweb.com with esmtp (Exim 4.82) (envelope-from ) id 1aMMWA-0004Tx-BN; Thu, 21 Jan 2016 16:11:46 -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:111839 Archived-At: > 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`. :) :) > The other thing I still don't understand is how forcing > window-scroll-functions to run could fix your problem or _avoiding_ > extra calculations. Where and under what conditions would you call > the function that forces Emacs to run window-scroll-functions? I either need to use BOTH the `post-command-hook` and `window-scroll-functions` hook; OR, just the WSF if it is forced to always run. WSF is needed (for sure) whenever `window-start` and `window-end` have changed -- so PCH must do the work the rest of the time. I had previously been using a poor test to GUESS (from the PCH) whether WSF will run. > Doesn't that waste processing in those cases where normally > window-scroll-functions didn't need to be run (because window-start > and window-end don't change)? IOW, aren't you running those costly > calculations from window-scroll-functions? If point moves left or right, the vertical ruler that tracks the cursor position moves with the cursor -- so recalculation is needed. The vertical ruler is on a 0.3 idle timer, and the horizontal ruler (with line numbers and pilcrows) is on all the time. For the horizontal ruler, I have a test that compares the previous window-start/end to the new window-start/end -- if it is just cursor movement (instead of self-insert-command), then I use the previously recorded list of calculations. Just moving the cursor left/right/up/down within the same window bounds is much faster than typing or deleting a character. ;; HORIZONTAL RULER (snippet) (setq posn-list (if (and hr-prev-start (= hr-prev-start start) hr-prev-end (= hr-prev-end end) +-posn-list (or (eq +-this-command 'lawlist-left-char) (eq +-this-command 'lawlist-right-char) (eq +-this-command 'lawlist-previous-line) (eq +-this-command 'lawlist-next-line) (eq +-this-command 'lawlist-forward-entity) (eq +-this-command 'lawlist-backward-entity) (eq +-this-command 'lawlist-forward-paragraph) (eq +-this-command 'lawlist-backward-paragraph) (eq +-this-command 'lawlist-end-of-visual-line) (eq +-this-command 'lawlist-beginning-of-visual-line))) +-posn-list (posn start end vcol))) The vertical ruler (on an idle timer) will use the previously recorded list of calculations under a few limited circumstances. ;; VERTICAL RULER (snippet) (setq posn-list (if (or (not +-posn-list) (and (not force) (memq last-command '( special-yank special-copy-selected-region copy-selected-region delete-word-or-whitespace delete-forward-char lawlist-backward-delete-char-untabify lawlist-beginning-of-buffer lawlist-end-of-buffer beginning-of-buffer end-of-buffer scroll-up scroll-down lawlist-super-scroll-up lawlist-super-scroll-down lawlist-scroll-up lawlist-scroll-down lawlist-left-char lawlist-right-char left-char right-char lawlist-previous-line lawlist-next-line previous-line next-line lawlist-forward-entity lawlist-backward-entity lawlist-forward-paragraph lawlist-backward-paragraph forward-paragraph backward-paragraph lawlist-end-of-visual-line lawlist-beginning-of-visual-line end-of-visual-line beginning-of-visual-line)))) (posn start end vcol) +-posn-list)) > Finally, wouldn't running from pre-command-hook solve the problem? > The values of window-start and window-end are known by then, and you > can record the old values to compare them against new, to know when > they change. No? Basically any change to the text requires some type of recalculation -- e.g., line got shorter/longer, block of test was deleted/pasted. Keith