all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
@ 2016-04-03 10:32 Mark Karpov
  2016-04-03 14:56 ` Eli Zaretskii
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Mark Karpov @ 2016-04-03 10:32 UTC (permalink / raw)
  To: 23204


I'm not sure if it's sort of feature (rather undocumented) or a bug.
Let's say I have a command that uses ‘read-char’ repeatedly, and it's
given a custom prompt as the first argument, like this:

  (defun my-command ()
    (interactive)
    (while (read-char "My prompt…" t)))

Now if you call this from lisp or like this: ‘M-x my-command RET’,
everything is fine: you see the prompt and you can type some chars
(press ‘C-g’ to get out of this).

But if you bind the command to key sequence, like this:

  (global-set-key (kbd "<menu> t y") #'my-command)

Then you have a nasty problem when you actually call it. Try to call it
and then type some characters — you will see no prompt and they will
accumulate in echo area indefinitely:

  menu t y h e r e SPC I SPC t y p e SPC t h i n g s SPC a n d SPC i t
  SPC i s SPC g e t t i n g SPC r a t h e r SPC l o n g

Does this work as intended? I would like to continue using ‘read-char’,
is there a way to just display my prompt in this case as well?



In GNU Emacs 25.1.50.9 (x86_64-unknown-linux-gnu, GTK+ Version 3.18.9)
 of 2016-03-24 built on arch
Repository revision: 39577d07124ee16895b9c6aab7e2c6e7d41cc715
Windowing system distributor 'The X.Org Foundation', version 11.0.11802000
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: H

Minor modes in effect:
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  vimish-fold-global-mode: t
  vimish-fold-mode: t
  show-paren-mode: t
  rich-minority-mode: t
  minibuffer-electric-default-mode: t
  ivy-mode: t
  global-auto-revert-mode: t
  display-time-mode: t
  delete-selection-mode: t
  cyphejor-mode: t
  ace-popup-menu-mode: t
  smartparens-global-mode: t
  flyspell-lazy-mode: t
  mk-highlight-line-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-fill-mode: 1

Recent messages:
Wrote /home/mark/.emacs.d/.git/COMMIT_EDITMSG
Git finished [2 times]
<menu> t y is undefined
typit-advanced-test
Quit
Would you like to play again? (y or n) n
Quit
Type "q" in help window to restore its previous buffer.
Modalka mode enabled in current buffer
Modalka mode disabled in current buffer

Load-path shadows:
/home/mark/.emacs.d/elpa/seq-2.15/seq hides /usr/local/share/emacs/25.1.50/lisp/emacs-lisp/seq

Features:
(shadow mail-extr emacsbug sendmail eieio-opt speedbar sb-image ezimage
dframe sort cal-move parse-time map diary-lib diary-loaddefs cal-iso
org-element org-rmail org-mhe org-irc org-info org-gnus org-docview
doc-view jka-compr org-bibtex bibtex org-bbdb org-w3m org-agenda org
org-macro org-footnote org-pcomplete org-list org-faces org-entities
org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-src ob-keys ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs cal-menu calendar cal-loaddefs zzz-to-char char-menu
dired-aux compile em-unix em-term term disp-table ehelp em-script
em-prompt em-ls em-hist em-pred em-glob em-dirs em-cmpl em-basic
em-banner em-alias esh-var esh-io esh-cmd esh-opt esh-ext esh-proc
esh-arg esh-groups eshell esh-module esh-mode vc vc-dispatcher
markdown-mode noutline outline linum magit-blame magit-stash
magit-bisect magit-remote magit-commit magit-sequence magit magit-apply
magit-wip magit-log magit-diff smerge-mode magit-core magit-autorevert
magit-process magit-popup magit-mode magit-git crm magit-section
magit-utils git-commit help-fns log-edit message rfc822 mml mml-sec epa
derived epg gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log with-editor
async-bytecomp async tramp-sh tramp tramp-compat tramp-loaddefs trampver
shell pcomplete comint ansi-color format-spec image-mode ace-window
hl-line dired dired-loaddefs vc-git diff-mode bookmark pp typit mmt
colir color counsel esh-util etags swiper aggressive-indent easy-mmode
rainbow-delimiters whitespace hl-todo flycheck-haskell haskell-cabal
haskell-utils flycheck-color-mode-line face-remap mk-visual
smart-mode-line solarized-dark-theme solarized mk-texinfo mk-tex
mk-shakespeare mk-prolog mk-org mk-markdown mk-man mk-magit mk-lisp
mk-js mk-ibuffer mk-html mk-gnus mk-eshell mk-erc mk-elisp mk-dired
mk-clojure kill-or-bury-alive mk-calendar mk-c mk-minor-modes
common-lisp-snippets yasnippet whole-line-or-region vimish-fold paren
rich-minority minibuf-eldef ivy ffap autorevert filenotify time delsel
cyphejor ace-popup-menu smartparens-config smartparens thingatpt
flyspell ispell flyspell-lazy cl mk-highlight-line mk-global modalka
edmacro kmacro fix-input quail ace-link xref project mk-python
mk-haskell mk-utils avy-menu avy ring flycheck find-func rx subr-x seq
seq-25 misc server f dash s ucs-normalize finder-inf tex-site fix-word
advice slime-autoloads info package epg-config url-handlers url-parse
auth-source cl-seq eieio byte-opt bytecomp byte-compile cl-extra
help-mode easymenu cconv eieio-core cl-macs gv eieio-loaddefs
cl-loaddefs pcase cl-lib password-cache url-vars time-date mule-util
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 554151 56418)
 (symbols 48 48648 0)
 (miscs 40 441 1766)
 (strings 32 115109 20051)
 (string-bytes 1 3514812)
 (vectors 16 79022)
 (vector-slots 8 1938762 165104)
 (floats 8 787 1950)
 (intervals 56 4215 460)
 (buffers 976 70)
 (heap 1024 62381 4356))





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-04-03 10:32 bug#23204: 25.1.50; Strange behaviour of ‘read-char’ Mark Karpov
@ 2016-04-03 14:56 ` Eli Zaretskii
  2016-04-03 16:33 ` Mark Karpov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2016-04-03 14:56 UTC (permalink / raw)
  To: Mark Karpov; +Cc: 23204

> From: Mark Karpov <markkarpov@openmailbox.org>
> Date: Sun, 03 Apr 2016 16:32:33 +0600
> 
>   (defun my-command ()
>     (interactive)
>     (while (read-char "My prompt…" t)))
> 
> Now if you call this from lisp or like this: ‘M-x my-command RET’,
> everything is fine: you see the prompt and you can type some chars
> (press ‘C-g’ to get out of this).
> 
> But if you bind the command to key sequence, like this:
> 
>   (global-set-key (kbd "<menu> t y") #'my-command)
> 
> Then you have a nasty problem when you actually call it. Try to call it
> and then type some characters — you will see no prompt and they will
> accumulate in echo area indefinitely:
> 
>   menu t y h e r e SPC I SPC t y p e SPC t h i n g s SPC a n d SPC i t
>   SPC i s SPC g e t t i n g SPC r a t h e r SPC l o n g

What if you do this instead:

  (global-set-key (kbd "<f8>") #'my-command)

Does this work as expected?  If so, does that explain what happens in
your original example?





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-04-03 10:32 bug#23204: 25.1.50; Strange behaviour of ‘read-char’ Mark Karpov
  2016-04-03 14:56 ` Eli Zaretskii
