sebastiw / distel-completion

Erlang/distel completion backend for both auto-complete and company-mode
GNU General Public License v3.0
7 stars 5 forks source link

company-frontend-distel inserts ":" into completion of other languages #4

Closed radupopescu closed 8 years ago

radupopescu commented 9 years ago

If company-frontend-distel is enabled with (require 'company-frontend-distel) I have an additional ":" in the completion of C/C++ projects. For example:

Suppose I have a struct:

struct C
{
    int x() { return 1; }
};

then later I declare an instance of C: C c; Using the suggested completion for c.x (pressing ENTER) will insert: c.x:()

Disabling the distel frontend fixes the issue (and completion still works with the distel backend).

Thank you.

dgutov commented 9 years ago

That file redefines company-finish, which is a pretty hostile behavior.

It doesn't look like there's been any activity here for years, though. I wish someone could take over the project.

radupopescu commented 9 years ago

Yes, I just noticed that this project hasn't seen any updates in quite some time.

At the same time, Distel is a really useful piece of software and integration with company-mode is great to have when you're working on a mix of C++ and Erlang projects in Emacs.

I've only recently started using company and distel but at some point I could fork this and clean it up.

On the issue of company-frontend-distel, I haven't noticed any downsides to not using it, yet. The completion pop up appears as usual, you select what you need, hit <RET>, it works.

dgutov commented 9 years ago

at some point I could fork this and clean it up

That would be welcome. Then we can ask melpa.org to point to your fork.

On the issue of company-frontend-distel, I haven't noticed any downsides to not using it, yet. The completion pop up appears as usual, you select what you need, hit , it works.

The idea behind it is to display the popup immediately again under certain conditions, which is not easy to do using just the public API. But I also don't think it justifies the hacky implementation.

sebastiw commented 9 years ago

Hi,

Yes, I did not know anyone used distel anymore. EDTS is the new black :) However, I will have a look at it when I get home.

BR, On Oct 20, 2015 12:55 PM, "Dmitry Gutov" notifications@github.com wrote:

at some point I could fork this and clean it up

That would be welcome. Then we can ask melpa.org to point to your fork.

On the issue of company-frontend-distel, I haven't noticed any downsides to not using it, yet. The completion pop up appears as usual, you select what you need, hit , it works.

The idea behind it is to display the popup immediately again under certain conditions, which is not easy to do using just the public API. But I also don't think it justifies the hacky implementation.

— Reply to this email directly or view it on GitHub https://github.com/sebastiw/company-distel/issues/4#issuecomment-149523644 .

radupopescu commented 9 years ago

Hi,

I never tried EDTS. Going with Company + DISTEL for Erlang + YCMD for C++ (and I'm sharing YCMD with Vim, which is where I'm coming from) is interesting for me because of the modularity of the system. Last I checked EDTS only integrated with auto-complete-mode, which I don't know much about.

Thank you for looking into this, Radu

sebastiw commented 9 years ago

Oh, I see.. It is a very aggressive behaviour to overwrite a function like that... Why did I ever...

It should probably be a defadvice instead, I'll try to get a fix tonight or sometime this weekend. I have added you as a collaborator if you have a fix ready, or want to contribute with something else.

dgutov commented 9 years ago

It should probably be a defadvice instead, I'll try to get a fix tonight or sometime this weekend.

An advice would be less problematic, but it can also break if the way company-finish is used is changed. It also won't by itself fix https://github.com/company-mode/company-mode/issues/414.

Using the workaround from https://github.com/company-mode/company-mode/issues/345 might be better.

radupopescu commented 9 years ago

@sebastiw Thank you. Unfortunately, I don't have a fix at the moment.

sebastiw commented 9 years ago

I have tried installing Distel, but I cannot connect to a node. I don't think the erlang node starts properly. However, I agree with @dgutov that it should be two company-backends. Maybe we can have one that activates on module-names and local funtions, and the other that activates when a user writes a colon ":" and then fetches the module name.. This would circumvent the not-so-perfect approach of company-mode/company-mode#345. I will create a new branch, and try to test some ideas there, however I will be traveling this week so I don't think I have enough time to complete the plugin before I leave.

dgutov commented 9 years ago

Maybe we can have one that activates on module-names and local funtions, and the other that activates when a user writes a colon ":" and then fetches the module name.

Why do you think that would help?

You can just as well have a single backend that activates in both of these cases.

sebastiw commented 9 years ago

Well. I think the problem from the beginning was with the module name started to clog the autocomplete buffer.

Consider the example where one starts with writing "li" and company then shows all functions from the module "lists:"

lib:flush_receive() lib:error_message(Format, Args) lib:progname() lists:all(Pred, List) lists:any(Pred, List) lists:append(ListOfLists) lists:append(List1, List2)

and so forth, and in the end there would be the local functions for example:

listAllMatches(Regex, String) limitString(Number, String) likeResults()

