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

Is there a way to have unicode characters working like idents? #230

Open
beta-ziliani opened this issue Jan 23, 2020 · 5 comments
Open

Is there a way to have unicode characters working like idents? #230

beta-ziliani opened this issue Jan 23, 2020 · 5 comments

Comments

@beta-ziliani
Copy link

beta-ziliani commented Jan 23, 2020

If I define a rule

(* Local Variables: *)
(* company-coq-local-symbols: ( ("_M" . ?ℳ) ) *)
(* End: *)

I would expect _M1, _M', _M_blah be printed as ℳ₁, ℳ', and ℳ_blah respectively.

Instead, I need to redefine them too as in:
("_M'" . (?ℳ (Br . Bl) ?'))

Which is far from ideal.

Is there a way to have this?

@cpitclaudel
Copy link
Owner

There is a way to have this, if we changed prettify-symbols-predicate. See the definition of company-coq-features/prettify-symbols--predicate

@beta-ziliani
Copy link
Author

I did but I still have no clue, sorry!

@cpitclaudel
Copy link
Owner

Try this after loading company-coq, maybe?

(defconst ~/numbers '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9))

(defun ~/prettify-symbols--same-ish-syntax (other ref)
  "Check if the syntax class of OTHER is similar to that of REF."
  (let ((stx-other (char-syntax (or other ?\s))))
    (pcase (char-syntax ref)
      (?w (and (eq stx-other ?w)
               (eq (memq ref ~/numbers) (memq other ~/numbers))))
      (?_ (eq stx-other ?_))
      (_ (memq stx-other '(?. ?\\))))))

(advice-add 'company-coq-features/prettify-symbols--same-ish-syntax
            :override #'~/prettify-symbols--same-ish-syntax)

@beta-ziliani
Copy link
Author

It seems to work. Is there a reason not to have it by default?

In any case, I ended up coding everything in unicode (that's the reason for asking better support at fuzzy search in the first place).

@cpitclaudel
Copy link
Owner

It seems to work. Is there a reason not to have it by default?

Not sure. I could try making it the default and seeing whether people complain ^^

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

No branches or pull requests

2 participants