GNU bug report logs - #10477
zap-to-char should allow picking from history

Previous Next

Package: emacs;

Reported by: jidanni <at> jidanni.org

Date: Wed, 11 Jan 2012 03:29:01 UTC

Severity: wishlist

Tags: fixed

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10477 in the body.
You can then email your comments to 10477 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Wed, 11 Jan 2012 03:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to jidanni <at> jidanni.org:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 11 Jan 2012 03:29:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: jidanni <at> jidanni.org
To: bug-gnu-emacs <at> gnu.org
Subject: zap-to-char should allow picking from history
Date: Wed, 11 Jan 2012 11:27:46 +0800
zap-to-char should allow typing e.g., the up arrow to pick a recently used
character, and then RET.

Currently the only way is to type the actual character back in again!
Even if hard to type CKS!

Currently one gets 'Non-character input-event'.

It should work something like one can maneuver at M-x occur's 'List
lines matching regexp:' prompt.

So: if a-z etc. is pressed, then no RET should be required.

If any 'Non-character input-event' is pressed, then we should be able to
manipulate from a history list of recently zapped chars.

emacs-version "24.0.92.1"




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Sun, 15 Jan 2012 01:25:02 GMT) Full text and rfc822 format available.

Message #8 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: <jidanni <at> jidanni.org>, <10477 <at> debbugs.gnu.org>
Subject: RE: bug#10477: zap-to-char should allow picking from history
Date: Sat, 14 Jan 2012 17:23:55 -0800
> zap-to-char should allow typing e.g., the up arrow to pick a 
> recently used character, and then RET.
> 
> Currently the only way is to type the actual character back in again!
> Even if hard to type CKS!
> 
> Currently one gets 'Non-character input-event'.
> 
> It should work something like one can maneuver at M-x occur's 'List
> lines matching regexp:' prompt.
> So: if a-z etc. is pressed, then no RET should be required.
> 
> If any 'Non-character input-event' is pressed, then we should 
> be able to manipulate from a history list of recently zapped chars.

This sounds similar to bug #1580 (which jidanni also filed), though the emphasis
seems a bit different.

---

FWIW, in Icicles, command `icicle-zap-to-char' uses function
`icicle-read-char-maybe-completing' interactively, which is like `read-char'
unless you hit a completing key (e.g. `TAB') or you hit `C-q'.

If you hit a completing key, you complete a character name against either the
names of your previously entered Unicode chars (default behavior) or all Unicode
char names (depends on an option setting).

It is function `icicle-read-char-by-name', a replacement for
`read-char-by-name', which does the completion.  It also populates the
Unicode-char history list used by `icicle-read-char-maybe-completing'.

You can read (and zap to) a TAB char by hitting C-q first: `C-q TAB'.  You can
read (and zap to) a `C-q' char by hitting `C-q C-q'.

The idea is to try to make it easier to zap to Unicode (e.g. Chinese) chars that
you have already inserted.  The tradeoff is that zapping to a TAB or C-q char
requires you to hit `C-q' first.

(I don't really know whether completing against a char name is necessarily
easier than "to type the actual character back in again".  Completing against a
history list instead of all Unicode chars as candidates, the thought was that it
might be.  Dunno.)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Sun, 15 Jan 2012 01:40:03 GMT) Full text and rfc822 format available.

Message #11 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: jidanni <at> jidanni.org
To: drew.adams <at> oracle.com
Cc: 10477 <at> debbugs.gnu.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Sun, 15 Jan 2012 09:38:26 +0800
>>>>> "DA" == Drew Adams <drew.adams <at> oracle.com> writes:
DA> The idea is to try to make it easier to zap to Unicode (e.g. Chinese) chars that
DA> you have already inserted.  The tradeoff is that zapping to a TAB or C-q char
DA> requires you to hit `C-q' first.
Well pros with embedded control characters probably have other means of zapping.
DA> (I don't really know whether completing against a char name is necessarily
DA> easier than "to type the actual character back in again".  Completing against a
DA> history list instead of all Unicode chars as candidates, the thought was that it
DA> might be.  Dunno.)
I don't know if "completion" is relevant in the case of just one character.
All I know is hitting one or two up arrows and then RET is what the user
would like to do.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Sun, 15 Jan 2012 03:49:02 GMT) Full text and rfc822 format available.

