abo-abo / function-args

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

fa-show can break syntax coloring and does not update its own position #29

Open zhro opened 9 years ago

zhro commented 9 years ago

GNU Emacs 24.5.1 in -nw terminal mode.

Slimmed .emacs:

(require 'cedet)

(setq semanticdb-default-save-directory "~/.semanticdb/")

(semantic-mode 1)

(add-to-list 'load-path "~/.emacs.d/function-args")
(add-to-list 'load-path "~/.emacs.d/swiper") ;; function-args dependency
(require 'function-args)
(fa-config-default)

Using the collowing code:

class Rectangle {
  int width;
  int height;

public:
  void set_values(int, int);
};

int main () {
  Rectangle rect;

  rect.set_values(

  return 0;
}

With the cursor set to the right of rect.set_values(, I activate fa-show, complete the function call with rect.set_values(1, 2); and call fa-abort to close the hint. I then hit Return and type int z; but it is no longer colored. Color-hinting for C++ no longer functions for anything new typed into the buffer.

I have tried this several times and can't seem to figure out what's wrong. I have to restart Emacs to get color back.

If I create a new object Rectangle m; and then call m.area( and invoke fa-show, the old hint of (int, int) : void appears above rect.set_values(1, 2);

abo-abo commented 9 years ago

Can't reproduce. The expected way for this to work is to have electric-pair-mode on and call fa-show when the point is inside the parens. Once you insert any character outside the parens, e.g. ";", the overlay will delete itself automatically.

zhro commented 9 years ago

I can confirm that if I turn on electric-pair-mode and use fa-show from within the parenthesis and complete the parameter list then syntax coloring works. However, the overlay does not remove itself when typing outside of the parenthesis afterwards; I have not yet seen this work.

If I invoke fa-show for rect.set_values(); and then leave the parenthesis without adding any parameters, syntax coloring is again broken.

It seems as though function-args fa-show does not work unless called from within an enclosed parenthesis (electric-pair-mode as you said). The overlay will appear when called after an open-but-unclosed parenthesis but will not proceed through the list as commas are entered; it will not recognize the closing parenthesis being added later, and again appears to break syntax coloring.

I know that you said you can't reproduce. I can be available on Skype to do a screen share to demonstrate.

zhro commented 9 years ago

I still would like to see this fixed. :\

abo-abo commented 9 years ago

As I said, I can't do anything without a reproducible recipe. The error is likely in your config, unrelated to function-args. Try to reproduce with emacs -Q and only load function-args.

zhro commented 9 years ago

In my first post I provided my slimmed .emacs config. There isn't anything there except for the bare essentials for testing.

I'm running Emacs under Windows/Cygwin. If I send you a complete working environment in a zip file (just run the a .bat) will you look at it?

abo-abo commented 9 years ago

I'm running Emacs under Windows/Cygwin. If I send you a complete working environment in a zip file (just run the a .bat) will you look at it?

Sorry, but I don't have Windows. I'll leave the issue open, maybe some other user can come up with a fix. Nothing else I can do, unless I get a reproducible recipe for GNU/Linux.

zhro commented 9 years ago

What flavor and version?

abo-abo commented 9 years ago

You mean GNU/Linux? It doesn't matter at all, they should work the same. I have Emacs 24.5.2 and Emacs 25 on Ubuntu 14.04, but I also fix bugs for Emacs 24.3, since it's provided by many package managers.

zhro commented 9 years ago

Clean install of ubuntu 15.04 in VMware Player 7.1.2 and same procedure as my first post results in the same problem: syntax coloring breaks. Please be sure to copy/paste and follow the instructions exactly. This version of Ubuntu comes with Emacs 24.4.1.

While in Ubuntu, although cedet loaded without error, I received the following error when attempting fa-show:

Wrong type argument: listp, "rect"

There seems to be a problem with the built-in cedet in Ubuntu or perhaps it requires a slightly different configuration?

I corrected it by using the git head of the latest cedet and adding this to my .emacs:

(load-file "~/.emacs.d/cedet-git-head/cedet-devel-load.el")

(require 'cedet)
(require 'semantic)
(require 'semantic/ia)
(require 'semantic/bovine/gcc)

I can confirm that the problem persists with both the built-in cedet (tested on Windows) and the latest cedet head (tested on Windows and Ubuntu).

abo-abo commented 9 years ago

OK, so you wrote your setup in detail. I suppose that you use emacs -nw. What exactly do you do when inside your C example, assuming you don't call fa-abort manually?

zhro commented 9 years ago

The source is saved to main.cpp which is loaded by emacs -nw main.cpp. The cursor is placed here:

rect.set_values(|

Everything is then as follows:

M-x fa-show type: 1, 2); then M-x fa-abort to close the hint. Return and int z;. Notice that syntax coloring no longer occurs.

I can give you shell access if need be but this is all in a fresh VM.

abo-abo commented 9 years ago

While in Ubuntu, although cedet loaded without error, I received the following error when attempting fa-show:

This only happens for rect.set_values( and not for rect.set_values(), which how the function is meant to be used.

zhro commented 9 years ago

I don't use electric-pair-mode and even with it on, the problem is that if I happened to delete a parenthesis and accidentally invoke fa-show then my whole mode is gimped and I have to restart emacs.

I don't know why it's breaking syntax coloring but can you at least fix it so that fa-abort restores the buffer to a working state? As I can understand if a visible popup interferes but not once it's been removed.

abo-abo commented 9 years ago

I can't reproduce the syntax coloring problem on Emacs 24.3.1 with emacs -nw. The only thing I get is this error:

Wrong type argument: listp, "rect"

but nothing else bad happens.

zhro commented 9 years ago

Yes, for some reason I get this on Ubuntu as well. The built-in cedet isn't parsing the file for some reason.

See my comment here: https://github.com/abo-abo/function-args/issues/29#issuecomment-139189648

abo-abo commented 9 years ago

It can be that it's not parsing it: it's an outdated version after all. That error isn't really a bug that I can fix. However, the syntax discoloration might be related to function-args, but I haven't encountered it so far under any circumstance.

zhro commented 9 years ago

Clone out the cedet repo and use the sample .emacs lines I provided and you will have the error to see. I would be extremely grateful if you could fix this.

zhro commented 9 years ago

Did you manage to get the error to reproduce?

zhro commented 9 years ago

Any luck? D: