all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: C-r and C-s in minibuffer should search completion
Date: Tue, 25 Mar 2008 23:44:18 +0200	[thread overview]
Message-ID: <87prtiik0l.fsf@jurta.org> (raw)
In-Reply-To: <jwvy78dkya8.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 20 Mar 2008 15:13:54 -0400")

> I believe C-s and C-r in the minibuffer should not only search the
> history but the completion table as well (at least when it's not
> a function).
>
> Could someone implement this feature?

I now have an idea how to implement this feature.

Some time ago I submitted a patch that introduces a new variable
`minibuffer-default-set-function' that extends a list of defaults
when minibuffer position hits the bottom of the list of defaults.

http://lists.gnu.org/archive/html/emacs-devel/2007-12/msg00179.html

This patch was approved by Richard but not installed because
it was undecided where to move mailcap.el.

The patch uses this variable for `shell-command' to append a list of
available mailcap commands to the list of defaults only when the user
types M-n below the default value.

The same could be done for the list of completions.  The patch below
implements a new function `minibuffer-default-add-completions' that
appends a list of all completions to the end of the list of defaults.
It would be good to use this function by default since it is useful
to search the completion table in all minibuffers that have it.

Index: lisp/simple.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/simple.el,v
retrieving revision 1.911
diff -c -r1.911 simple.el
*** lisp/simple.el	23 Mar 2008 22:52:20 -0000	1.911
--- lisp/simple.el	25 Mar 2008 21:43:34 -0000
***************
*** 1304,1313 ****
--- 1305,1339 ----
  
  (defvar minibuffer-temporary-goal-position nil)
  
+ (defvar minibuffer-default-set-function 'minibuffer-default-add-completions
+   "*Function run by `goto-history-element' before using `minibuffer-default'.
+ This is useful to dynamically set the value of `minibuffer-default'
+ before `goto-history-element' reads it when moves into the future.")
+ 
+ (make-variable-buffer-local 'minibuffer-default-set-function)
+ 
+ (defun minibuffer-default-add-completions ()
+   "Return a list of all completions without the default value.
+ This function is used to add all elements of the completion table to
+ the end of the list of defaults after the default value."
+   (interactive)
+   (let ((def minibuffer-default)
+ 	(all (all-completions ""
+ 			      minibuffer-completion-table
+ 			      minibuffer-completion-predicate
+ 			      t)))
+     (if (listp def)
+ 	(append def all)
+       (setq all (cons def (delete def all))))))
+ 
  (defun goto-history-element (nabs)
    "Puts element of the minibuffer history in the minibuffer.
  The argument NABS specifies the absolute history position."
    (interactive "p")
+   (when (and (functionp minibuffer-default-set-function)
+ 	     (< nabs (if (stringp minibuffer-default) -1 0)))
+     (setq minibuffer-default (funcall minibuffer-default-set-function)
+ 	  minibuffer-default-set-function nil))
    (let ((minimum (if minibuffer-default
  		     (- (if (listp minibuffer-default)
  			    (length minibuffer-default)

-- 
Juri Linkov
http://www.jurta.org/emacs/




  parent reply	other threads:[~2008-03-25 21:44 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-20 19:13 C-r and C-s in minibuffer should search completion Stefan Monnier
2008-03-20 19:35 ` Juri Linkov
2008-03-20 20:07   ` Lennart Borgman (gmail)
2008-03-20 20:38     ` Juri Linkov
2008-03-20 20:54       ` Drew Adams
2008-03-20 23:07         ` Juri Linkov
2008-03-20 22:13   ` Stefan Monnier
2008-03-20 22:27     ` Drew Adams
2008-03-20 23:03     ` Juri Linkov
2008-03-21  1:26       ` Stefan Monnier
2008-03-22  1:17         ` Juri Linkov
2008-03-22 17:04           ` Stefan Monnier
2008-03-23  2:17             ` Juri Linkov
2008-03-23  3:24               ` Stefan Monnier
2008-03-29  1:00   ` Xavier Maillard
2008-03-29 12:30     ` Juri Linkov
2008-03-29 16:23       ` Drew Adams
2008-03-30  0:38         ` Juri Linkov
2008-03-30  2:38           ` Drew Adams
2008-03-20 20:44 ` Drew Adams
2008-03-25 21:44 ` Juri Linkov [this message]
2008-03-26  2:31   ` Stefan Monnier
2008-03-26  7:01     ` Drew Adams
2008-03-26 14:41       ` Stefan Monnier
2008-03-26 17:07         ` Drew Adams
2008-03-26 10:56     ` Juri Linkov
2008-03-26 14:47       ` Stefan Monnier
2008-03-27  0:44         ` Juri Linkov
2008-03-27  2:43           ` Stefan Monnier
2008-03-27 23:43             ` Juri Linkov
2008-03-29  4:03               ` Stefan Monnier
2008-03-30  0:44                 ` Juri Linkov
2008-03-30  4:01                   ` Stefan Monnier
2008-03-30 18:32                     ` Juri Linkov
2008-03-30 22:41                       ` Stefan Monnier
2008-03-30 23:50                         ` Juri Linkov
2008-03-31  2:11                           ` Stefan Monnier
2008-04-03 22:59                             ` Juri Linkov
2008-04-04  1:18                               ` Stefan Monnier
2008-04-06 20:45                                 ` Juri Linkov
2008-04-07 15:32                                   ` Stefan Monnier
2008-04-15 22:28                                     ` Juri Linkov
2008-04-16  2:08                                       ` Stefan Monnier
2008-04-16 23:16                                         ` Juri Linkov
2008-04-17  1:41                                           ` Stefan Monnier
2008-04-17  9:18                                             ` Juri Linkov
2008-04-18  1:07                                               ` Stefan Monnier
2008-04-19 20:11                                                 ` Juri Linkov
2008-04-19 21:10                                                   ` Stefan Monnier
2008-04-19 22:46                                                     ` Juri Linkov
2008-04-20  2:44                                                       ` Stefan Monnier
2008-04-21 21:51                                                         ` Juri Linkov
2008-04-22  3:11                                                           ` Stefan Monnier
2008-04-22 20:59                                                             ` Juri Linkov
2008-04-23  2:28                                                               ` Stefan Monnier
2008-04-21  3:07                                                       ` Richard Stallman
2008-04-21 22:54                                                         ` Juri Linkov
2008-04-22  3:10                                                           ` Stefan Monnier
2008-03-30  0:44                 ` minibuffer-default-add-shell-commands (was: C-r and C-s in minibuffer should search completion) Juri Linkov
2008-03-30  4:08                   ` minibuffer-default-add-shell-commands Stefan Monnier
2008-03-30 18:28                     ` minibuffer-default-add-shell-commands Juri Linkov
2008-03-30 11:30                   ` minibuffer-default-add-shell-commands Reiner Steib
2008-03-30 18:31                     ` minibuffer-default-add-shell-commands Juri Linkov
2008-03-30 20:25                       ` minibuffer-default-add-shell-commands Reiner Steib

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87prtiik0l.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.