and lastly atoms (which in Erlang are like matching patterns or kindof strings hardtoexplain...)

limit line lime

Oh, and I almost forgot of the built-in functions

link(PidOrPort) list_to_atom(String) list_to_binary(IoList) etc...

So in some cases you want to list modules, and in some cases you will have a given module and only list the functions in that module. Thruthfully, I have not really dug into my code yet, so I'm really not sure. I know I previously ran into some troubles.

On Oct 29, 2015 21:27, "Dmitry Gutov" notifications@github.com wrote:

Maybe we can have one that activates on module-names and local funtions, and the other that activates when a user writes a colon ":" and then fetches the module name.

Why do you think that would help?

You can just as well have a single backend that activates in both of these cases.

— Reply to this email directly or view it on GitHub https://github.com/sebastiw/company-distel/issues/4#issuecomment-152308622 .

dgutov commented 9 years ago

My point is, having two backends won't help, because you just use one of them at a time. Whatever backend is activated, it shows you completions, you pick one, and that completion is done.

You might as well have one backend and choose the list of completions to show based on whether there's a : in the buffer before the current symbol.

sebastiw commented 9 years ago

Ok, I understand.

I have looked some more on why I did the "frontend" and I have left this comment to myself:

;;; Not really a frontend, just replaces the function ;;; company-finish to start again after a completion. ;;; Also to have the helpdocs appear in a popup instead ;;; of a new buffer.

Maybe I should just delete the file as it is not really needed.. Still would be nice to get Distel to work first to see what it really does. I'm debugging right now.

On 29 October 2015 at 22:24, Dmitry Gutov notifications@github.com wrote:

My point is, having two backends won't help, because you just use one of them at a time. Whatever backend is activated, it shows you completions, you pick one, and that completion is done.

You might as well have one backend and choose the list of completions to show based on whether there's a : in the buffer before the current symbol.

— Reply to this email directly or view it on GitHub https://github.com/sebastiw/company-distel/issues/4#issuecomment-152332525 .

radupopescu commented 9 years ago

@sebastiw I don't know what OS you are using, but on Mac OS X, I also had trouble with distel after the upgrade to El Capitan. Something changed in the application level firewall and I couldn't get distel to connect to the running Erlang node unless I disabled the "Stealth mode" setting. Which is weird, because that should affect ICMP. At the same time "epmd" and "beam.smp" are already among the applications white listed by the application level firewall.

Regarding the autocomplete list becoming too long, one can use something like "helm-company" to filter it. I am using this right now and I'm quite happy with the setup, but it's true that it involves installing an additional package.

sebastiw commented 9 years ago

I'm on Ubuntu-14.04 kernel 4.3. I starting to think that it is something with either emacs 25.0.50s network-stream.el or most likely some defmacro in distel. Distel creates some buffers, but is unable to start processes or send messages to those processes. Could be the firewall but I doubt that, I had similar problems with distel 3 years ago. On Oct 30, 2015 7:42 AM, "Radu Popescu" notifications@github.com wrote:

@sebastiw https://github.com/sebastiw I don't know what OS you are using, but on Mac OS X, I also had trouble with distel after the upgrade to El Capitan. Something changed in the application level firewall and I couldn't get distel to connect to the running Erlang node unless I disabled the "Stealth mode" setting. Which is weird, because that should affect ICMP. At the same time "epmd" and "beam.smp" are already among the applications white listed by the application level firewall.

Regarding the autocomplete list becoming too long, one can use something like "helm-company" to filter it. I am using this right now and I'm quite happy with the setup, but it's true that it involves installing an additional package.

— Reply to this email directly or view it on GitHub https://github.com/sebastiw/company-distel/issues/4#issuecomment-152443306 .

sebastiw commented 8 years ago

OK, just uploaded a rewrite to the whole repo. I have completely removed company-distel-frontend with the aggressive behaviour. Two major implementation problems left with this version:

@radupopescu could you please grab the latest and test if it removes the problem with c-code?

radupopescu commented 8 years ago

Hi @sebastiw, thanks for the updates! I pulled your latest commitss and did some basic checking, with an Erlang and a C++ project:

However I'm seeing two errors in the message log:

fail: [rex [badrpc [EXIT [undef ([distel describe (io format 3) nil] [rpc -handle_call_call/6-fun-0- 5 ([file rpc.erl] [line 206])])]]]]
Company: backend company-distel error "Wrong type argument: char-or-string-p, nil" with args (post-completion io:format)

The errors always appear, regardless of the value of erl-company-popup-help.

For the record, here is how I enable company-distel:

(require 'company-distel)
(add-hook 'erlang-mode-hook
          (lambda()
            (add-to-list 'company-backends 'company-distel)
            (setq erl-company-popup-help t)))

Thanks!

sebastiw commented 8 years ago

Ok

Try setting the "semi-" new parameter (setq distel-completion-get-doc-from-internet t)

radupopescu commented 8 years ago

Sorry for the late reply!