unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g'))
@ 2012-10-02 15:42 Dani Moncayo
  2012-10-02 16:22 ` Drew Adams
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Dani Moncayo @ 2012-10-02 15:42 UTC (permalink / raw)
  To: Drew Adams; +Cc: Nix, Stefan Monnier, emacs-devel

>> Quite. Perhaps I'm just an idiot, but I always thought the current
>> isearch behaviour of not immediately quitting when C-g was stuck on a
>> failed search was a *bug*.
>
> That is something very different from what this thread is about (and not a bug,
> IMO).  The C-g behavior in Emacs incremental search is somewhat complex (depends
> on the search state), and fine as is (IMO).

IIUC, the behavior of C-g from Isearch is not that complex.  As
documented in (info "(emacs)Error in Isearch"), `C-g' from Isearch
does this:
* If the current search is successful, `C-g' cancels the Isearch.
* Else, `C-g' restores the last succesful search string.

And I, like Nix, don't like the second case.  I would like C-g to
_always_ cancel the Isearch.

So IMO this behavior should be configurable.

-- 
Dani Moncayo



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

* RE: C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g'))
  2012-10-02 15:42 C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Dani Moncayo
@ 2012-10-02 16:22 ` Drew Adams
  2012-10-02 17:05   ` Dani Moncayo
  2012-10-02 17:06 ` C-g from Isearch Stefan Monnier
  2012-10-03  5:08 ` C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Stephen J. Turnbull
  2 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2012-10-02 16:22 UTC (permalink / raw)
  To: 'Dani Moncayo'
  Cc: 'Nix', 'Stefan Monnier', emacs-devel

> > `C-g' from Isearch does this:
> * If the current search is successful, `C-g' cancels the Isearch.
> * Else, `C-g' restores the last succesful search string.
> 
> And I, like Nix, don't like the second case.  I would like C-g to
> _always_ cancel the Isearch.  So IMO this behavior should be
> configurable.

It already is.  Just do this:

(define-key isearch-mode-map 'isearch-cancel)

And you also already have a key binding for this: `ESC ESC ESC'. 




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

* Re: C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g'))
  2012-10-02 16:22 ` Drew Adams
@ 2012-10-02 17:05   ` Dani Moncayo
  0 siblings, 0 replies; 12+ messages in thread
From: Dani Moncayo @ 2012-10-02 17:05 UTC (permalink / raw)
  To: Drew Adams; +Cc: Nix, Stefan Monnier, emacs-devel

On Tue, Oct 2, 2012 at 6:22 PM, Drew Adams <drew.adams@oracle.com> wrote:
>> > `C-g' from Isearch does this:
>> * If the current search is successful, `C-g' cancels the Isearch.
>> * Else, `C-g' restores the last succesful search string.
>>
>> And I, like Nix, don't like the second case.  I would like C-g to
>> _always_ cancel the Isearch.  So IMO this behavior should be
>> configurable.
>
> It already is.  Just do this:
>
> (define-key isearch-mode-map 'isearch-cancel)

Right.  I'll add that (well, adding the missing "C-g") to my init file.  Thanks.

>
> And you also already have a key binding for this: `ESC ESC ESC'.
>

I don't want to use another binding.  I just want C-g to
unconditionally exit Isearch.

-- 
Dani Moncayo



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

* Re: C-g from Isearch
  2012-10-02 15:42 C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Dani Moncayo
  2012-10-02 16:22 ` Drew Adams
@ 2012-10-02 17:06 ` Stefan Monnier
  2012-10-02 17:08   ` Nix
  2012-10-02 17:18   ` Drew Adams
  2012-10-03  5:08 ` C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Stephen J. Turnbull
  2 siblings, 2 replies; 12+ messages in thread
From: Stefan Monnier @ 2012-10-02 17:06 UTC (permalink / raw)
  To: Dani Moncayo; +Cc: Nix, Drew Adams, emacs-devel

> And I, like Nix, don't like the second case.  I would like C-g to
> _always_ cancel the Isearch.
> So IMO this behavior should be configurable.

I don't think the difference is terribly important, but a configuration
option for that is acceptable.


        Stefan



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

* Re: C-g from Isearch
  2012-10-02 17:06 ` C-g from Isearch Stefan Monnier
@ 2012-10-02 17:08   ` Nix
  2012-10-02 17:18   ` Drew Adams
  1 sibling, 0 replies; 12+ messages in thread
From: Nix @ 2012-10-02 17:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Drew Adams, Dani Moncayo

