From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: C-r and C-s in minibuffer should search completion Date: Thu, 27 Mar 2008 02:44:08 +0200 Organization: JURTA Message-ID: <87od9181m7.fsf@jurta.org> References: <87prtiik0l.fsf@jurta.org> <87iqz969fh.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206581006 4659 80.91.229.12 (27 Mar 2008 01:23:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Mar 2008 01:23:26 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 27 02:23:57 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JegqR-0002HN-Vb for ged-emacs-devel@m.gmane.org; Thu, 27 Mar 2008 02:23:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jegpl-000729-9r for ged-emacs-devel@m.gmane.org; Wed, 26 Mar 2008 21:23:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jegph-000724-Hp for emacs-devel@gnu.org; Wed, 26 Mar 2008 21:23:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jegpg-00071s-0N for emacs-devel@gnu.org; Wed, 26 Mar 2008 21:23:08 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jegpf-00071p-Ro for emacs-devel@gnu.org; Wed, 26 Mar 2008 21:23:07 -0400 Original-Received: from relay02.kiev.sovam.com ([62.64.120.197]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jegpg-0007WG-0H for emacs-devel@gnu.org; Wed, 26 Mar 2008 21:23:08 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay02.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1JegpZ-0009yk-Kf; Thu, 27 Mar 2008 03:23:03 +0200 In-Reply-To: (Stefan Monnier's message of "Wed, 26 Mar 2008 10:47:12 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: eb35aeac2b84d7677a861f668fbe3b20 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 2502 [Mar 26 2008] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 10 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:93594 Archived-At: > There seem to be some typo or something missing from your sentence, but > IIUC you have implemented what I suggested so that M-n only computes the > completion table after having consumed the normal defaults? Can you > send the new code? Yep, this was already implemented in my previous patch. If there exist a default value, then the first M-n just inserts this default value to the minibuffer without any computation, and only next M-n (that would otherwise signal an error) computes the completion table. Below is a new patch with a small improvement: it introduces a new variable `minibuffer-default-add-p' useful to add more elements to the list of defaults several times in chunks when needed (it can keep the current state of added elements to the list of defaults): Index: lisp/simple.el =================================================================== RCS file: /sources/emacs/emacs/lisp/simple.el,v retrieving revision 1.912 diff -c -r1.912 simple.el *** lisp/simple.el 26 Mar 2008 03:40:40 -0000 1.912 --- lisp/simple.el 27 Mar 2008 00:42:03 -0000 *************** *** 1304,1313 **** --- 1305,1352 ---- (defvar minibuffer-temporary-goal-position nil) + (defvar minibuffer-default-add-function 'minibuffer-default-add-completions + "Function run by `goto-history-element' before consuming `minibuffer-default'. + This is useful to dynamically set the value of `minibuffer-default' + before `goto-history-element' reads it when it moves into the future.") + + (make-variable-buffer-local 'minibuffer-default-add-function) + + (defvar minibuffer-default-add-p t + "When non-nil, add more elements to the end of the list of default values. + Any non-nil value causes `goto-history-element' to add more elements + to a list of defaults by calling a function defined by + `minibuffer-default-add-function'. When this function + doesn't need to add more elements after its call, it should + set this variable to nil.") + + (make-variable-buffer-local 'minibuffer-default-add-p) + + (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))) + (setq minibuffer-default-add-p nil) + (if (listp def) + (append def 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 minibuffer-default-add-p + (functionp minibuffer-default-add-function) + (< nabs (- (if (listp minibuffer-default) + (length minibuffer-default) + 1)))) + (setq minibuffer-default (funcall minibuffer-default-add-function))) (let ((minimum (if minibuffer-default (- (if (listp minibuffer-default) (length minibuffer-default) -- Juri Linkov http://www.jurta.org/emacs/