johnw42 / fira-code-emacs

Some code to make Fira Code work in Emacs
Apache License 2.0
60 stars 4 forks source link

Strange behavior with the last commit! #1

Closed arkhan closed 4 years ago

arkhan commented 5 years ago

Great job, congratulations.

In the last commit you get a strange behavior as you can see in the attached image.

output-2019-09-15-21:15:38

In my configuration I have it like this:

(leaf pcache
  :straight t
  :init
  (setq pcache-directory (let ((dir (concat conf:cache-dir "pcache/")))
                           (make-directory dir t)
                           dir)))

(leaf unicode-fonts
  :straight t
  :init (unicode-fonts-setup))

(global-font-lock-mode 1)
(set-face-attribute 'default nil
                    :font "Fira Emacs Retina"
                    :height 115
                    :slant 'normal
                    :weight 'normal
                    :width 'normal)

(leaf fira-code
  :straight (fira-code
             :type git
             :host github
             :repo "johnw42/fira-code-emacs")
  :hook (prog-mode-hook . fira-code-mode))

Thanks

tgolsson commented 5 years ago

Got the same issue! I think it was caused by this comment. Overall, I feel that the prettification is very fragile and will break repeated characters into prettified chunks as well which looks glitchy and distracting. I think some form of contextual parsing might be useful?

I've not had time to test anything yet, but I'm thinking that maybe using word-boundaries (so we have to start and end prettyficiation at boundaries) might be a good starting point.

tgolsson commented 5 years ago

For what it's worth, I set the fira compose predicate to prettify-symbols-default-compose-p and it seems to work a lot better overall, including both comments and spurious wedged symbols.

arkhan commented 5 years ago

@tgolsson thanks, setting the configuration as follows:

(leaf pcache
  :straight t
  :init
  (setq pcache-directory (let ((dir (concat conf:cache-dir "pcache/")))
                           (make-directory dir t)
                           dir)))

(leaf unicode-fonts
  :straight t
  :init (unicode-fonts-setup))

(global-font-lock-mode 1)
(set-face-attribute 'default nil
                    :font "Fira Emacs Retina"
                    :height 115
                    :slant 'normal
                    :weight 'normal
                    :width 'normal)

(leaf fira-code
  :straight (fira-code
             :type git
             :host github
             :repo "johnw42/fira-code-emacs")
  :setq (fira-code-compose-predicate . 'prettify-symbols-default-compose-p)
  :hook (prog-mode-hook . fira-code-mode))

(leaf prog-mode
  :config
  (add-hook 'prog-mode-hook
            (lambda ()
              (mapc (lambda (pair) (push pair prettify-symbols-alist))
                    '(("in" . ?\u2208)
                      ("IN" . ?\u2208)
                      ("not in" . ?\u2209)
                      ("NOT IN" . ?\u2209)
                      ("not" . ?\u00AC)
                      ("NOT" . ?\u00AC)))))
  (defun indicate-buffer-boundaries-left ()
    (setq indicate-buffer-boundaries 'left))
  (add-hook 'prog-mode-hook #'indicate-buffer-boundaries-left)
  (add-hook 'prog-common-hook
            (lambda ()
              (font-lock-add-keywords nil
                                      '(("\\<\\(FIX\\|FIXME\\|TODO\\|BUG\\|HACK\\):" 1 font-lock-warning-face t))))))

output-2019-09-16-10:21:36

But you should also change the "@" symbol

jpellegrini commented 4 years ago

Got the same issue! I think it was caused by this comment.

Yes -- that was me! (Sorry, I should have realized beforehand that it would trigger that sort of behavior).

Overall, I feel that the prettification is very fragile and will break repeated characters into prettified chunks as well which looks glitchy and distracting. I think some form of contextual parsing might be useful?

I agree! I hadn't had a problem since I made that commend (and the commit was made by @johnw42), but I see what happens.

Now I have tested setting fira-code-compose-predicate to 'prettify-symbols-default-compose-p and it seems to work fine for most of my use cases.

jpellegrini commented 4 years ago

Oh - I just pulled and commit 71b35183584f483e1d5957fa547e26c496eb6000 seems to fix the issue.

johnw42 commented 4 years ago

Oops, I'm just now seeing all these messages! I think everything is working now so I'm gonna close the issue. Feel free to file another one if more problems turn up.

Overall, I feel that the prettification is very fragile and will break repeated characters into prettified chunks as well which looks glitchy and distracting. I think some form of contextual parsing might be useful?

Oh, it's absolutely very fragile, and I keep discovering subtle new ways for it to be broken. I suppose I'll make a proper release once I'm satisfied I don't need any more API changes.