Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making _ a symbol constituent. #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jeeger
Copy link

@jeeger jeeger commented Jan 19, 2015

  • 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.

- 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.
@dominikh
Copy link
Owner

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.

@jeeger
Copy link
Author

jeeger commented Jan 19, 2015

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 jeeger closed this Jan 19, 2015
Added the "\\s_" element to all parts where [:word:] appeared. This way,
we can have _ as a symbol constituent for proper backward/forward-word
movement.
@jeeger
Copy link
Author

jeeger commented Jan 20, 2015

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 jeeger reopened this Jan 20, 2015
@dominikh
Copy link
Owner

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.

@jeeger
Copy link
Author

jeeger commented Jan 20, 2015

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).

@dominikh
Copy link
Owner

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.

@jeeger
Copy link
Author

jeeger commented Jan 20, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants