all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 22404@debbugs.gnu.org
Subject: bug#22404: 25.1.50; Forcing `window-scroll-functions` to run.
Date: Thu, 21 Jan 2016 13:11:48 -0800	[thread overview]
Message-ID: <m2bn8eab8r.wl%esq@lawlist.com> (raw)
In-Reply-To: <m260yqdsp7.wl%esq@lawlist.com>

> 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





  parent reply	other threads:[~2016-01-21 21:11 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19  5:49 bug#22404: 25.1.50; Forcing `window-scroll-functions` to run Keith David Bershatsky
2016-01-19 17:50 ` Eli Zaretskii
2016-01-19 18:49 ` Keith David Bershatsky
2016-01-19 19:39   ` Eli Zaretskii
2016-01-19 18:53 ` John Wiegley
2016-01-19 19:26 ` Keith David Bershatsky
2016-01-19 20:35 ` Keith David Bershatsky
2016-01-20 13:34   ` Eli Zaretskii
2016-01-19 23:07 ` Keith David Bershatsky
2016-01-21  2:32 ` Keith David Bershatsky
2016-01-21 17:41   ` Eli Zaretskii
2016-01-21 19:54 ` Keith David Bershatsky
2016-01-21 20:28   ` Eli Zaretskii
2016-01-29 12:00     ` Michael Heerdegen
2016-01-29 14:37       ` Eli Zaretskii
2016-01-29 14:57         ` Michael Heerdegen
2016-01-29 15:33           ` Eli Zaretskii
2016-01-21 21:11 ` Keith David Bershatsky [this message]
2016-01-29  2:14   ` John Wiegley
2016-01-29  3:08 ` Keith David Bershatsky
2016-01-29  8:42   ` Eli Zaretskii
2016-01-29 15:54 ` Keith David Bershatsky
2016-02-01  3:50 ` Keith David Bershatsky
2016-02-01 19:54   ` Eli Zaretskii
2016-02-01 13:18 ` Keith David Bershatsky
2016-02-02 16:34   ` Eli Zaretskii
2016-02-02  5:58 ` Keith David Bershatsky
2016-02-02 18:16 ` Keith David Bershatsky
2016-02-02 18:43   ` Eli Zaretskii
2016-02-02 20:00 ` Keith David Bershatsky
2016-02-02 21:05 ` Keith David Bershatsky
2016-02-08  8:51 ` Keith David Bershatsky
2016-02-08 17:17   ` Eli Zaretskii
2016-02-09 16:00 ` Keith David Bershatsky
2016-02-09 17:48   ` Eli Zaretskii
2016-02-12  0:14 ` Keith David Bershatsky
2016-02-12  8:18   ` Eli Zaretskii
2016-02-16  3:39     ` Keith David Bershatsky
2016-02-12  8:25   ` Why do idle timers trigger redisplay? Eli Zaretskii
2016-02-22  6:05 ` bug#22404: 25.1.50; Forcing `window-scroll-functions` to run Keith David Bershatsky
2016-03-11 16:21 ` Keith David Bershatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2bn8eab8r.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=22404@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.