@ 2016-04-03 16:33 ` Mark Karpov
  2016-06-12 17:02 ` Noam Postavsky
  2022-02-03 20:47 ` Lars Ingebrigtsen
  3 siblings, 0 replies; 10+ messages in thread
From: Mark Karpov @ 2016-04-03 16:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 23204

This works, but I do not see how it explains this behavior. IMO, the
prompt should appear no matter how the command is invoked, because that
prompt is part of that command's functioning.

Eli Zaretskii writes:

> What if you do this instead:
>
>   (global-set-key (kbd "<f8>") #'my-command)
>
> Does this work as expected?  If so, does that explain what happens in
> your original example?





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-04-03 10:32 bug#23204: 25.1.50; Strange behaviour of ‘read-char’ Mark Karpov
  2016-04-03 14:56 ` Eli Zaretskii
  2016-04-03 16:33 ` Mark Karpov
@ 2016-06-12 17:02 ` Noam Postavsky
  2016-06-12 17:11   ` Eli Zaretskii
  2022-02-03 20:47 ` Lars Ingebrigtsen
  3 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2016-06-12 17:02 UTC (permalink / raw)
  To: 23204; +Cc: Mark Karpov

severity 23204 minor
quit

I also don't quite understand why this happens, but it seems that
using (message nil) to clear the minibuffer also works:

