Skip to content

symbol includes trailing @ sign in as-patterns #311

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

Closed
mattraibert opened this issue Jul 28, 2014 · 5 comments · Fixed by #471
Closed

symbol includes trailing @ sign in as-patterns #311

mattraibert opened this issue Jul 28, 2014 · 5 comments · Fixed by #471

Comments

@mattraibert
Copy link

Emacs 24.3.91.1 (built from src on ubuntu)
haskell-mode 20140726.1852 (from melpa)

When I use find-tag or highlight-symbol-at-point on an as-pattern, emacs incorrectly thinks the at-sign is part of the symbol.

For example, in the following code, if point is on the xxs on the left-hand side of line 3, and you type M-. to find-tag, the default symbol to search for will be xxs@

tails                   :: [a] -> [[a]]
tails []                =  [[]]
tails xxs@(_:xs)        =  xxs : tails xs

It's also observable in this screenshot of this code store@ is highlighted but not store

store

@purcell
Copy link
Member

purcell commented Aug 27, 2014

Yes, this is a tricky one. @ is explicitly added to the symbol table as a "symbol constituent" character, since it is indeed valid in certain positions:

    (mapc (lambda (x)
            (modify-syntax-entry x "_" table))
          ;; Some of these are actually OK by default.
          "!#$%&*+./:<=>?@^|~")

This discussion has a succinct summary of when it is legal, ie. not at the end of a symbol.

Given the Emacs syntax table system, which can't take into account the character's position in a potential symbol, I'm not sure that a resolution of this issue is possible. It might be the case that the syntax-propertize-function mechanism in Emacs >= 24 would help, but haskell-mode doesn't use that at all currently.

@gracjan
Copy link
Contributor

gracjan commented Feb 17, 2015

@purcell: wait, this explanation does not sound right, please correct me if I'm wrong:

There is a 'w' category that is for words. '@' is never a part of 'w' category in Haskell.
There is a '_' category that is for symbols. '@' is either special symbol if alone or part of operator symbol if there is a longer sequence of symbols.

Am I wrong about either Haskell or Emacs interpretation of 'w' vs '_'?

@purcell
Copy link
Member

purcell commented Feb 17, 2015

@gracjan Hmm, yes, you're probably right that @ should not have symbol syntax.

@gracjan
Copy link
Contributor

gracjan commented Feb 17, 2015

@purcell, @mattraibert

Currently '@' has class '_', each of 'store' has class 'w'.

In haskell-mode highlight-symbol-at-point highlights whole of 'store@', and whole of 'store+++' and whole of 'store+load'.

In c-mode characters like '+', '@' etc have class '.' (punctuation).

Do we lose any functionality if Haskell symbol characters get puntuaction class?

@purcell
Copy link
Member

purcell commented Feb 18, 2015

Do we lose any functionality if Haskell symbol characters get puntuaction class?

Probably not, though I can't be 100% certain.

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 a pull request may close this issue.

3 participants