From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: C Headers completion candidates Date: Thu, 14 Jul 2016 07:27:19 -0700 (PDT) Message-ID: References: <87k2gozusa.fsf@ram.bvr.dp.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1468508330 19106 80.91.229.3 (14 Jul 2016 14:58:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Jul 2016 14:58:50 +0000 (UTC) To: bvraghav@iitk.ac.in, help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 14 16:58:34 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bNi5v-0002TL-R3 for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 16:58:32 +0200 Original-Received: from localhost ([::1]:54552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNi5q-0000GM-0H for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 10:58:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNhbv-0006JS-9Y for help-gnu-emacs@gnu.org; Thu, 14 Jul 2016 10:27:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNhbq-0003pY-7e for help-gnu-emacs@gnu.org; Thu, 14 Jul 2016 10:27:31 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:33792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNhbp-0003ov-VC for help-gnu-emacs@gnu.org; Thu, 14 Jul 2016 10:27:26 -0400 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u6EERL3S009733 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 14 Jul 2016 14:27:21 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u6EERKaR011374 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 14 Jul 2016 14:27:21 GMT Original-Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u6EERJ6X014914; Thu, 14 Jul 2016 14:27:20 GMT In-Reply-To: <87k2gozusa.fsf@ram.bvr.dp.lan> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6744.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110838 Archived-At: > I want a set of completion candidates for c-headers, something like > `auto-complete c headers'. Only, I do not want the complete ac-library > tagged along, nor do I want the popups. >=20 > Personally, I want to use the icicles interface, where I feel > comfortable. Icicles does not provide anything special for completing symbols in C headers. Whatever is already available for vanilla Emacs (e.g. to determine the possible completions for a partial symbol before the cursor) should be usable with Icicles. > Step 1. Identifying the context > --- Example > #include > --- > `|' represents the cursor here > I think I can code the regexp here What regexp do you mean, here? If the cursor is at that location then all that should be needed is a function that takes the name just before the cursor (e.g. "vec") and returns completions for it (your step 2). > Step 2. Set of completion candidates > Search the $INCLUDE environment variable, with `visited' flags on the > folders that have been visited; and create the set of completion > candidates, one in a line Sounds reasonable. Maybe someone familiar with Emacs C mode(s) can speak to what is already available wrt such gathering of completion candidates. (Icicles does nothing specific for this, but if you have a function that provides the completions then Icicles can make use of it.) > I hope there is a smarter way? Maybe there is already a function that gathers completions here. Wait to hear from those who are familiar with Emacs C modes. If there is not then you can code it, along the lines you suggested (using $INCLUDE etc.). > Step 3. Tell Icicles to invoke these set of completion candidates, > when the context is active. How? I do not know. As Stefan mentioned, `completion-at-point-functions' is a list of functions that, in the current mode (e.g. C mode), perform completion for a name (e.g. a "symbol") that is just before the cursor. If there is already a function on the list that is the value of that variable when you are in C mode, then try it. `C-M-i' is bound to `complete-symbol' - this is what you would use to complete the symbol (name) at point. If that command uses the minibuffer to let you choose among completions when there is more than one, then (in Icicle mode) you can take advantages of Icicles completion automatically. But probably it does not use the minibuffer for this. If `C-M-i' does not use the minibuffer when there are multiple choices, but instead expects you to keep hitting `C-M-i' to cycle to another choice, then you will need to use another command instead, which does use the minibuffer (e.g. bind it to `C-M-i' or some other key, in C mode). (If a command uses the minibuffer with completion then you can use it with Icicles completion.) In that case, you will need to code that command. If there is already a function on list `completion-at-point-functions' in C mode, then you can model the Icicles command that you will add to list `completion-at-point-functions' on that existing function. The only change you should need to make is for the case when multiple completions are available. In that case, call `completing-read', passing the list of completions as argument, to read the chosen candidate. Then, delete the partial name just before the cursor and replace it by that chosen completion (just as the vanilla code does).