(defun my-command ()
  (interactive)
  (message nil)
  (while (read-char "My prompt…" t)))

(global-set-key (kbd "<f12> t y") #'my-command)

(I can't bind <menu> t y in emacs -Q, I get an error message telling
me <menu> is not a prefix key)





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-06-12 17:02 ` Noam Postavsky
@ 2016-06-12 17:11   ` Eli Zaretskii
  2016-06-12 17:13     ` Noam Postavsky
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2016-06-12 17:11 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: markkarpov, 23204

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Sun, 12 Jun 2016 13:02:30 -0400
> Cc: Mark Karpov <markkarpov@openmailbox.org>
> 
> I also don't quite understand why this happens, but it seems that
> using (message nil) to clear the minibuffer also works:
> 
> (defun my-command ()
>   (interactive)
>   (message nil)
>   (while (read-char "My prompt…" t)))
> 
> (global-set-key (kbd "<f12> t y") #'my-command)
> 
> (I can't bind <menu> t y in emacs -Q, I get an error message telling
> me <menu> is not a prefix key)

I think the problem is specifically with invoking such commands via
menus, and the reason is that menu handling is inside the toolkit, out
of Emacs control.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-06-12 17:11   ` Eli Zaretskii
@ 2016-06-12 17:13     ` Noam Postavsky
  2016-06-12 17:17       ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2016-06-12 17:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Mark Karpov, 23204

On Sun, Jun 12, 2016 at 1:11 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> I think the problem is specifically with invoking such commands via
> menus, and the reason is that menu handling is inside the toolkit, out
> of Emacs control.

No, without the (message nil) I see the problem when binding to <f12> t y.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-06-12 17:13     ` Noam Postavsky
@ 2016-06-12 17:17       ` Eli Zaretskii
  2016-06-12 17:23         ` Noam Postavsky
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2016-06-12 17:17 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: markkarpov, 23204

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Sun, 12 Jun 2016 13:13:09 -0400
> Cc: 23204@debbugs.gnu.org, Mark Karpov <markkarpov@openmailbox.org>
> 
> On Sun, Jun 12, 2016 at 1:11 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> > I think the problem is specifically with invoking such commands via
> > menus, and the reason is that menu handling is inside the toolkit, out
> > of Emacs control.
> 
> No, without the (message nil) I see the problem when binding to <f12> t y.

Because F12 is not a prefix key.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-06-12 17:17       ` Eli Zaretskii
@ 2016-06-12 17:23         ` Noam Postavsky
  2016-06-12 17:26           ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2016-06-12 17:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Mark Karpov, 23204

On Sun, Jun 12, 2016 at 1:17 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Noam Postavsky <npostavs@users.sourceforge.net>
>> Date: Sun, 12 Jun 2016 13:13:09 -0400
>> Cc: 23204@debbugs.gnu.org, Mark Karpov <markkarpov@openmailbox.org>
>>
>> On Sun, Jun 12, 2016 at 1:11 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> > I think the problem is specifically with invoking such commands via
>> > menus, and the reason is that menu handling is inside the toolkit, out
>> > of Emacs control.
>>
>> No, without the (message nil) I see the problem when binding to <f12> t y.
>
> Because F12 is not a prefix key.

Ok, then I don't quite understand what you mean by "menus", I thought
that means the thing at the top of the screen that can be clicked with
the mouse.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-06-12 17:23         ` Noam Postavsky
@ 2016-06-12 17:26           ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2016-06-12 17:26 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: markkarpov, 23204

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Sun, 12 Jun 2016 13:23:31 -0400
> Cc: 23204@debbugs.gnu.org, Mark Karpov <markkarpov@openmailbox.org>
> 
> On Sun, Jun 12, 2016 at 1:17 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> From: Noam Postavsky <npostavs@users.sourceforge.net>
> >> Date: Sun, 12 Jun 2016 13:13:09 -0400
> >> Cc: 23204@debbugs.gnu.org, Mark Karpov <markkarpov@openmailbox.org>
> >>
> >> On Sun, Jun 12, 2016 at 1:11 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> > I think the problem is specifically with invoking such commands via
> >> > menus, and the reason is that menu handling is inside the toolkit, out
> >> > of Emacs control.
> >>
> >> No, without the (message nil) I see the problem when binding to <f12> t y.
> >
> > Because F12 is not a prefix key.
> 
> Ok, then I don't quite understand what you mean by "menus"

Maybe nothing, if the OP's problem is also that <menu>, whatever it
is, is not a prefix key.

> I thought that means the thing at the top of the screen that can be
> clicked with the mouse.

Me too, but maybe I was just confused.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#23204: 25.1.50; Strange behaviour of ‘read-char’
  2016-04-03 10:32 bug#23204: 25.1.50; Strange behaviour of ‘read-char’ Mark Karpov
                   ` (2 preceding siblings ...)
  2016-06-12 17:02 ` Noam Postavsky
@ 2022-02-03 20:47 ` Lars Ingebrigtsen
  3 siblings, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-03 20:47 UTC (permalink / raw)
  To: Mark Karpov; +Cc: 23204

Mark Karpov <markkarpov@openmailbox.org> writes:

> I'm not sure if it's sort of feature (rather undocumented) or a bug.
> Let's say I have a command that uses ‘read-char’ repeatedly, and it's
> given a custom prompt as the first argument, like this:
>
>   (defun my-command ()
>     (interactive)
>     (while (read-char "My prompt…" t)))
>
> Now if you call this from lisp or like this: ‘M-x my-command RET’,
> everything is fine: you see the prompt and you can type some chars
> (press ‘C-g’ to get out of this).
>
> But if you bind the command to key sequence, like this:
>
>   (global-set-key (kbd "<menu> t y") #'my-command)
>
> Then you have a nasty problem when you actually call it. Try to call it
> and then type some characters — you will see no prompt and they will
> accumulate in echo area indefinitely:
>
>   menu t y h e r e SPC I SPC t y p e SPC t h i n g s SPC a n d SPC i t
>   SPC i s SPC g e t t i n g SPC r a t h e r SPC l o n g

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I can reproduce this problem in Emacs 25.1, but not on the current
master, so it looks like it's been fixed in the years since this was
first reported, and I'm therefore closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-02-03 20:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-03 10:32 bug#23204: 25.1.50; Strange behaviour of ‘read-char’ Mark Karpov
2016-04-03 14:56 ` Eli Zaretskii
2016-04-03 16:33 ` Mark Karpov
2016-06-12 17:02 ` Noam Postavsky
2016-06-12 17:11   ` Eli Zaretskii
2016-06-12 17:13     ` Noam Postavsky
2016-06-12 17:17       ` Eli Zaretskii
2016-06-12 17:23         ` Noam Postavsky
2016-06-12 17:26           ` Eli Zaretskii
2022-02-03 20:47 ` Lars Ingebrigtsen

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.