GNU bug report logs - #12490
24.2; Search inside Minibuffer don't work with M-x (M-x C-s)

Previous Next

Package: emacs;

Reported by: Jakub Jankiewicz <jcubic <at> onet.pl>

Date: Sat, 22 Sep 2012 20:53:02 UTC

Severity: normal

Tags: confirmed, fixed, patch

Found in version 24.2

Fixed in version 28.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 12490 in the body.
You can then email your comments to 12490 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#12490; Package emacs. (Sat, 22 Sep 2012 20:53:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jakub Jankiewicz <jcubic <at> onet.pl>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 22 Sep 2012 20:53:03 GMT) Full text and rfc822 format available.

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

From: Jakub Jankiewicz <jcubic <at> onet.pl>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2; Search inside Minibuffer don't work with M-x (M-x C-s)
Date: Sat, 22 Sep 2012 22:42:29 +0200
[Message part 1 (text/plain, inline)]
Hi,

I want to report, that most used function stop working in Emacs 24
(tested 2 versions 24.1.1 and latest 24.2.1). I use Search in
Mini buffer a lot (don't know if people use it or not). If you call
search C-s when inside minibuffer like C-h f C-s you can search the
content of Minibuffer like search for functions or for buffer name to
switch like C-x b C-s (better then ido mode). And in Emacs 24 M-x C-s
stop working so I you can't search for interactive function to execute
anymore. It was working in 23.3 provided by Ubuntu (package
23.3+1-1ubuntu4).

Exact symptoms:
$ emacs -Q
M-x C-s
Typing any character show "Failing I-search"

I used 24.1.1 but just compile latest GNU Emacs 24.2.1
(i686-pc-linux-gnu, GTK+ Version 2.24.6) and got the same result.

Jakub

--
Jakub Jankiewicz, Web Developer
http://jcubic.pl
[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12490; Package emacs. (Sat, 22 Sep 2012 23:26:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> jurta.org>
To: Jakub Jankiewicz <jcubic <at> onet.pl>
Cc: 12490 <at> debbugs.gnu.org
Subject: Re: bug#12490: 24.2;
	Search inside Minibuffer don't work with M-x (M-x C-s)
Date: Sun, 23 Sep 2012 02:21:39 +0300
> I want to report, that most used function stop working in Emacs 24
> (tested 2 versions 24.1.1 and latest 24.2.1). I use Search in
> Mini buffer a lot (don't know if people use it or not). If you call
> search C-s when inside minibuffer like C-h f C-s you can search the
> content of Minibuffer like search for functions or for buffer name to
> switch like C-x b C-s (better then ido mode). And in Emacs 24 M-x C-s
> stop working so I you can't search for interactive function to execute
> anymore. It was working in 23.3 provided by Ubuntu (package
> 23.3+1-1ubuntu4).

Sorry, this feature has been removed by http://debbugs.gnu.org/5214
and http://debbugs.gnu.org/5364

But it's easy to restore it with a simple patch that prepends the
current default value (a command at point) to the sorted list of
all available command names:

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2012-09-22 20:53:16 +0000
+++ lisp/simple.el	2012-09-22 23:20:41 +0000
@@ -1352,9 +1352,15 @@ (defun read-extended-command ()
 	     (lambda ()
 	       ;; Get a command name at point in the original buffer
 	       ;; to propose it after M-n.
-	       (with-current-buffer (window-buffer (minibuffer-selected-window))
-		 (and (commandp (function-called-at-point))
-		      (format "%S" (function-called-at-point)))))))
+	       (let ((def (with-current-buffer
+			      (window-buffer (minibuffer-selected-window))
+			    (and (commandp (function-called-at-point))
+				 (format "%S" (function-called-at-point)))))
+		     (all (sort (minibuffer-default-add-completions)
+				(lambda (a b) (string< a b)))))
+		 (if def
+		     (cons def (delete def all))
+		   all)))))
     ;; Read a string, completing from and restricting to the set of
     ;; all defined commands.  Don't provide any initial input.
     ;; Save the command read on the extended-command history list.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12490; Package emacs. (Sun, 23 Sep 2012 09:30:02 GMT) Full text and rfc822 format available.

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