On 2 Oct 2012, Stefan Monnier said:

>> And I, like Nix, don't like the second case.  I would like C-g to
>> _always_ cancel the Isearch.
>> So IMO this behavior should be configurable.
>
> I don't think the difference is terribly important, but a configuration
> option for that is acceptable.

Neither do I. Like I said, it is initially confusing and prone to seem
like a bug, but is both documented and a useful behaviour for which no
other keybinding is particularly obviously appropriate.

-- 
NULL && (void)



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

* RE: C-g from Isearch
  2012-10-02 17:06 ` C-g from Isearch Stefan Monnier
  2012-10-02 17:08   ` Nix
@ 2012-10-02 17:18   ` Drew Adams
  2012-10-03  1:33     ` Stefan Monnier
  1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2012-10-02 17:18 UTC (permalink / raw)
  To: 'Stefan Monnier', 'Dani Moncayo'
  Cc: 'Nix', emacs-devel

> > And I, like Nix, don't like the second case.  I would like
> > C-g to _always_ cancel the Isearch.  So IMO this behavior
> > should be configurable.
> 
> I don't think the difference is terribly important, but a 
> configuration option for that is acceptable.

Coming from someone who often resists adding yet another user option, this is a
bit surprising to me.  IMHO, this is a case where your more usual stance wrt new
options (YAGNI) would be appropriate.

It is trivial for a user to bind C-g to `isearch-cancel'.
(And that command already has another simple binding.)

I would, however, support documenting this in the manual, where we discuss the
out-of-the-box behavior of C-g.  Just mention that ESC ESC ESC (command
`isearch-cancel') always cancels isearch (and you can bind it to another key if
you want).




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

* Re: C-g from Isearch
  2012-10-02 17:18   ` Drew Adams
@ 2012-10-03  1:33     ` Stefan Monnier
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2012-10-03  1:33 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Nix', emacs-devel, 'Dani Moncayo'

> It is trivial for a user to bind C-g to `isearch-cancel'.

Indeed, I had not noticed it, thank you.  Then a config var is
indeed superfluous.


        Stefan



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

* C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g'))
  2012-10-02 15:42 C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Dani Moncayo
  2012-10-02 16:22 ` Drew Adams
  2012-10-02 17:06 ` C-g from Isearch Stefan Monnier
@ 2012-10-03  5:08 ` Stephen J. Turnbull
  2012-10-03  6:37   ` Dani Moncayo
  2012-10-03 15:19   ` C-g from Isearch Jason Rumney
  2 siblings, 2 replies; 12+ messages in thread
From: Stephen J. Turnbull @ 2012-10-03  5:08 UTC (permalink / raw)
  To: Dani Moncayo; +Cc: Nix, Stefan Monnier, Drew Adams, emacs-devel

Dani Moncayo writes:

 > documented in (info "(emacs)Error in Isearch"), `C-g' from Isearch
 > does this:
 > * If the current search is successful, `C-g' cancels the Isearch.
 > * Else, `C-g' restores the last succesful search string.

In XEmacs, this is useless duplication.  Deleting the character has
the same effect some rather large fraction of the time, as it's
unusual that multiple not found characters are typed.

 > And I, like Nix, don't like the second case.  I would like C-g to
 > _always_ cancel the Isearch.
 > 
 > So IMO this behavior should be configurable.

I'm tempted to just change XEmacs's behavior to "always cancel" and
see how many cries of outrage can be induced.




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

* Re: C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g'))
  2012-10-03  5:08 ` C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Stephen J. Turnbull
@ 2012-10-03  6:37   ` Dani Moncayo
  2012-10-03 15:19   ` C-g from Isearch Jason Rumney
  1 sibling, 0 replies; 12+ messages in thread
From: Dani Moncayo @ 2012-10-03  6:37 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: Nix, Stefan Monnier, Drew Adams, emacs-devel

