emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (Not) scrolling past the end of a buffer


From: Jorgen Schaefer
Subject: Re: (Not) scrolling past the end of a buffer
Date: Sat, 20 Oct 2012 11:52:30 +0200

On Fri, 19 Oct 2012 22:07:59 -0400
Stefan Monnier <address@hidden> wrote:

> > There was a discussion back in February about Emacs scrolling past
> > the end of buffers, but that discussion never finished (as far as I
> > can tell).
> 
> It won't end until someone goes through the trouble to write the code.
> But those who know the code know that it's going to be a pain to
> implement, especially if you want acceptable performance.
> IOW, patches welcome,

As I said, I tried - and failed. :-(

Now, I *do* have some lisp code that does exactly what I want. It's not
exactly the paragon of efficiency, but it works, and it's fast enough
for my needs:

  (when (and window-bottom-mode
             (equal (point-max)
                    (window-end nil t)))
    (save-excursion
      (goto-char (point-max))
      (recenter -1)))

My problem is that I do not have a place where I can actually put this.

`window-scroll-functions' works excellently with only minor performance
problems in large buffers. But since Emacs 24, the docstring of that
variable explicitly says not to do this. As a law-abiding Emacs
citizen, I am trying to fix my code now.

`post-command-hook', as used by ERC, is a very problematic choice.
There, you need to walk through all windows, in all frames, go to the
respective buffer, and then run the code above - after each command.
That's incredibly bad performance. (ERC gets away with it because it
doesn't use `window-end', but it's own input mark; that's not exactly
the behavior I want. I've also seen complaints about that being slower
than the old solution in ERC, but I have no first-hand experience.)

So, now with the request not to use `window-scroll-functions', and
`post-command-hook' being a very bad choice, where would I hook my code
into Emacs?

Regards,
        -- Jorgen



reply via email to

[Prev in Thread] Current Thread [Next in Thread]