From: Jakub Jankiewicz <jcubic <at> onet.pl>
To: Juri Linkov <juri <at> jurta.org>
Cc: 12490 <at> debbugs.gnu.org
Subject: Re: bug#12490: 24.2; Search inside Minibuffer don't work with M-x
	(M-x C-s)
Date: Sun, 23 Sep 2012 11:27:13 +0200
[Message part 1 (text/plain, inline)]
Awesome thanks, it work. I didn't want to modify the file so I put whole
function to my .emacs file.

On Sun, 23 Sep 2012 02:21:39 +0300
Juri Linkov <juri <at> jurta.org> wrote:

> > I want to report, that most used function stop working in Emacs 24
> > (tested 2 versions 24.1.1 and latest 24.2.1). I use Search in
> > Mini buffer a lot (don't know if people use it or not). If you call
> > search C-s when inside minibuffer like C-h f C-s you can search the
> > content of Minibuffer like search for functions or for buffer name
> > to switch like C-x b C-s (better then ido mode). And in Emacs 24
> > M-x C-s stop working so I you can't search for interactive function
> > to execute anymore. It was working in 23.3 provided by Ubuntu
> > (package 23.3+1-1ubuntu4).
> 
> Sorry, this feature has been removed by http://debbugs.gnu.org/5214
> and http://debbugs.gnu.org/5364
> 
> But it's easy to restore it with a simple patch that prepends the
> current default value (a command at point) to the sorted list of
> all available command names:
> 
> === modified file 'lisp/simple.el'
> --- lisp/simple.el	2012-09-22 20:53:16 +0000
> +++ lisp/simple.el	2012-09-22 23:20:41 +0000
> @@ -1352,9 +1352,15 @@ (defun read-extended-command ()
>  	     (lambda ()
>  	       ;; Get a command name at point in the original buffer
>  	       ;; to propose it after M-n.
> -	       (with-current-buffer (window-buffer
> (minibuffer-selected-window))
> -		 (and (commandp (function-called-at-point))
> -		      (format "%S" (function-called-at-point)))))))
> +	       (let ((def (with-current-buffer
> +			      (window-buffer
> (minibuffer-selected-window))
> +			    (and (commandp
> (function-called-at-point))
> +				 (format
> "%S" (function-called-at-point)))))
> +		     (all (sort (minibuffer-default-add-completions)
> +				(lambda (a b) (string< a b)))))
> +		 (if def
> +		     (cons def (delete def all))
> +		   all)))))
>      ;; Read a string, completing from and restricting to the set of
>      ;; all defined commands.  Don't provide any initial input.
>      ;; Save the command read on the extended-command history list.

--
Jakub Jankiewicz, Web Developer
http://jcubic.pl
[signature.asc (application/pgp-signature, attachment)]

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

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Juri Linkov <juri <at> jurta.org>
Cc: Jakub Jankiewicz <jcubic <at> onet.pl>, 12490 <at> debbugs.gnu.org
Subject: Re: bug#12490: 24.2;
 Search inside Minibuffer don't work with M-x (M-x C-s)
Date: Wed, 30 Oct 2019 23:25:07 +0100
Juri Linkov <juri <at> jurta.org> writes:

>> I want to report, that most used function stop working in Emacs 24
>> (tested 2 versions 24.1.1 and latest 24.2.1). I use Search in
>> Mini buffer a lot (don't know if people use it or not). If you call
>> search C-s when inside minibuffer like C-h f C-s you can search the
>> content of Minibuffer like search for functions or for buffer name to
>> switch like C-x b C-s (better then ido mode). And in Emacs 24 M-x C-s
>> stop working so I you can't search for interactive function to execute
>> anymore. It was working in 23.3 provided by Ubuntu (package
>> 23.3+1-1ubuntu4).
>
> Sorry, this feature has been removed by http://debbugs.gnu.org/5214
> and http://debbugs.gnu.org/5364
>
> But it's easy to restore it with a simple patch that prepends the
> current default value (a command at point) to the sorted list of
> all available command names:
>
> === modified file 'lisp/simple.el'
> --- lisp/simple.el	2012-09-22 20:53:16 +0000
> +++ lisp/simple.el	2012-09-22 23:20:41 +0000
> @@ -1352,9 +1352,15 @@ (defun read-extended-command ()
>  	     (lambda ()
>  	       ;; Get a command name at point in the original buffer
>  	       ;; to propose it after M-n.
> -	       (with-current-buffer (window-buffer (minibuffer-selected-window))
> -		 (and (commandp (function-called-at-point))
> -		      (format "%S" (function-called-at-point)))))))
> +	       (let ((def (with-current-buffer
> +			      (window-buffer (minibuffer-selected-window))
> +			    (and (commandp (function-called-at-point))
> +				 (format "%S" (function-called-at-point)))))
> +		     (all (sort (minibuffer-default-add-completions)
> +				(lambda (a b) (string< a b)))))
> +		 (if def
> +		     (cons def (delete def all))
> +		   all)))))
>      ;; Read a string, completing from and restricting to the set of
>      ;; all defined commands.  Don't provide any initial input.
>      ;; Save the command read on the extended-command history list.

