abo-abo / function-args

C++ completion for GNU Emacs
120 stars 10 forks source link

Function argument completion #1

Closed tuhdo closed 10 years ago

tuhdo commented 10 years ago

This is a great package. The only thing missing is function arguments completion, like auto-complete-clang does:

clang

Argument insertion and return type:

clang_arg_insert

abo-abo commented 10 years ago

Could you explain in words the feature that you want? I don't see how your first screenshot is better than this one:

screenshot

Other than the fact that CEDET doesn't currently see other candidates for assign. If CEDET saw them, they would be there.

I have no idea what's happening in your second screenshot.

tuhdo commented 10 years ago

The problem with fa-show is that it can only show if a function is complete with its arguments, i.e. if you try fa-show on ss.assign (without any arguments), nothing shows up. Why does fa-show need this after moo-complete already there? It is because after inserting, we don't have any information about function arguments; we only have the inserted function name.

You are right that the second screenshot is unclear, so I made this gif:

clang_example

I think moo-complete should insert function arguments in a similar manner, or let fa-show pops up for helping us insert the function arguments. It should be possible, since moo-complete has all information of a function (its return type and its arguments).

fa-show uses a pop-up is convenient, but sometimes there are too many overloaded functions, like 10 or more functions, cycling to find a correct signature is inconvenient. It should have another option to display all the possible signatures in a separate buffer.

abo-abo commented 10 years ago

The problem with fa-show is that it can only show if a function is complete with its arguments, i.e. if you try fa-show on ss.assign (without any arguments), nothing shows up.

This is by design. The way fa-show works is that it searches forward for the next open paren on current line (unless it's already inside parens, then it doesn't move the point). Once you have:

ss.assign()

fa-show (M-i) will work from any point in this range (marked with |):

|ss.assign(|)

So the work-flow for insertion is ss.as M-o M-i.

I think moo-complete should insert function arguments in a similar manner

As you see, moo-complete inserts parens on completion. And in some cases (function pointers) even that is too much.

The way it's done in the gif seems to obtrusive for me, I prefer the minimalism of fa-show. Being unobtrusive is key, because most people (extrapolated from myself, may be inaccurate) eventually don't like to be spoon fed the forms to fill in. More and more as they get the hang of the library.

fa-show uses a pop-up is convenient, but sometimes there are too many overloaded functions, like 10 or more functions, cycling to find a correct signature is inconvenient. It should have another option to display all the possible signatures in a separate buffer.

I can eventually add some functionality for this, but it hasn't bugged me enough to do it already. And the whole idea of function-args is no separate buffers, helm doesn't count:)

tuhdo commented 10 years ago

This is by design. The way fa-show works is that it searches forward for the next open paren on current line (unless it's already inside parens, then it doesn't move the point).

Nice to know that fa-show can be activate between a pair of parens. I thought that I have to have full arguments.

The way it's done in the gif seems to obtrusive for me, I prefer the minimalism of fa-show.

Yes, you can still keep the current behaviour of moo-complete. Argument completion is optional. auto-complete-clang does this. You don't have to be prompted for a form to complete arguments, unless you want too. The combination between moo-complete and fa-show suffices to make this feature. Currently, there's mismatch between moo-complete and fa-show: if I choose a function with multiple signatures in moo-complete, activating fa-show gives me another signature. For example, after I choose a particular insert function (which is corresponding to candiadte No.8 in fa-show), fa-show gives me candidate No.1.

It would be nice if fa-show somehow knows which function I selected from moo-complete and give me an appropriate one.

I can eventually add some functionality for this, but it hasn't bugged me enough to do it already. And the whole idea of function-args is no separate buffers, helm doesn't count:)

Well, this could be optional, and certainly it can compensate for its separate buffer by knowing which function signature and argument position I'm using, and highlight appropriately.

For example, there are 3 function of a same name listed in a fa-show buffer, one with 1 argument and two with 2 argument:

After enter foo(, if:

You can implement this similar to Helm (but no using Helm, or if you find a possible way, it's fine): as you type, the candidates are narrowed, only leaving suitable candidates (similar to Helm). The buffer is automatically closed after you finish entering all arguments of the most matched candidate.

This sounds a lot. Certainly, you can implement whenever you want. I just want to leave my idea here, so you could use them when needed (I hope).

abo-abo commented 10 years ago

Thanks for the feedback, I'll try to implement some of these features at some point. It's not feasible to implement dispatch by type yet, because CEDET's understanding of C++ isn't solid enough yet. You can check function-args.el: a large part of the source are work-arounds and crutches and duct tape, which break from time to time with CEDET upgrades.

I'm closing this issue for now, as it's too broad. But if you want to help, please open a new issue on moo-complete and fa-show being in sync. That sounds doable. Add other issues as well if you want, just don't munge all the features into one topic - this makes it hard to read and to understand what exactly you want.

I'd prefer a minimal Cucumber-style issues like:

  1. Given test.cc with following contents ...
  2. When I do moo-complete and select ...
  3. And then I do fa-show and ...
  4. The result should be ...
tuhdo commented 10 years ago

After getting used fa-show, I found that it's more convenient then earlier proposal in this issue. since I can traverse back and forth between arguments and change things without afraid of losing type information, as opposed to yasnippet style in ac-complete-clang.

abo-abo commented 10 years ago

Yes, that's exactly what I was aiming for:)