From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: how to determine the current table (really) being used for minibuffer completion? Date: Sat, 26 Sep 2009 17:26:47 -0400 Message-ID: References: <137402B99D584CEE9AF2E4B23116527A@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1254000427 10062 80.91.229.12 (26 Sep 2009 21:27:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 26 Sep 2009 21:27:07 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 26 23:27:00 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 1MrenD-0005Ee-Vy for ged-emacs-devel@m.gmane.org; Sat, 26 Sep 2009 23:27:00 +0200 Original-Received: from localhost ([127.0.0.1]:55951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MrenD-0005IM-FH for ged-emacs-devel@m.gmane.org; Sat, 26 Sep 2009 17:26:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mren8-0005IH-3m for emacs-devel@gnu.org; Sat, 26 Sep 2009 17:26:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mren2-0005HQ-EO for emacs-devel@gnu.org; Sat, 26 Sep 2009 17:26:52 -0400 Original-Received: from [199.232.76.173] (port=42995 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mren2-0005HN-BI for emacs-devel@gnu.org; Sat, 26 Sep 2009 17:26:48 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:29498 helo=ironport2-out.pppoe.ca) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mren2-0000vW-2D for emacs-devel@gnu.org; Sat, 26 Sep 2009 17:26:48 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnQFAE4jvkpFpYq6/2dsb2JhbACBUNIxhB4Fh30 X-IronPort-AV: E=Sophos;i="4.44,457,1249272000"; d="scan'208";a="46654674" Original-Received: from 69-165-138-186.dsl.teksavvy.com (HELO pastel.home) ([69.165.138.186]) by ironport2-out.pppoe.ca with ESMTP; 26 Sep 2009 17:26:47 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 4683280B1; Sat, 26 Sep 2009 17:26:47 -0400 (EDT) In-Reply-To: (Drew Adams's message of "Sat, 26 Sep 2009 07:58:17 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:115677 Archived-At: > Hypothetical example that might make the request clearer: > (completion-all-completions > STRING 'read-file-name-internal nil (length STRING)) > The result returned might be a list of relative file names, or it > might be a list of env vars. A result such as ("CATACOMBS" > "CATAPHILE" "CATASTROPHE" . 4) could be either. > I would like (via Lisp) to know which kind of completion was in fact used > successfully: file-name completion per se or env var completion. In which form? Do you want a symbol like `file' vs `envvar', or do you want a completion-table (which can then be a has-table, an obarray, an alist, a list, a symbol-function, or a lambda expression)? The second might be doable in many cases (actually more so in Emacs-23 than in Emacs-22, since most functional completion tables now get composed using primitives like complete-with-action or completion-table-*, so we could add a 5th method (additionally to the original 3, try-completions, all-completions, and test-completion, plus the new completion-boundaries) a bit more easily), but I'm not sure it would be easy to use. > I don't want to analyze STRING (e.g. check for `$') to figure out what > might be the case. (completion-boundaries STRING > 'read-file-name-internal nil "") just gives something like (0 . 0), > indicating the whole STRING. (completion-boundaries "to/to" 'read-file-name-internal nil "") returns (3 . 0), (completion-boundaries "to/$to" 'read-file-name-internal nil "") returns (4 . 0) and (completion-boundaries "to/${to" 'read-file-name-internal nil "") returns (5 . 0), so by looking at (aref STR (1- (car (completion-boundaries STR ...)))) you can "easily" tell which case is currently relevant. But of course, that requires knowledge of the behavior of read-file-name-internal. > Emacs should be able to tell me directly what the last completion > table/function used was. It should be easy to make this info > available somehow, e.g. in a global variable. It might be easy in 99% of the cases, depending on exactly what you want. In my experience, providing this info before seeing actual uses for it is a perfect recipe for "features" which are unusable in practice because they don't quite give the info we need. So I'm definitely not opposed to providing this info, but I'll wait for a practical use for it, so I'll be in a better position to provide the right info. > Similarly, for multiple, successive completion types using > `completion-styles', I would like to know which type (style) was in > fact successful. Same answer here. Actually, this one is even a bit worse, because I strongly suspect that if some code needs this info, it's probably not doing the right thing. But in any case, we'll see it when we get there. Stefan