unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: storm@cua.dk, monnier@iro.umontreal.ca, 21747@debbugs.gnu.org,
	bruce.connor.am@gmail.com
Subject: bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook
Date: Sun, 25 Oct 2015 09:10:42 +0100	[thread overview]
Message-ID: <87oafnpdvh.fsf@gnu.org> (raw)
In-Reply-To: <87si4zpg97.fsf@gnu.org> (Tassilo Horn's message of "Sun, 25 Oct 2015 08:19:16 +0100")

Tassilo Horn <tsdh@gnu.org> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Tassilo Horn <tsdh@gnu.org>
>>> Cc: bruce.connor.am@gmail.com, monnier@iro.umontreal.ca, storm@cua.dk,
>>> 21747@debbugs.gnu.org
>>> Date: Sat, 24 Oct 2015 15:30:11 +0200
>>> 
>>> Eli Zaretskii <eliz@gnu.org> writes:
>>> 
>>> >> My recipe for reproduction is
>>> >> 
>>> >>   1. emacs -Q
>>> >>   2. M-x package-initialize
>>> >>   3. M-x global-aggressive-indent-mode
>>> >>   4. C-x C-f ~/test.sh
>>> >>   5. type the keyword if where the i is displayed immediately
>>> >>      and the display of f is delayed
>>> >> 
>>> >> This does only occur for sh-mode keywords like if, while, etc. where the
>>> >> delaying starts with after entering the last char of the keyword.  Also,
>>> >> I can reproduce that problem only if test.sh doesn't exist.
>>> >
>>> > I don't understand: are you saying that the post-command-hook finished
>>> > its job, and yet redisplay is not entered?
>>> 
>>> Yes, or rather the function aggressive-indent--indent-if-changed which
>>> is in post-command-hook finished.
>>> 
>>> >> Or well, I just tried what happens when I replace the `while-no-input'
>>> >> with a `progn'.  Then Emacs goes into some infloop.  Attaching with gdb
>>> >> shows:
>>> >
>>> > There's a procedure in etc/DEBUG to determine which call-stack frame
>>> > infloops, please use it and tell what you found.
>>> 
>>> Ok, so with the aggressive-indent--indent-if-changed where
>>> while-no-input is replaced with progn, I perform my recipe until emacs
>>> infloops.  Then do "kill -TSTP <PID>" and repeatedly "finish" at the gdb
>>> prompt.  But the last frame being displayed in GDB before finish doesn't
>>> return anymore is not always the same.  Most of the time it is poll ()
>>> from /usr/lib/libc.so.6.  Here are two other results.
>>
>> No, that's bogus (GC cannot infloop, you just didn't wait long enough
>> for that "finish" to return).
>
> Oh, sorry.
>
>> The function that infloops is re-search-backward, because it is called
>> with LIMIT set to zero.  The real problem is here:
>>
>>   (defun sh-smie--keyword-p ()
>>     "Non-nil if we're at a keyword position.
>>   A keyword position is one where if we're looking at something that looks
>>   like a keyword, then it is a keyword."
>>     (let ((prev (funcall smie-backward-token-function)))
>>       (if (zerop (length prev))
>> 	  (looking-back "\\`\\|\\s(" (1- (point)))  <<<<<<<<<<<<<<<<<<
>> 	(assoc prev smie-grammar))))
>>
>> What do you expect looking-back to do here when point is at BOB?
>
> I think when point is a BOB, then the \\` part of the regex would match
> for sure so replacing looking-back with (or (bobp) (looking-back ...))
> would have the same semantics, right?  So I've tried this patch:

By the way, I cannot reproduce an infloop in re-search-backward when
LIMIT is zero.  Instead, with the current unchanged master code I also
have pretty much the same infloop on the SMIE lisp level as in the
previous mail where I patched the code in order not to run in LIMIT = 0
cases:

1 -> (aggressive-indent--indent-if-changed)
| 2 -> (aggressive-indent--run-user-hooks)
| 2 <- aggressive-indent--run-user-hooks: nil
| 2 -> (aggressive-indent--softly-indent-region-and-on 2 3)
| | 3 -> (aggressive-indent-indent-region-and-on 2 3)
| | | 4 -> (sh-smie--indent-continuation)
| | | | 5 -> (sh-smie--looking-back-at-continuation-p)
| | | | 5 <- sh-smie--looking-back-at-continuation-p: nil
| | | 4 <- sh-smie--indent-continuation: nil
| | | 4 -> (sh-smie-sh-forward-token)
| | | | 5 -> (sh-smie--default-forward-token)
| | | | 5 <- sh-smie--default-forward-token: "if"
| | | | 5 -> (sh-smie--sh-keyword-p "if")
| | | | | 6 -> (sh-smie--keyword-p)
| | | | | | 7 -> (sh-smie-sh-backward-token)
| | | | | | | 8 -> (sh-smie--default-backward-token)
| | | | | | | 8 <- sh-smie--default-backward-token: ""
| | | | | | 7 <- sh-smie-sh-backward-token: ""
| | | | | 6 <- sh-smie--keyword-p: t
| | | | 5 <- sh-smie--sh-keyword-p: t
| | | 4 <- sh-smie-sh-forward-token: "if"
| | | 4 -> (sh-smie-sh-forward-token)
| | | | 5 -> (sh-smie--newline-semi-p)
| | | | | 6 -> (sh-smie-sh-backward-token)
| | | | | | 7 -> (sh-smie--default-backward-token)
| | | | | | 7 <- sh-smie--default-backward-token: "if"
| | | | | | 7 -> (sh-smie--sh-keyword-p "if")
| | | | | | | 8 -> (sh-smie--keyword-p)
| | | | | | | | 9 -> (sh-smie-sh-backward-token)
| | | | | | | | | 10 -> (sh-smie--default-backward-token)
| | | | | | | | | 10 <- sh-smie--default-backward-token: ""
| | | | | | | | 9 <- sh-smie-sh-backward-token: ""
| | | | | | | 8 <- sh-smie--keyword-p: t
| | | | | | 7 <- sh-smie--sh-keyword-p: t
| | | | | 6 <- sh-smie-sh-backward-token: "if"
| | | | 5 <- sh-smie--newline-semi-p: nil
| | | 4 <- sh-smie-sh-forward-token: ";"

[the above one repeats indefinitely]

| | | 4 -> (sh-smie-sh-forward-token)
| | | | 5 -> (sh-smie--newline-semi-p)
| | | | | 6 -> (sh-smie-sh-backward-token)
| | | | | | 7 -> (sh-smie--default-backward-token)
| | | | | | 7 <- sh-smie--default-backward-token: "if"
| | | | | | 7 -> (sh-smie--sh-keyword-p "if")
| | | | | | | 8 -> (sh-smie--keyword-p)
| | | | | | | | 9 -> (sh-smie-sh-backward-token)
| | | | | | | 8 <- sh-smie--keyword-p: !non-local\ exit!
| | | | | | 7 <- sh-smie--sh-keyword-p: !non-local\ exit!
| | | | | 6 <- sh-smie-sh-backward-token: !non-local\ exit!
| | | | 5 <- sh-smie--newline-semi-p: !non-local\ exit!
| | | 4 <- sh-smie-sh-forward-token: !non-local\ exit!
| | 3 <- aggressive-indent-indent-region-and-on: !non-local\ exit!
| 2 <- aggressive-indent--softly-indent-region-and-on: !non-local\ exit!
1 <- aggressive-indent--indent-if-changed: t

Bye,
Tassilo





  reply	other threads:[~2015-10-25  8:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-24  7:42 bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook Tassilo Horn
2015-10-24  8:02 ` Eli Zaretskii
2015-10-24  8:53   ` Tassilo Horn
2015-10-24  9:14     ` Eli Zaretskii
2015-10-24  9:49       ` Tassilo Horn
2015-10-24 10:30         ` Artur Malabarba
2015-10-24 10:52           ` Eli Zaretskii
2015-10-24 12:13             ` Tassilo Horn
2015-10-24 12:45               ` Eli Zaretskii
2015-10-24 13:30                 ` Tassilo Horn
2015-10-24 13:57                   ` Artur Malabarba
2015-10-24 14:06                     ` Eli Zaretskii
2015-10-24 14:05                   ` Eli Zaretskii
2015-10-25  7:19                     ` Tassilo Horn
2015-10-25  8:10                       ` Tassilo Horn [this message]
2015-10-25  9:25                         ` Tassilo Horn
2015-10-25 18:45                           ` Eli Zaretskii
2015-10-25 18:49                             ` Tassilo Horn
2015-10-25 20:10                           ` Stefan Monnier
2015-10-26  6:57                             ` Tassilo Horn
2015-10-25 18:43                       ` Eli Zaretskii
2015-10-24 12:46               ` Tassilo Horn
2015-10-25 14:43             ` Artur Malabarba
2015-10-25 18:50               ` Eli Zaretskii
2015-10-26  0:27                 ` Artur Malabarba
2015-10-26  3:32                   ` Eli Zaretskii
2015-10-26 13:43                     ` Tassilo Horn
2015-10-24 10:35         ` Eli Zaretskii

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=87oafnpdvh.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=21747@debbugs.gnu.org \
    --cc=bruce.connor.am@gmail.com \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=storm@cua.dk \
    /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).