all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Engster <deng@randomsample.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gundaetiapo@gmail.com, 15045@debbugs.gnu.org, eric@siege-engine.com
Subject: bug#15045: Point jumps inappropriately around time of Semantic lexing
Date: Fri, 09 Aug 2013 18:10:04 +0200	[thread overview]
Message-ID: <87pptmsv4z.fsf@engster.org> (raw)
In-Reply-To: <83zjsrs3k2.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 09 Aug 2013 10:53:33 +0300")

Eli Zaretskii writes:
>> From: David Engster <deng@randomsample.de>
>> Cc: gundaetiapo@gmail.com, monnier@iro.umontreal.ca,
>> 15045@debbugs.gnu.org, eric@siege-engine.com
>
>> Date: Fri, 09 Aug 2013 07:36:07 +0200
>> 
>> >> However, doing redisplay in timers is not nice.
>> >
>> > Why not?
>> 
>> Because doing redisplay is a user-visible side effect, and in general,
>> timers shouldn't have those.
>
> How else can a timer such as that of display-time do its thing?  IOW,
> when the purpose of a timer is to cause something to be displayed,
> they have no alternative but to force redisplay.

As you know, Emacs does not have strict timers. If you say to Emacs: one
minute from now, say 'foo', and Emacs happens to be busy one minute from
now, nothing will happen until it waits again. So I wonder: with such a
lenient definition of "timer", does the wait for the next redisplay
really matter? After which idle time does redisplay kick in anyway?

>> AFAICS, any function that calls things like
>> `accept-process-output', `input-pending-p' or `sit-for' inside a
>> `save-excursion' might get an unwanted scrolling effect if point is
>> temporarily moved to some invisible location.
>
> You mean, because of timers that might get run and cause redisplay?

Yes.

> Yes, that's possible.  But the way to avoid this is to never call
> these when point is in a place the user won't expect. Forcing the
> Emacs community not to trigger redisplay inside timers is IMO _not_
> the right way, because this is unnecessarily restrictive, and would
> disallow a whole bunch of useful features for no good reason.

I said: "doing redisplay in timers is not nice". I did not say that it
should be forbidden (if that's even possible).

However, I do propose the following:

- Deleting the 'sit-for' in the display-time-event-handler, since I
  would think that it is the most likely suspect for a non-idle timer
  that does redisplay in a usual Emacs session. The
  force-mode-line-update should be enough, and even if it isn't: if the
  minute is updated half a second too late, we can live with that (we
  can already live with a displayed 'load' value that's up to a minute
  old).

- In (info "(elisp) Timers"), the manual already discourages certain
  things in timers, like changing buffer content or waiting with
  `sit-for'. I think we should add something like this:

  "Also, enforcing a redisplay in non-idle timers is problematic, since
  they may run at times when other functions have moved point or
  narrowed the buffer temporarily.  The redisplay would make these
  visible, leading to unwanted scrolling or sudden narrowing and
  subsequent widening of the buffer.  You should rather try if waiting
  for the next redisplay after the timer has run is sufficient for your
  needs.  If you just change the mode-line, use `force-mode-line-update'
  instead of a full redisplay."

- We should add information to the documentation of
  `access-process-output' and `input-pending-p', like

  "Note that timers may run during this function, which may trigger a
  redisplay.  So before calling this function, you should make sure that
  any temporary changes you made to point position or the buffer (like
  narrowing) are undone, as to not make these changes visible."

As a sidenote: What "bunch of useful features" do you have in mind for
non-idle timers that do redisplay? They shouldn't alter buffer content,
so what can they do that would need immediate redisplay? Displaying some
kind of progress/time indicator is pretty much the only thing I can come
up with.

> IOW, it's the caller of input-pending-p etc. that is the fault here,
> not the timers that it inadvertently lets run.

Until yesterday, I was completely unaware that `accept-process-output'
or `input-pending-p' could run timers that do redisplay, and I think I'm
in good company. The doc-strings do not mention it, so there must be
lots of third-party code which does not pay attention to this, so we
should try that this bug triggers as little as possible.

>> In fact, I just understood another bug in speck-mode (which is similar
>> to flycheck). I sometimes had unwanted scrolls there, too, and I now saw
>> that those also happen at every full minute while typing.
>
> Then there's the same bug there, that's all.

Yes. But it shows that this bug is easy to make, and it's hard to track
down. Also, the bug is slightly different in that speck does not only
alter point, but also narrows the buffer, which is even more scary than
unwanted scrolling.

>> I thought that the jit-lock timer is a non-idle timer, but you are
>> right.
>
> There's no jit-lock timer.

Yes. Sorry for being imprecise. I meant the jit-lock defer timer.

