From: Daniel Colascione <dancol@dancol.org>
To: 17139@debbugs.gnu.org
Subject: bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook?
Date: Fri, 28 Mar 2014 19:39:28 -0700 [thread overview]
Message-ID: <53363260.9060207@dancol.org> (raw)
In-Reply-To: <53362D5C.2070502@dancol.org>
[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]
On 03/28/2014 07:18 PM, Daniel Colascione wrote:
> Say we're using a mode derived from comint that implements completion by
> using the comint redirection functionality to send commands to the
> process associated with the comint buffer. Say we have TAB bound to
> complete-symbol. If the user presses TAB (to create a list of
> completions) and then immediately presses RET to run comint-send-input,
> we send the input to the subprocess, but don't wait for a reply. Then we
> run post-command-hook; completion-in-region--postch is on the list of
> hooks to run. This function runs completion-in-region-mode--predicate,
> which makes a hidden call to the subprocess; this hidden call involves
> writing a command waiting for a reply. But because we just sent the
> *user* line in comint-send-input, we might actually read the response to
> *that* line instead of the internal completion command, causing an
> error. The response to the internal completion command then appears in
> the comint buffer.
>
> Why can't we do the completion-in-region--postch stuff in pre-command-hook?
I think this fix works, but I'm not particularly familiar with the
completion code. Can someone review?
=== modified file 'lisp/comint.el'
--- lisp/comint.el 2014-03-22 22:12:52 +0000
+++ lisp/comint.el 2014-03-29 02:36:49 +0000
@@ -1769,6 +1769,12 @@
Similarly for Soar, Scheme, etc."
(interactive)
+ ;; If we're currently completing, stop. We're definitely done
+ ;; completing, and by sending the input, we might cause side effects
+ ;; that will confuse the code running in the completion
+ ;; post-command-hook.
+ (when completion-in-region-mode
+ (completion-in-region-mode -1))
;; Note that the input string does not include its terminal newline.
(let ((proc (get-buffer-process (current-buffer))))
(if (not proc) (user-error "Current buffer has no process")
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]
next prev parent reply other threads:[~2014-03-29 2:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-29 2:18 bug#17139: Race condition in complete-in-region: should we be using pre-command-hook, not post-command-hook? Daniel Colascione
2014-03-29 2:39 ` Daniel Colascione [this message]
2014-03-30 21:39 ` Stefan Monnier
2014-03-30 21:49 ` Daniel Colascione
2014-03-31 12:40 ` Stefan Monnier
2014-03-31 18:20 ` Daniel Colascione
2016-06-04 22:17 ` Noam Postavsky
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=53363260.9060207@dancol.org \
--to=dancol@dancol.org \
--cc=17139@debbugs.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 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).