From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.devel Subject: Re: Any objection to adding completing-read-function? Date: Wed, 29 Dec 2010 08:16:38 +0000 Message-ID: References: <09A3268D77B2468CA279813722859771@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1293610616 10476 80.91.229.12 (29 Dec 2010 08:16:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 29 Dec 2010 08:16:56 +0000 (UTC) Cc: Drew Adams , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 29 09:16:52 2010 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.69) (envelope-from ) id 1PXrDH-0004At-I1 for ged-emacs-devel@m.gmane.org; Wed, 29 Dec 2010 09:16:51 +0100 Original-Received: from localhost ([127.0.0.1]:47187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PXrDG-0001GI-LS for ged-emacs-devel@m.gmane.org; Wed, 29 Dec 2010 03:16:50 -0500 Original-Received: from [140.186.70.92] (port=50544 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PXrDA-0001Fo-5x for emacs-devel@gnu.org; Wed, 29 Dec 2010 03:16:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PXrD7-0000CE-8V for emacs-devel@gnu.org; Wed, 29 Dec 2010 03:16:44 -0500 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:57615) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PXrD7-0000Br-2U for emacs-devel@gnu.org; Wed, 29 Dec 2010 03:16:41 -0500 Original-Received: by wyj26 with SMTP id 26so10268692wyj.0 for ; Wed, 29 Dec 2010 00:16:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=Umdqyjky6nDDvkHN+kEI8LjjHQ6+E8DaRm858VY5ffs=; b=YH+RwguG0yUjc431W86JGLEOn/0TRUElGJv4fqhf9WlLEJk/E5zMknndtAEtvu9OM8 PUQCK+R4RhVuc50+RFAlm+22fqg04OYc+ivJ6YqGMwVmF7jDSomUpH3O5CbmKe2NafDJ z3o7tHOEkjZLr2DvwtyPv93FMNcE5brrZHOjE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=Px9le0I3JBX7Z20Gr3Bvo9WoLVAEXdDoRWiybFfXYdDGrMJ7CmC/PWZzR6/AQgXeee UO2VVLwBVeEfmscfCcuG0iELiiG/iELEX30Jnph+kz3SSbmrduNoxSN9xu86xAYADE4i aURgVyTLZPO+HhHCVbzheRpl5jffSdG/tHu/I= Original-Received: by 10.227.128.203 with SMTP id l11mr8415939wbs.104.1293610600306; Wed, 29 Dec 2010 00:16:40 -0800 (PST) Original-Received: from Victoria.local (cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com [86.9.122.85]) by mx.google.com with ESMTPS id f35sm9898338wbf.14.2010.12.29.00.16.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 29 Dec 2010 00:16:39 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Tue, 28 Dec 2010 21:51:09 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.91 (Mac OS X 10.6.5) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:134025 Archived-At: On 2010-12-29 02:51 +0000, Stefan Monnier wrote: >> Is the following patch (against 24, not touching ido.el yet) something >> people have in mind? - Leo > > I think so, tho it's hard to tell since the diff shows a big removal and > a big addition: if you place read-file-name-default after > read-file-name, then the diff will be more readable, I think. > > > Stefan I thought C-c C-w in diff ignore all spaces but it turned out only for a hunk. Here is the diff again: diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 8d09d5d..4b006c7 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1474,8 +1474,9 @@ 'completion--file-name-table) "Internal subroutine for `read-file-name'. Do not call this.") -(defvar read-file-name-function nil - "If this is non-nil, `read-file-name' does its work by calling this function.") +(defvar read-file-name-function 'read-file-name-default + "The function called by `read-file-name' to do its work. +It should accept the same arguments as `read-file-name'.") (defcustom read-file-name-completion-ignore-case (if (memq system-type '(ms-dos windows-nt darwin cygwin)) @@ -1513,7 +1514,7 @@ such as making the current buffer visit no file in the case of (declare-function x-file-dialog "xfns.c" (prompt dir &optional default-filename mustmatch only-dir-p)) -(defun read-file-name-defaults (&optional dir initial) +(defun read-file-name--defaults (&optional dir initial) (let ((default (cond ;; With non-nil `initial', use `dir' as the first default. @@ -1580,6 +1580,12 @@ See also `read-file-name-completion-ignore-case' and `read-file-name-function'." + (funcall read-file-name-function + prompt dir default-filename mustmatch initial predicate)) + +(defun read-file-name-default (prompt &optional dir default-filename mustmatch initial predicate) + "Default method for reading file names. +See `read-file-name' for the meaning of the arguments." (unless dir (setq dir default-directory)) (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir))) (unless default-filename @@ -1601,9 +1601,6 @@ (minibuffer--double-dollars dir))) (initial (cons (minibuffer--double-dollars initial) 0))))) - (if read-file-name-function - (funcall read-file-name-function - prompt dir default-filename mustmatch initial predicate) (let ((completion-ignore-case read-file-name-completion-ignore-case) (minibuffer-completing-file-name t) (pred (or predicate 'file-exists-p)) @@ -1639,7 +1636,7 @@ (lambda () (with-current-buffer (window-buffer (minibuffer-selected-window)) - (read-file-name-defaults dir initial))))) + (read-file-name--defaults dir initial))))) (completing-read prompt 'read-file-name-internal pred mustmatch insdef 'file-name-history default-filename))) @@ -1713,7 +1713,7 @@ (if history-delete-duplicates (delete val1 file-name-history) file-name-history))))))) - val))))) + val)))) (defun internal-complete-buffer-except (&optional buffer) "Perform completion on all buffers excluding BUFFER.