Message #14 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: <jidanni <at> jidanni.org>
Cc: 10477 <at> debbugs.gnu.org
Subject: RE: bug#10477: zap-to-char should allow picking from history
Date: Sat, 14 Jan 2012 19:47:36 -0800
> DA> The idea is to try to make it easier to zap to Unicode 
> DA> (e.g. Chinese) chars that you have already inserted.
> DA> The tradeoff is that zapping to a TAB or C-q char
> DA> requires you to hit `C-q' first.
>
> Well pros with embedded control characters probably have 
> other means of zapping.
>
> DA> (I don't really know whether completing against a char 
> DA> name is necessarily easier than "to type the actual
> DA> character back in again".  Completing against a
> DA> history list instead of all Unicode chars as candidates, 
> DA> the thought was that it might be.  Dunno.)
>
> I don't know if "completion" is relevant in the case of just 
> one character.  All I know is hitting one or two up arrows
> and then RET is what the user would like to do.

You can do that as well in Icicles during completion.  You have the choice: type
chars to match candidates (in this case, Unicode char names) or cycle using,
e.g., arrow keys.  E.g., you can do this:

M-z TAB <up> <up> <up>...





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Mon, 14 Oct 2019 03:12:02 GMT) Full text and rfc822 format available.

Message #17 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: jidanni <at> jidanni.org
Cc: 10477 <at> debbugs.gnu.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Mon, 14 Oct 2019 05:11:41 +0200
jidanni <at> jidanni.org writes:

> zap-to-char should allow typing e.g., the up arrow to pick a recently used
> character, and then RET.
>
> Currently the only way is to type the actual character back in again!
> Even if hard to type CKS!
>
> Currently one gets 'Non-character input-event'.

I've now implemented this in Emacs 27 -- it was more code than expected,
so perhaps simple.el isn't the right place for it.  On the other hand,
`zap-to-char' is there, so perhaps that's the right place for it?

Or it could go to subr-x.el with an autoload -- `zap-to-char' probably
isn't the most used command ever, anyway, and I'm not sure
`read-char-with-history' has much utility outside that command.

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




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 14 Oct 2019 03:12:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 10477 <at> debbugs.gnu.org and jidanni <at> jidanni.org Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 14 Oct 2019 03:12:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Sun, 27 Oct 2019 22:03:02 GMT) Full text and rfc822 format available.

Message #24 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 10477 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Sun, 27 Oct 2019 23:30:43 +0200
>> zap-to-char should allow typing e.g., the up arrow to pick a recently used
>> character, and then RET.
>>
>> Currently the only way is to type the actual character back in again!
>> Even if hard to type CKS!
>>
>> Currently one gets 'Non-character input-event'.
>
> I've now implemented this in Emacs 27 -- it was more code than expected,
> so perhaps simple.el isn't the right place for it.  On the other hand,
> `zap-to-char' is there, so perhaps that's the right place for it?

I tried typing the up arrow, but it fails with the error
"Non-character input-event".  Is this intentional?

> Or it could go to subr-x.el with an autoload -- `zap-to-char' probably
> isn't the most used command ever, anyway, and I'm not sure
> `read-char-with-history' has much utility outside that command.

Indeed, subr-x.el looks like a more suitable place.

Another variant is create a new file for commands reading input
with a name like read-x.el (or maybe minibuffer-x.el or prompt-x.el).
Then put here `read-char-with-history', also all functions from
lisp/emacs-lisp/map-ynp.el and lisp/emacs-lisp/rmc.el,
maybe also read-char-choice from subr.el.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Sun, 27 Oct 2019 22:15:01 GMT) Full text and rfc822 format available.

Message #27 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 10477 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Sun, 27 Oct 2019 23:14:46 +0100
Juri Linkov <juri <at> linkov.net> writes:

>> I've now implemented this in Emacs 27 -- it was more code than expected,
>> so perhaps simple.el isn't the right place for it.  On the other hand,
>> `zap-to-char' is there, so perhaps that's the right place for it?
>
> I tried typing the up arrow, but it fails with the error
> "Non-character input-event".  Is this intentional?

That's the way the command has always worked, so I didn't change that.

>> Or it could go to subr-x.el with an autoload -- `zap-to-char' probably
>> isn't the most used command ever, anyway, and I'm not sure
>> `read-char-with-history' has much utility outside that command.
>
> Indeed, subr-x.el looks like a more suitable place.
>
> Another variant is create a new file for commands reading input
> with a name like read-x.el (or maybe minibuffer-x.el or prompt-x.el).
> Then put here `read-char-with-history', also all functions from
> lisp/emacs-lisp/map-ynp.el and lisp/emacs-lisp/rmc.el,
> maybe also read-char-choice from subr.el.

Makes sense to me.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Sun, 27 Oct 2019 22:36:02 GMT) Full text and rfc822 format available.