>  > documented in (info "(emacs)Error in Isearch"), `C-g' from Isearch
>  > does this:
>  > * If the current search is successful, `C-g' cancels the Isearch.
>  > * Else, `C-g' restores the last succesful search string.
>
> In XEmacs, this is useless duplication.  Deleting the character has
> the same effect some rather large fraction of the time, as it's
> unusual that multiple not found characters are typed.

AFAIK, this is true also for GNU Emacs.  Typing <backspace> in Isearch
restores the previous Isearch state.  So I agree with you: `C-g'
duplicates this feature (almost - `C-g' restores the last successful
state) at the expense of annoying those user who expect this command
to its usual job (cancel the current command).

>  > And I, like Nix, don't like the second case.  I would like C-g to
>  > _always_ cancel the Isearch.
>  >
>  > So IMO this behavior should be configurable.
>
> I'm tempted to just change XEmacs's behavior to "always cancel" and
> see how many cries of outrage can be induced.

I've done that in my init file:
  (define-key isearch-mode-map [?\C-g] 'isearch-cancel)


--
Dani Moncayo



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

* Re: C-g from Isearch
  2012-10-03  5:08 ` C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Stephen J. Turnbull
  2012-10-03  6:37   ` Dani Moncayo
@ 2012-10-03 15:19   ` Jason Rumney
  2012-10-03 15:45     ` Dani Moncayo
  1 sibling, 1 reply; 12+ messages in thread
From: Jason Rumney @ 2012-10-03 15:19 UTC (permalink / raw)
  To: Stephen J. Turnbull
  Cc: Nix, emacs-devel, Stefan Monnier, Drew Adams, Dani Moncayo

"Stephen J. Turnbull" <stephen@xemacs.org> writes:

> In XEmacs, this is useless duplication.  Deleting the character has
> the same effect some rather large fraction of the time, as it's
> unusual that multiple not found characters are typed.

Fast typing, and yank are two ways this can happen quite easily.  That
said, I never knew about this behaviour of C-g in isearch before, and
never would have expected it.  I usually end my isearch with RET, but if
I did try C-g I would be surprised to see it working like undo rather
than quit. 




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

* Re: C-g from Isearch
  2012-10-03 15:19   ` C-g from Isearch Jason Rumney
@ 2012-10-03 15:45     ` Dani Moncayo
  2012-10-03 16:44       ` Jason Rumney
  0 siblings, 1 reply; 12+ messages in thread
From: Dani Moncayo @ 2012-10-03 15:45 UTC (permalink / raw)
  To: Jason Rumney
  Cc: Nix, Stephen J. Turnbull, Stefan Monnier, Drew Adams, emacs-devel

>> In XEmacs, this is useless duplication.  Deleting the character has
>> the same effect some rather large fraction of the time, as it's
>> unusual that multiple not found characters are typed.
>
> Fast typing, and yank are two ways this can happen quite easily.

Yank doesn't count here, since the whole yanked string will be removed
from the search string with a single <backspace> keystroke.

> That
> said, I never knew about this behaviour of C-g in isearch before, and
> never would have expected it.  I usually end my isearch with RET, but if
> I did try C-g I would be surprised to see it working like undo rather
> than quit.

I agree, but that is the current behavior in Emacs.  At least, you can
fix this with
  (define-key isearch-mode-map [?\C-g] 'isearch-cancel)

-- 
Dani Moncayo



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

* Re: C-g from Isearch
  2012-10-03 15:45     ` Dani Moncayo
@ 2012-10-03 16:44       ` Jason Rumney
  0 siblings, 0 replies; 12+ messages in thread
From: Jason Rumney @ 2012-10-03 16:44 UTC (permalink / raw)
  To: Dani Moncayo
  Cc: Nix, Stephen J. Turnbull, Stefan Monnier, Drew Adams, emacs-devel

Dani Moncayo <dmoncayo@gmail.com> writes:

> Yank doesn't count here, since the whole yanked string will be removed
> from the search string with a single <backspace> keystroke.

More surprising behaviour I never knew about.  Inconsistencies like
this, and the old C-y behaviour, which thankfully got fixed in 24.1,
are probably why I never use the more advanced isearch features.




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

end of thread, other threads:[~2012-10-03 16:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-02 15:42 C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Dani Moncayo
2012-10-02 16:22 ` Drew Adams
2012-10-02 17:05   ` Dani Moncayo
2012-10-02 17:06 ` C-g from Isearch Stefan Monnier
2012-10-02 17:08   ` Nix
2012-10-02 17:18   ` Drew Adams
2012-10-03  1:33     ` Stefan Monnier
2012-10-03  5:08 ` C-g from Isearch (was: Isearch: retrieve last successful search string from when you quit (`C-g')) Stephen J. Turnbull
2012-10-03  6:37   ` Dani Moncayo
2012-10-03 15:19   ` C-g from Isearch Jason Rumney
2012-10-03 15:45     ` Dani Moncayo
2012-10-03 16:44       ` Jason Rumney

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).