hvesalai / emacs-scala-mode

The definitive scala-mode for emacs
http://ensime.org
GNU General Public License v3.0
361 stars 68 forks source link

Add support for identifiers names consisting of special characters #136

Closed VlachJosef closed 7 years ago

VlachJosef commented 7 years ago

to be treated as symbols in emacs, which allows easy navigation around buffer by jumping from one identifier to another

CLAassistant commented 7 years ago

CLA assistant check
All committers have signed the CLA.

hvesalai commented 7 years ago

I'm quite sure there is already something that handles real scala syntax such as =>. For the rest, I understand the idea, but differ with the view that this should be done in scala-mode proper. The list of symbols is totally dependent on the libraries the user is using.

So if we highlight these specially, why not other non-alphabetic names?

VlachJosef commented 7 years ago

Real scala syntax like => doesn't behave like symbol currently.

I'm fine with including such a subset of special syntax / method names which will be generally useful for all. I just don't want to go with empty list as default, since it will make purpose of this variable harder to understand.

fommil commented 7 years ago

yeah, can we just have a regex instead of explicit list? Or is there a collision with use of those characters as scala syntax?

hvesalai commented 7 years ago

Which movement commands exactly were you referring to in your submit comment?

VlachJosef commented 7 years ago

I'm using highlight-symbol-next etc. a lot for jumping around the buffer, but not just that, for example projectile-ag command by default select symbol under the point, which also make this to work .

VlachJosef commented 7 years ago

@fommil that list is turned into a single regex when used

hvesalai commented 7 years ago

In my view, if this change is made, it should mark all symbols as such, not just some selected few. I.e. it should mark everything else than the reserved symbols (so it would NOT mark for example, => or :

hvesalai commented 7 years ago

The code that you are "countering" with the syntax-propertize-function is this

    ;; by default all opchars are punctuation, but they will be
    ;; modified by syntax-propertize-function to be symbol
    ;; constituents when a part of varid or capitalid
    (dolist (char (mapcar 'identity "!#%&*+/:<=>?@^|~-\u21D2\u2190")) ;; TODO: Sm, So
      (modify-syntax-entry char "." syntab))

My code only marks these characters as symbols if they appear in a varid or capital id. What you should do is to study if that could be expanded to include at least op ids, if not all ids

The all ids case would then include stuff like this being one symbol

`volatile ++`
VlachJosef commented 7 years ago

ok, I've got the idea, I'll take a look

VlachJosef commented 7 years ago

I'm closing this PR as proper solution is still being worked on. It will be little more work to make it right. In the meantime I've raised #137 which makes quoted ids work as a single symbol.