From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: how to determine the current table (really) being used for minibuffer completion? Date: Fri, 25 Sep 2009 14:22:26 -0700 Message-ID: <137402B99D584CEE9AF2E4B23116527A@us.oracle.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1253913779 12331 80.91.229.12 (25 Sep 2009 21:22:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Sep 2009 21:22:59 +0000 (UTC) Cc: emacs-devel@gnu.org To: "'Stefan Monnier'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 25 23:22:52 2009 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 1MrIFd-0002zr-Sr for ged-emacs-devel@m.gmane.org; Fri, 25 Sep 2009 23:22:50 +0200 Original-Received: from localhost ([127.0.0.1]:57317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MrIFd-0001v5-5m for ged-emacs-devel@m.gmane.org; Fri, 25 Sep 2009 17:22:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MrIFW-0001tH-Cj for emacs-devel@gnu.org; Fri, 25 Sep 2009 17:22:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MrIFN-0001nV-3m for emacs-devel@gnu.org; Fri, 25 Sep 2009 17:22:38 -0400 Original-Received: from [199.232.76.173] (port=49466 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MrIFL-0001m4-WD for emacs-devel@gnu.org; Fri, 25 Sep 2009 17:22:32 -0400 Original-Received: from acsinet12.oracle.com ([141.146.126.234]:30726) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MrIFL-0004sP-DD for emacs-devel@gnu.org; Fri, 25 Sep 2009 17:22:31 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by acsinet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n8PLLdHI020654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 25 Sep 2009 21:21:40 GMT Original-Received: from abhmt013.oracle.com (abhmt013.oracle.com [141.146.116.22]) by acsinet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n8PLN2a6013350; Fri, 25 Sep 2009 21:23:02 GMT Original-Received: from dradamslap1 (/141.144.66.80) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 25 Sep 2009 14:22:26 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: Aco+Gv20g73ALDEpQkWZVtD2t0ZXXgAAVTmw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: abhmt013.oracle.com [141.146.116.22] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090207.4ABD3493.0189:SCFSTAT5015188,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 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:115641 Archived-At: > > Since the Emacs 23 changes to minibuffer completion, there is little > > doc, and there are few doc strings. It's not always obvious how to > > determine the current state of evaluation. > > I do not know what you mean. Please give a concrete example > showing how you used to do it in Emacs-22. How I used to do what? There is no concrete example. The point is that it is impossible (difficult?) to know which kind of completion function is currently being attempted, or which type completed successfully. Previously, comparing `minibuffer-completion-table' against a given function gave some idea. And surely you know what I mean wrt doc and doc strings. ;-) > > In particular, when completion tables are tried in sequence > > under the covers, how is it possible to know at some point > > which table is actually being tried? > > If you mean uses of completion-table-in-turn: you can't and neither > could you in Emacs-22; and this is not strictly a change in the > minibuffer completion but in the implementation of some completion > tables (yes, I made changes to both because the minibuffer completion > changes needed some adjustments in the competion tables to > work better, and because I wanted to rewrite in Lisp the C implementation > of some of the completion tables, and because I wanted to give the > code more structure). So you've confirmed what I said: one cannot know. The request is to be able to know. IOW, to be able to have some finer-grain knowledge of the completion state. > > For example, how to know, during file-name completion, > > whether the table currently being tried is > > `(completion--make-envvar-table)' or > > `(completion--file-name-table)'? > > You can't (and neither could you before, AFAICT). > Could you give us some context to beter understand when you need it? No. I didn't say I needed it in some concrete way. The point is that now there can be radically different kinds of completion that are used, all within the same `read-file-name-internal' (for example). I would like to be able to know which phase of that completion processing I'm in, or which phase succeeded if completion was successful. I would like, for instance (just an example), to be able to distinguish file-name completion per se from env var completion, both of which are now included as part of "file-name" completion in a larger sense. > > We have the global variable `minibuffer-completion-table', > > but that is apparently useless in this context. That var might > > be bound to some function `foo', but that doesn't mean that > > it is `foo' that is actually trying to perform completion > > at the moment, since completion now can involve several > > completion attempts using different tables > > (e.g. functions), successively. > > It does mean that `foo' is the table that does the completion. Only in a general way. `foo' or `read-file-name-internal' is the overall completion function, to be sure, but the completion processing is now decomposed into several distinct cases (as you say, next). For `read-file-name-internal', these are `completion--embedded-envvar-table' and `completion--file-name-table'. `read-file-name-internal' doesn't really call directly for any low-level completion act (e.g. `try-completion') anymore. > That table may be decomposed into several distinct cases, but that's > nothing new. The same was already the case when completing for > Info-goto-node, for example. Well, yes and no. Yes, this is a quantitative expansion of the kind of thing that has already been done in `Info-read-node-name' (but it did only one kind of completion or another, not a sequence of different kinds of completions) - but it pretty much becomes a qualitative change because it is so pervasive now. > > So not only is checking `minibuffer-completion-table' against > > `read-file-name-internal' useless, > > Comparing functions is usually a bad idea. Sometimes, > there's not much else we can do, admittedly. The Emacs code still compares `minibuffer-completion-table' against `read-file-name-internal', in particular, in many locations. I assume that all of those occurrences still work as intended. ;-) But I might want to do something different, depending on whether, say, an env var is being completed or a file name (properly speaking) is being completed at the moment (or was completed successfully). Maybe just display a msg; it really doesn't matter what. This doesn't depend on any particular concrete case (need). It is a general request. > > How about (at least) recording in some global var the table that is > > currently being used/tried? > > It's not even clear what that would mean. Maybe have a global variable `current-completion-table', analogous to `minibuffer-completion-table. Maybe `complete-with-action' could set it to the table it is currently using. That might make it possible to know which type of completion was used successfully. I obviously don't have a great feel for how to best implement what I'm asking for or how best to use it. It just seems that we should be able to have some way to test what's going on - what kind of completion is being attempted - and what kind of completion was successful. The act of completion is now a multi-act epic play. It's good to be able to know which act is in progress or what the outcome of the previous act was. That's all.