go-mode.el icon indicating copy to clipboard operation
go-mode.el copied to clipboard

Making _ a symbol constituent.

Open jeeger opened this issue 10 years ago • 7 comments

  • Comments indicate that this shouldn't work in XEmacs, but if we only make it a symbol constituent in GNU Emacs, this should still work with XEmacs.

jeeger avatar Jan 19 '15 10:01 jeeger

Can you give me a quick rundown on what _ as a symbol constituent means for users of go-mode? I've looked into it years ago when I wrote go-mode, and iirc the gist was "it's better", but I don't remember why.

dominikh avatar Jan 19 '15 15:01 dominikh

Hello! "" as symbol constituent means that "a_b_c" is a symbol, but the words consist of "a", "b" and "c". When "" is a word character, the word is "a_b_c" as well. This allows the user to navigate between parts of the symbol with backward/forward-word.

However, my change seems to introduce errors in syntax highlighting (probably related to the comment in the syntax table definition), which I'll have to debug. Some of the font-lock rules seem to use \< and \> instead of \_< and \_>. I'll have a look at it some time and I'll close this for now.

jeeger avatar Jan 19 '15 16:01 jeeger

Fixed the font-locking rules to add symbol characters to all regexes. This fixes font-locking for identifiers containing underscores. However, I'm not clear on the interoperability with XEmacs, as I don't use it. The only thing that could potentially be a problem is support of the \s_ regex class.

jeeger avatar Jan 20 '15 10:01 jeeger

Now that you mention it, this change might also break other emacs packages that copied our regexps for matching identifiers. I'll have to think about this.

dominikh avatar Jan 20 '15 19:01 dominikh

This shouldn't influence other packages at all. The [:word:] class depends on the current syntax table anyway, and the regexes won't work in modes that have a different syntax table from go-mode. If the regex is copied, this won't influence anything either, since _ is still a word character.

Of course, I can't guarantee anything^^. I'd like to mention though that not having _ as a symbol character differs significantly from standard emacs mode (for example c-mode).

jeeger avatar Jan 20 '15 19:01 jeeger

This shouldn't influence other packages at all

The go-eldoc package, for example, copied and slightly modified our regexps, which means they still use [:word:][:multibyte:]. Changing _ to be a symbol constituent instead of a word character would cause them the same problems that it caused for our syntax highlighting.

dominikh avatar Jan 20 '15 19:01 dominikh

If go-eldoc uses the go-mode syntax table, this would break their copy of the regexes. However, I'd suspect that this is an easy fix. Do you know of any other modes that use the go-mode syntax table and have copied the regexes from go-mode?

I'll try and have a look at go-eldoc tomorrow and see if I can fix it there as well.

jeeger avatar Jan 20 '15 20:01 jeeger