From: "Drew Adams" <drew.adams@oracle.com>
To: "'Stefan Monnier'" <monnier@iro.umontreal.ca>
Cc: 5923@debbugs.gnu.org
Subject: bug#5923: 23.1.95; minibuffer-message discards input events
Date: Tue, 20 Apr 2010 09:18:28 -0700 [thread overview]
Message-ID: <C68D354839BC439681CDDE4359E56473@us.oracle.com> (raw)
In-Reply-To: <EE56D5192B7448138B8876177844DC3C@us.oracle.com>
[-- Attachment #1: Type: text/plain, Size: 2582 bytes --]
The problem appears to be with `sit-for', not with `minibuffer-message'. More
specifically, the call to `input-pending-p' in `sit-for' does not act as it
should. Dunno if `input-pending-p' is the problem generally, or just in this
context.
Attached is a small, simple, self-contained file that reproduces the problem.
Just load it, then `M-x C-u sssss'. The `s' keystrokes are ignored while the
`sit-for' delay is waited for.
In all cases except `icicle-universal-argument', the original command is called,
followed by a call to `message' and then `sit-for'.
`icicle-universal-argument' is identical to `universal-argument' except:
* It too calls `message' followed by `sit-for'.
* It uses `icicle-ensure-overriding-map-is-bound', not
`ensure-overriding-map-is-bound'. The difference is that the former sets
`overriding-terminal-local-map' to `icicle-universal-argument-map', not
`universal-argument-map'.
The difference between those two maps is that the `icicle-*' commands are used
in place of the originals (and each `icicle-*' command calls `message' followed
by `sit-for').
So all of the changes from the vanilla Emacs code amount to the same trivial
change: Add a call to `message' and `sit-for' after the vanilla command behavior
is finished. There are no other changes.
`sit-for' seems to be the problem, but there is no change in the code for
`sit-for' from Emacs 22 and Emacs 23 (where the bug first appears). Perhaps
there is a relevant change elsewhere that has to do with these keymaps or with
input events?
Debugging `sit-for' a bit indicates that `input-pending-p' does indeed return
nil when it should return non-nil in this context (after user input). The final
`cond' branch is taken in the `sit-for' code, instead of the `input-pending-p'
branch.
There is no change in the C source code for `input-pending-p' itself, between
Emacs 22 and 23. But it tests several global vars in order to do its thing, so
perhaps the bug was introduced by changing the value of one of those vars. The
vars are `unread-command-events', `unread-command-char',
`unread-post-input-method-events', and `unread-input-method-events'. That seems
likely.
Note this in the doc string of `input-pending-p': "Actually, the value is nil
only if we can be ***sure*** that no input is available; if there is a doubt,
the value is t."
Obviously, we are by no means respecting that declared conservative behavior. It
is returning nil (in this case) even when we should not be sure that no input is
available - even when input is in fact available.
I hope this bug will be fixed. Thx.
[-- Attachment #2: bug-5923-emacs-4.el --]
[-- Type: application/octet-stream, Size: 3264 bytes --]
(defvar icicle-universal-argument-map
(let ((map (make-sparse-keymap)))
(define-key map [t] 'icicle-universal-argument-other-key)
(define-key map (vector meta-prefix-char t) 'icicle-universal-argument-other-key)
(define-key map [switch-frame] nil)
(define-key map [?\C-u] 'icicle-universal-argument-more)
(define-key map [?-] 'icicle-universal-argument-minus)
(define-key map [?0] 'icicle-digit-argument)
(define-key map [?1] 'icicle-digit-argument)
(define-key map [?2] 'icicle-digit-argument)
(define-key map [?3] 'icicle-digit-argument)
(define-key map [?4] 'icicle-digit-argument)
(define-key map [?5] 'icicle-digit-argument)
(define-key map [?6] 'icicle-digit-argument)
(define-key map [?7] 'icicle-digit-argument)
(define-key map [?8] 'icicle-digit-argument)
(define-key map [?9] 'icicle-digit-argument)
(define-key map [kp-0] 'icicle-digit-argument)
(define-key map [kp-1] 'icicle-digit-argument)
(define-key map [kp-2] 'icicle-digit-argument)
(define-key map [kp-3] 'icicle-digit-argument)
(define-key map [kp-4] 'icicle-digit-argument)
(define-key map [kp-5] 'icicle-digit-argument)
(define-key map [kp-6] 'icicle-digit-argument)
(define-key map [kp-7] 'icicle-digit-argument)
(define-key map [kp-8] 'icicle-digit-argument)
(define-key map [kp-9] 'icicle-digit-argument)
(define-key map [kp-subtract] 'icicle-universal-argument-minus)
map)
"...")
(defun icicle-universal-argument ()
(interactive)
(setq prefix-arg (list 4)
universal-argument-num-events (length (this-command-keys)))
(icicle-ensure-overriding-map-is-bound)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
(defun icicle-digit-argument (arg)
(interactive "P")
(digit-argument)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
(defun icicle-negative-argument (arg)
(interactive "P")
(negative-argument arg)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
(defun icicle-universal-argument-more (arg)
(interactive "P")
(universal-argument-more arg)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
(defun icicle-universal-argument-other-key (arg)
(interactive "P")
(universal-argument-other-key arg)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
(defun icicle-universal-argument-minus (arg)
(interactive "P")
(universal-argument-minus arg)
(icicle-msg-maybe-in-minibuffer "prefix %S" prefix-arg))
(defun icicle-ensure-overriding-map-is-bound ()
(unless overriding-map-is-bound
(setq saved-overriding-map overriding-terminal-local-map
overriding-terminal-local-map icicle-universal-argument-map
overriding-map-is-bound t)))
(defun icicle-msg-maybe-in-minibuffer (format-string &rest args)
(apply #'message format-string args)
(sit-for 1))
(define-key minibuffer-local-completion-map [remap universal-argument]
'icicle-universal-argument)
(define-key minibuffer-local-completion-map [remap negative-argument]
'icicle-negative-argument)
(define-key minibuffer-local-completion-map [remap digit-argument]
'icicle-digit-argument)
next prev parent reply other threads:[~2010-04-20 16:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-10 16:52 bug#5923: 23.1.95; minibuffer-message discards input events Drew Adams
2010-04-10 19:15 ` Stefan Monnier
2010-04-10 19:59 ` Drew Adams
2010-04-14 2:19 ` Stefan Monnier
2010-04-14 5:06 ` Drew Adams
2010-04-19 5:38 ` Drew Adams
2010-04-19 6:09 ` Drew Adams
2010-04-20 16:18 ` Drew Adams [this message]
2010-04-20 23:45 ` Drew Adams
2010-04-21 0:05 ` Drew Adams
2010-07-23 22:26 ` Stefan Monnier
2010-07-28 15:24 ` Drew Adams
2016-07-05 4:06 ` npostavs
2016-07-05 14:19 ` Drew Adams
2016-07-06 13:11 ` Noam Postavsky
2016-07-06 13:59 ` Drew Adams
2016-07-06 14:55 ` Noam Postavsky
2016-07-06 15:05 ` Eli Zaretskii
2016-07-06 15:30 ` Noam Postavsky
2016-07-06 15:38 ` Eli Zaretskii
2016-07-06 14:25 ` bug#3938: " Eli Zaretskii
2016-07-06 15:10 ` bug#5923: " Drew Adams
2016-07-06 15:32 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C68D354839BC439681CDDE4359E56473@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=5923@debbugs.gnu.org \
--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 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.