-David





  parent reply	other threads:[~2013-08-09 16:10 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07 17:59 bug#15045: Point jumps inappropriately around time of Semantic lexing Barry OReilly
2013-08-07 18:30 ` Stefan Monnier
2013-08-07 18:42   ` David Engster
2013-08-07 19:31     ` Barry OReilly
2013-08-07 19:44       ` Eli Zaretskii
2013-08-07 20:39         ` Barry OReilly
2013-08-08  2:41           ` Eli Zaretskii
2013-08-08 17:07             ` Barry OReilly
2013-08-08 17:46               ` Eli Zaretskii
2013-08-07 21:23       ` Stefan Monnier
2013-08-08 17:21     ` David Engster
2013-08-08 18:06       ` Stefan Monnier
2013-08-08 18:13         ` David Engster
2013-08-08 21:39         ` Eli Zaretskii
2013-08-08 22:51           ` Stefan Monnier
2013-08-09  7:56             ` Eli Zaretskii
2013-08-09 14:03               ` Stefan Monnier
2013-08-09 14:16                 ` Eli Zaretskii
2013-08-09 17:34                   ` Stefan Monnier
2013-08-09 18:23                     ` Eli Zaretskii
2013-08-08 20:03       ` Barry OReilly
2013-08-08 20:30         ` David Engster
2013-08-08 21:49           ` Eli Zaretskii
2013-08-09  5:36             ` David Engster
2013-08-09  7:53               ` Eli Zaretskii
2013-08-09 11:50                 ` Eric M. Ludlam
2013-08-09 13:31                   ` Eli Zaretskii
2013-08-09 14:04                   ` Stefan Monnier
2013-08-09 14:19                     ` Eli Zaretskii
2013-08-09 18:08                       ` Stefan Monnier
2013-08-09 18:38                         ` Eli Zaretskii
2013-08-09 18:41                           ` David Engster
2013-08-09 20:49                             ` Eli Zaretskii
2013-08-09 21:36                             ` Stefan Monnier
2013-08-10  9:42                               ` David Engster
2013-08-09 21:46                           ` Stefan Monnier
2013-08-09 16:10                 ` David Engster [this message]
2013-08-09 18:31                   ` Eli Zaretskii
2013-08-10  9:54                     ` David Engster
2013-08-10 10:22                       ` Eli Zaretskii
2013-08-10 18:06                         ` Barry OReilly
2013-10-14 19:32                           ` Barry OReilly
2013-10-14 19:51                             ` Eli Zaretskii
2013-10-15 13:42                               ` Stefan Monnier
2013-10-15 14:12                                 ` Barry OReilly
2013-10-15 16:28                                   ` Eli Zaretskii
2013-10-15 17:08                                     ` Barry OReilly
2013-10-15 18:48                                       ` Eli Zaretskii
2013-10-15 19:19                                         ` Barry OReilly
2013-10-16  2:57                                       ` Stefan Monnier
2013-10-16 14:57                                         ` Barry OReilly
2013-10-16 17:50                                           ` Stefan Monnier
2013-10-16 18:32                                             ` Barry OReilly
2013-10-17 15:03                                             ` Barry OReilly
2013-10-17 18:18                                               ` Stefan Monnier
2013-10-17 20:01                                                 ` Barry OReilly
2013-10-18  0:27                                                   ` Stefan Monnier
2013-10-18 14:03                                                     ` Barry OReilly
2013-10-25 19:15                                                       ` Barry OReilly
2013-11-14 18:21                                                         ` Barry OReilly
2013-11-16  4:14                                                           ` Stefan Monnier
2013-11-16  4:54                                                             ` Barry OReilly
2013-11-16 17:37                                                               ` Stefan Monnier
2013-11-16 20:33                                                                 ` Barry OReilly
2013-11-16 21:29                                                                   ` Stefan Monnier
2013-08-09 18:50                   ` Stefan Monnier
2013-08-09  9:12               ` martin rudalics
2013-08-09 16:27                 ` David Engster
2013-08-09 17:10                   ` martin rudalics
2013-08-09 18:51                   ` Stefan Monnier
2013-08-08 21:26         ` Stefan Monnier
2013-08-08 21:57           ` Eli Zaretskii
2013-08-08 22:50             ` Stefan Monnier
2013-08-09  7:54               ` Eli Zaretskii
2013-08-08 21:47         ` Eli Zaretskii
2013-08-09  3:26       ` Eric M. Ludlam

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=87pptmsv4z.fsf@engster.org \
    --to=deng@randomsample.de \
    --cc=15045@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=eric@siege-engine.com \
    --cc=gundaetiapo@gmail.com \
    /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.