From: David Engster <deng@randomsample.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Barry OReilly <gundaetiapo@gmail.com>,
15045@debbugs.gnu.org, "Eric M. Ludlam" <eric@siege-engine.com>
Subject: bug#15045: Point jumps inappropriately around time of Semantic lexing
Date: Thu, 08 Aug 2013 19:21:12 +0200 [thread overview]
Message-ID: <87eha4t7xz.fsf@engster.org> (raw)
In-Reply-To: <87pptptk9n.fsf@engster.org> (David Engster's message of "Wed, 07 Aug 2013 20:42:44 +0200")
[-- Attachment #1: Type: text/plain, Size: 3487 bytes --]
[Adding Eric to CC]
David Engster writes:
> Stefan Monnier writes:
>>> The short of it is that I occasionally witness point jump to elsewhere
>>> in the buffer while I'm editing and then back again.
>>
>> So it's "displayed at A" then "displayed at B" then "displayed at
>> A again"? what happens between each one of those 3 displays?
>>
>> If "nothing", then I suspect there's something like a `sit-for'
>> somewhere that causes a redisplay in the middle of the command (i.e. in
>> the middle of a save-excursion).
>
> I sometimes see this as well, and yes, "nothing" happens between those
> three displays. I also think there's a redisplay triggered by another
> background task while Semantic does its idle parsing stuff.
I think I tracked this down. I first instrumented `sit-for' to see which
background tasks trigger it. On my machine, this happens by two things:
`jit-lock-deferred-fontify', and `display-time-event-handler'.
The display-time handler is called twice per minute: I have
(display-time) in my .emacs, and every full minute the time gets updated
in the mode-line. Also, it is called in the
gnus-after-get-new-news-hook, and since I check for new mails in the
background, it gets called through this, too.
It's kinda hard to trigger this problem through jit-lock, since its idle
time is much smaller than the one from Semantic. So I disabled it and
tried to trigger the jump by stopping typing at roughly XX:XX:59. The
semantic idle function kicks in after 1 second, and lo and behold, I saw
a jump. It's still difficult to reproduce, but I managed to get two
backtraces in the past hour, which are attached.
As you can see, the display-time-event-handler does indeed interrupt the
lexing phase. It does a `sit-for', the display jumps. Not sure what
happens after that. Does the semantic-idle function resume? Anyway,
somehow point gets back to its original position, and through
`trace-redisplay', I saw the following on stderr:
0x7f35178 (test.cpp): same window start
0x7f35178 (test.cpp): 1
redisplay_preserve_echo_area (2)
redisplay_internal 0
0x7f35178 (test.cpp): try_scrolling
redisplay_preserve_echo_area (8)
redisplay_internal 0
0x7f35178 (test.cpp): same window start
0x7f35178 (test.cpp): 1
0x7f35178 (test.cpp): try_scrolling
redisplay_preserve_echo_area (8)
I guess this just says that redisplay made point visible by scrolling,
right?
You might wonder how the display-time-event-handler can interrupt the
Semantic lexer. In the two backtraces, you see that it calls
`accept-process-output' and `input-pending-p'. This is hidden inside the
macro `semantic-throw-on-input', which can be called in code wrapped
inside `semantic-exit-on-input'; it's our poor-man's 'yield'. It's used
extensively in the idle function code, and it's just there to do a
non-local exit in case the user does something. However, now I know that
it also allows other timers to run.
If you look in the `define-lex' macro, you see that it calls
`semantic-throw-on-input' after each identified token. The problem is
that it does not restore the cursor position before that, so I guess the
fix is simply to change this call to
(save-excursion
(goto-char starting-position)
(semantic-throw-on-input 'lex))
Obviously, we will have to check all other calls to
`semantic-throw-on-input' for this as well. However, I also wonder if
display-time-event-handler couldn't just call `force-mode-line-update';
or does this repaint the whole display as well?
-David
[-- Attachment #2: backtr1.txt --]
[-- Type: text/plain, Size: 991 bytes --]
sit-for(0)
display-time-event-handler()
apply(display-time-event-handler nil)
byte-code("[snipped]" [timer apply 5 6] 4)
timer-event-handler([t 20995 27860 0 60 display-time-event-handler nil nil 0])
accept-process-output()
semantic-c-lexer(2886 7946 nil nil)
semantic-lex(2886 7946 nil)
semantic-parse-region-default(2886 7946 nil nil nil)
semantic-parse-region-c-mode(2886 7946 nil nil nil)
semantic-parse-region(2886 7946 nil)
semantic-edits-incremental-parser-1()
byte-code("[snipped]" [err message "incremental parser error: %S" error-message-string t] 4)))] 3)
semantic-parse-changes-default()
semantic-parse-changes()
semantic-fetch-tags()
byte-code("[snipped]" [semantic-fetch-tags nil] 1)
semantic-idle-scheduler-refresh-tags()
byte-code("[snipped]")
semantic-idle-core-handler()
semantic-idle-scheduler-function()
apply(semantic-idle-scheduler-function nil)
timer-event-handler([t 0 1 0 t semantic-idle-scheduler-function nil idle 0])
[-- Attachment #3: backtr2.txt --]
[-- Type: text/plain, Size: 1266 bytes --]
sit-for(0)
display-time-event-handler()
apply(display-time-event-handler nil)
byte-code("[snipped]" [timer apply 5 6] 4)
timer-event-handler([t 20995 36800 0 60 display-time-event-handler nil nil 0])
input-pending-p()
semantic-c-lexer(2939 7944 nil nil)
semantic-lex(2939 7944 nil)
semantic-parse-region-default(2939 7944 bovine-inner-scope nil t)
semantic-parse-region-c-mode(2939 7944 bovine-inner-scope nil t)
semantic-parse-region(2939 7944 bovine-inner-scope nil t)
semantic-get-local-variables-default()
semantic-get-local-variables-c++-mode()
semantic-get-local-variables()
semantic-get-all-local-variables-default(nil)
semantic-get-all-local-variables()
byte-code("[snipped]" [scopecache eieio-oset localvar semantic-get-all-local-variables] 4)
semantic-calculate-scope(7797)
semantic-analyze-current-context-default(7797)
semantic-analyze-current-context(7797)
byte-code("[snipped]" [semantic-analyze-current-context] 2)
semantic-idle-summary-current-symbol-info-context()
semantic-idle-summary-current-symbol-info-default()
semantic-idle-summary-current-symbol-info-c-mode()
semantic-idle-summary-current-symbol-info()
semantic-idle-summary-idle-function()
funcall(semantic-idle-summary-idle-function)
next prev parent reply other threads:[~2013-08-08 17:21 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 [this message]
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
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eha4t7xz.fsf@engster.org \
--to=deng@randomsample.de \
--cc=15045@debbugs.gnu.org \
--cc=eric@siege-engine.com \
--cc=gundaetiapo@gmail.com \
--cc=monnier@iro.umontreal.ca \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).