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

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Jakub Jankiewicz
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 (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Juri Linkov
> 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.



Reply | Threaded
Open this post in threaded view
|

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

Jakub Jankiewicz
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 <[hidden email]> 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 (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Stefan Kangas
In reply to this post by Juri Linkov
Juri Linkov <[hidden email]> 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



Reply | Threaded
Open this post in threaded view
|

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

Lars Ingebrigtsen
Stefan Kangas <[hidden email]> 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



Reply | Threaded
Open this post in threaded view
|

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

Juri Linkov
>> 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.



Reply | Threaded
Open this post in threaded view
|

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

Drew Adams
> 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'.



Reply | Threaded
Open this post in threaded view
|

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

Stefan Kangas
In reply to this post by Juri Linkov
Juri Linkov <[hidden email]> 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



Reply | Threaded
Open this post in threaded view
|

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

Juri Linkov
>> 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?



Reply | Threaded
Open this post in threaded view
|

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

Juri Linkov
>> 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?