I tested this patch.  It works, and the behaviour seems better than
what we have now.

Should it perhaps be installed?

Best regards,
Stefan Kangas




Added tag(s) patch. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Wed, 30 Oct 2019 22:39:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12490; Package emacs. (Sat, 23 Nov 2019 14:42:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Juri Linkov <juri <at> jurta.org>, Jakub Jankiewicz <jcubic <at> onet.pl>,
 12490 <at> debbugs.gnu.org
Subject: Re: bug#12490: 24.2; Search inside Minibuffer don't work with M-x
 (M-x C-s)
Date: Sat, 23 Nov 2019 15:41:12 +0100
Stefan Kangas <stefan <at> marxist.se> writes:

> I tested this patch.  It works, and the behaviour seems better than
> what we have now.
>
> Should it perhaps be installed?

I haven't tested the patch, but if it works like I imagine (i.e., it
allows searching in the M-x history), then that sounds very nice.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12490; Package emacs. (Sat, 30 Nov 2019 21:48:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> jurta.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Jakub Jankiewicz <jcubic <at> onet.pl>, 12490 <at> debbugs.gnu.org,
 Stefan Kangas <stefan <at> marxist.se>
Subject: Re: bug#12490: 24.2; Search inside Minibuffer don't work with M-x
 (M-x C-s)
Date: Sat, 30 Nov 2019 23:43:28 +0200
>> I tested this patch.  It works, and the behaviour seems better than
>> what we have now.
>>
>> Should it perhaps be installed?
>
> I haven't tested the patch, but if it works like I imagine (i.e., it
> allows searching in the M-x history), then that sounds very nice.

Actually, searching in the M-x history is already implemented.

This patch allows searching thru all commands available via M-x,
i.e. it's like using isearch in the *Completions* buffer like

  M-x TAB <PgUp> C-s command

with without opening the *Completions* buffer, with just

  M-x C-s command

to search commands available with M-x M-n M-n M-n ...