Message #30 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 10477 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Mon, 28 Oct 2019 00:34:55 +0200
>>> I've now implemented this in Emacs 27 -- it was more code than expected,
>>> so perhaps simple.el isn't the right place for it.  On the other hand,
>>> `zap-to-char' is there, so perhaps that's the right place for it?
>>
>> I tried typing the up arrow, but it fails with the error
>> "Non-character input-event".  Is this intentional?
>
> That's the way the command has always worked, so I didn't change that.

I tried the up arrow because this is what OP asked to implement:

  "zap-to-char should allow typing e.g., the up arrow to pick a recently used
   character, and then RET."

Using read-from-minibuffer would allow this for free.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Mon, 28 Oct 2019 10:49:02 GMT) Full text and rfc822 format available.

Message #33 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 10477 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Mon, 28 Oct 2019 11:48:30 +0100
Juri Linkov <juri <at> linkov.net> writes:

> I tried the up arrow because this is what OP asked to implement:
>
>   "zap-to-char should allow typing e.g., the up arrow to pick a recently used
>    character, and then RET."

I wasn't aware that <up> traversed the history -- I've always used
`M-p'.  But, yes, <up> should work in zap-to-char, too, then.

> Using read-from-minibuffer would allow this for free.

How would you implement read-char-with-history using
read-from-minibuffer?  Rebind self-insert-command?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Mon, 28 Oct 2019 23:01:02 GMT) Full text and rfc822 format available.

Message #36 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 10477 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Tue, 29 Oct 2019 00:17:56 +0200
>> Using read-from-minibuffer would allow this for free.
>
> How would you implement read-char-with-history using
> read-from-minibuffer?  Rebind self-insert-command?

Exactly, by rebinding self-insert-command:

(defvar read-char-from-minibuffer-map
  (let ((map (make-sparse-keymap)))
    (set-keymap-parent map minibuffer-local-map)
    (define-key map [remap self-insert-command]
      (lambda ()
        (interactive)
        (delete-minibuffer-contents)
        (insert (event-basic-type last-command-event))
        (exit-minibuffer)))
    map))

(defun read-char-from-minibuffer (prompt)
  (read-from-minibuffer prompt nil
   read-char-from-minibuffer-map nil
  'read-char-from-minibuffer-history))

(read-char-from-minibuffer "Please type a character: ")




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Tue, 29 Oct 2019 11:33:01 GMT) Full text and rfc822 format available.

Message #39 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 10477 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Tue, 29 Oct 2019 12:32:52 +0100
Juri Linkov <juri <at> linkov.net> writes:

>>> Using read-from-minibuffer would allow this for free.
>>
>> How would you implement read-char-with-history using
>> read-from-minibuffer?  Rebind self-insert-command?
>
> Exactly, by rebinding self-insert-command:
>
> (defvar read-char-from-minibuffer-map
>   (let ((map (make-sparse-keymap)))
>     (set-keymap-parent map minibuffer-local-map)
>     (define-key map [remap self-insert-command]
>       (lambda ()
>         (interactive)
>         (delete-minibuffer-contents)
>         (insert (event-basic-type last-command-event))
>         (exit-minibuffer)))
>     map))
>
> (defun read-char-from-minibuffer (prompt)
>   (read-from-minibuffer prompt nil
>    read-char-from-minibuffer-map nil
>   'read-char-from-minibuffer-history))
>
> (read-char-from-minibuffer "Please type a character: ")

Hm, interesting.

That indeed seems a lot better than the current read-char-with-history.
(Minor tweak -- this returns a string, but should return a char.)

And this presumably works with "complicated" input methods, too?  Xim
etc.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Tue, 29 Oct 2019 23:03:02 GMT) Full text and rfc822 format available.

Message #42 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 10477 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Wed, 30 Oct 2019 00:01:57 +0100
Juri Linkov <juri <at> linkov.net> writes:

> Exactly, by rebinding self-insert-command:

OK; I've taken your code and tweaked it a bit and used it to replace
read-char-with-history.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10477; Package emacs. (Wed, 30 Oct 2019 00:02:02 GMT) Full text and rfc822 format available.

Message #45 received at 10477 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 10477 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10477: zap-to-char should allow picking from history
Date: Wed, 30 Oct 2019 02:00:34 +0200
>> Exactly, by rebinding self-insert-command:
>
> OK; I've taken your code and tweaked it a bit and used it to replace
> read-char-with-history.

I also renamed it to a better name: by analogy with read-from-minibuffer,
and to hint that it relies on, the new name is read-char-from-minibuffer.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 27 Nov 2019 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 163 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.