unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: bvraghav@iitk.ac.in, help-gnu-emacs@gnu.org
Subject: RE: C Headers completion candidates
Date: Thu, 14 Jul 2016 07:27:19 -0700 (PDT)	[thread overview]
Message-ID: <d8913689-82a7-441a-9b90-e369b770b1b3@default> (raw)
In-Reply-To: <87k2gozusa.fsf@ram.bvr.dp.lan>

> 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.
> 
> 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 <vec|>
> ---
> `|' 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).



  parent reply	other threads:[~2016-07-14 14:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14  4:51 C Headers completion candidates B.V. Raghav
2016-07-14 13:02 ` Stefan Monnier
2016-07-14 14:27 ` Drew Adams [this message]
2016-07-17  8:40   ` B.V. Raghav
2016-07-17 15:02     ` Drew Adams
2016-07-18  3:07       ` B.V. Raghav
2016-07-18  5:17         ` Drew Adams
2016-07-18 11:21           ` B.V. Raghav
2016-07-18 14:17             ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d8913689-82a7-441a-9b90-e369b770b1b3@default \
    --to=drew.adams@oracle.com \
    --cc=bvraghav@iitk.ac.in \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).