The problem why this patch is not installed is the need to decide
in what order to sort these commands.  The patch sorts alphabetically,
but maybe better to sort by command usage frequency, or somesuch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12490; Package emacs. (Sat, 30 Nov 2019 23:42:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Juri Linkov <juri <at> jurta.org>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Jakub Jankiewicz <jcubic <at> onet.pl>, 12490 <at> debbugs.gnu.org,
 Stefan Kangas <stefan <at> marxist.se>
Subject: RE: bug#12490: 24.2; Search inside Minibuffer don't work with M-x
 (M-x C-s)
Date: Sat, 30 Nov 2019 15:41:38 -0800 (PST)
> This patch allows searching thru all commands available via M-x,

That's not "searching" - certainly not isearching.

> i.e. it's like using isearch in the *Completions* buffer like
>   M-x TAB <PgUp> C-s command

That _is_ isearching (in buffer *Completions*).

> with without opening the *Completions* buffer, with just
>   M-x C-s command
> to search commands available with M-x M-n M-n M-n ...

It's not searching.  We use a different key, such
as `M-s' or `M-r', to insert a matching history
element.  `M-s' is `next-matching history-element'.
It has nothing in common with Isearch.

IMHO, we should never bind `C-s' in the minibuffer
to anything.  Why?  Because the minibuffer is a
buffer where text editing and cursor movment are
allowed/encouraged/normal.  We shouldn't remove
the ability to use Isearch there (using the global
`C-s' binding).

`C-s' in the minibuffer should, as it has before
(prior to Emacs 23, it seems), provide Isearch on
the minibuffer contents, just like it does in other
buffers.

I see now that someone changed this in Emacs 23,
at least for `read-buffer', to make `C-s' do what
has been described in this thread.  IMHO, that was
a step backward, not forward.  (I didn't notice it
because I have my own `read-buffer' code.)

It's fine to have other keys to find and retrieve
past inputs, completion candidates, defaults, etc.
That's something we've always done (`M-s', `M-n',
etc.).

Co-opting `C-s' to do that kind of thing was (and
is) misguided, IMO.  Spreading it from `C-x b' to
`M-x' will be yet another step backward.

My FWIW vote is to remove any default bindings of
`C-s' in the minibuffer, to let it do its useful
job there of `isearch-forward'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12490; Package emacs. (Sun, 01 Dec 2019 07:38:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Juri Linkov <juri <at> jurta.org>
Cc: Jakub Jankiewicz <jcubic <at> onet.pl>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 12490 <at> debbugs.gnu.org
Subject: Re: bug#12490: 24.2; Search inside Minibuffer don't work with M-x
 (M-x C-s)
Date: Sun, 1 Dec 2019 08:36:59 +0100
Juri Linkov <juri <at> jurta.org> writes:

> The problem why this patch is not installed is the need to decide
> in what order to sort these commands.  The patch sorts alphabetically,
> but maybe better to sort by command usage frequency, or somesuch.

One possibility would be to install it and improve the ordering later.

BTW, do we have a mechanism for sorting by command frequency?

Best regards,
Stefan Kangas




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

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

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Jakub Jankiewicz <jcubic <at> onet.pl>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 12490 <at> debbugs.gnu.org
Subject: Re: bug#12490: 24.2; Search inside Minibuffer don't work with M-x
 (M-x C-s)
Date: Mon, 02 Dec 2019 00:38:22 +0200
>> The problem why this patch is not installed is the need to decide
>> in what order to sort these commands.  The patch sorts alphabetically,
>> but maybe better to sort by command usage frequency, or somesuch.
>
> One possibility would be to install it and improve the ordering later.

I agree.

> BTW, do we have a mechanism for sorting by command frequency?

One possibility is to use the minibuffer history to sort by the number
of occurrences of each history element, but this method doesn't work
when history-delete-duplicates is customized to non-nil, so there are
no duplicates in the history.

Although I noticed that icomplete.el often proposes the most
relevant elements first, but I never investigated how it does this,
maybe by frequency?




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

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

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Jakub Jankiewicz <jcubic <at> onet.pl>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 12490 <at> debbugs.gnu.org
Subject: Re: bug#12490: 24.2; Search inside Minibuffer don't work with M-x
 (M-x C-s)
Date: Tue, 03 Dec 2019 00:51:30 +0200
>> BTW, do we have a mechanism for sorting by command frequency?
>
> One possibility is to use the minibuffer history to sort by the number
> of occurrences of each history element, but this method doesn't work
> when history-delete-duplicates is customized to non-nil, so there are
> no duplicates in the history.
>
> Although I noticed that icomplete.el often proposes the most
> relevant elements first, but I never investigated how it does this,
> maybe by frequency?

Another place worth looking at https://github.com/nonsequitur/smex
It seems using ido to sort commands by frequency?




Added tag(s) confirmed. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Mon, 20 Jan 2020 22:47:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12490; Package emacs. (Wed, 19 Aug 2020 13:54:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> jurta.org>
Cc: Jakub Jankiewicz <jcubic <at> onet.pl>, 12490 <at> debbugs.gnu.org,
 Stefan Kangas <stefan <at> marxist.se>
Subject: Re: bug#12490: 24.2; Search inside Minibuffer don't work with M-x
 (M-x C-s)
Date: Wed, 19 Aug 2020 15:52:55 +0200
Juri Linkov <juri <at> jurta.org> writes:

>> One possibility would be to install it and improve the ordering later.
>
> I agree.

It seems that everybody here agreed that this was a good patch (even if
some tweaking might be nice), so I've applied it to Emacs 28.

-- 
(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. (Wed, 19 Aug 2020 13:54:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 12490 <at> debbugs.gnu.org and Jakub Jankiewicz <jcubic <at> onet.pl> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 19 Aug 2020 13:54:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 17 Sep 2020 11:24:07 GMT) Full text and rfc822 format available.

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

Previous Next


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