syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

matlab-mode comments color #7469

Closed Mengesh closed 4 years ago

Mengesh commented 7 years ago

Description :octocat:

Comments in .m files are not colored well in matlab-mode if they contain a number and some operation symbol like +-*/.

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: The color of comment lines are different

Expected behaviour: :heart: :smile: The color of all comment lines should be the same regardless of the comment text

System Info :computer:

((auto-completion :variables auto-completion-enable-snippets-in-popup t auto-completion-enable-help-tooltip t auto-completion-enable-sort-by-usage t)
 better-defaults emacs-lisp git markdown pandoc org
 (shell :variables shell-default-height 30 shell-default-position 'bottom)
 spell-checking syntax-checking extra-langs ranger semantic gtags
 (python :variables python-enable-yapf-format-on-save t)
 (latex :variables font-latex-fontify-script nil latex-enable-auto-fill t latex-enable-folding t))
TheBB commented 7 years ago

This reproduces in emacs -q with matlab-mode and highlight-numbers-mode, therefore one of these is the culprit.

Mengesh commented 7 years ago

So I guess the workaround would be

 (remove-hook 'matlab-mode-hook 'highlight-numbers-mode)

but it doesn't work for me and I can't figure out why.

It works with prog-mode-hook though.

 (remove-hook 'prog-mode-hook 'highlight-numbers-mode)
TheBB commented 7 years ago

Because highlight-numbers-mode isn't in matlab-mode-hook, it's in prog-mode-hook.

Mengesh commented 7 years ago

That makes sense :)

jb55 commented 7 years ago

(triage) is there anything left to do here?

DvdMgr commented 6 years ago

Wouldn't removing highlight-numbers-mode from prog-mode-hook affect other modes, too?

I found that adding an entry to the hash table highlight-numbers-modelist with key 'matlab-mode and value 'do-not-use works, too!

braham-snyder commented 6 years ago

it would, but I don't think anyone was suggesting that was a satisfactory solution, only that it was sufficient (for debugging's sake)

adding an entry to highlight-numbers-modelist works, as does the following:

    (add-hook 'matlab-mode-hook
            ;; `highlight-numbers-mode' breaks MATLAB comment coloring --
            ;; `highlight-numbers-mode' is mostly redundant with
            ;; `rainbow-identifiers-mode' anyway
            (lambda ()
              (highlight-numbers-mode -1))
            ;; We must append the above *after* `spacemacs/run-prog-mode-hooks'
            ;; in `matlab-mode-hook', since the former hook enables
            ;; `highlight-numbers-mode'. Note that
            ;; `spacemacs/run-prog-mode-hooks' is manually added to
            ;; `matlab-mode-hook' by Spacemacs since the upstream `matlab-mode'
            ;; package does not derive `matlab-mode' from `prog-mode' (oddly --
            ;; IIRC the author refused to do so for compatibility with XEmacs).
            'append)

which is quite confusing in that it requires appending to achieve the expected effect (whereas, normally, the prog-mode-hook will always run before any functions in the derived mode's hook). Perhaps we could change where spacemacs/run-prog-mode-hooks is called to avoid this situation more generally?

DvdMgr commented 6 years ago

That explains why the hook didn't seem to work when I was toying with it, nice to know!

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!