Note that there are some explanatory texts on larger screens.

plurals
  1. POSyntax highlight for perl in Emacs is broken, is there a fix?
    primarykey
    data
    text
    <p>I'm a perl programmer and a new emacs user. I'm under Windows, using cperl-mode for editing perl. Emacs version is 24.2.1. Here's a screenshot with some sample code:</p> <p><a href="http://breqwas.net/dropbox/perlsyn_emacs.png" rel="nofollow noreferrer">http://breqwas.net/dropbox/perlsyn_emacs.png</a></p> <ol><li>Obvious bug: it highlights arrays, hashes and non-quoted literal values in ( a => "b" ) style lists <i>inside comments</i></li> <li>One more bug: it highligts the first word in a regular expression as an array because of non-default quote symbol</li> <li>Not a bug, but looks weird: it highlights arrays and hashes any time when they are used (even in comments, huh), but scalars are highlighted only when declared</li> <li>Not a bug, but looks weird: same story with functions: highlighted when declared, not when called</li> <li>Not a bug, but looks weird: why do "print", "say" and "system" have different colors?</li></ol> <p>I could keep going, but I hope that explains the word "broken" pretty well.</p> <p>Then I learned the magic C-u C-x = key combination, which shows, among other stuff, the text properties for the text under the cursor, hoping to make a better coloring scheme of my own. At this point it started making even less sense.</p> <p>"print" has <i>cperl-nonoverridable-face</i>. "die" has <i>font-lock-keyword-face</i>. Meanwhile, both are functions and can be (and often are) overrided. "system" has <i>font-lock-type-face</i>. Why? Function declarations have <i>font-lock-function-name-face</i> - that's OK, but so do the arguments of "use". Why? Function calls and scalars don't have face property at all and can't be highlighted. Why? Etc, Etc. Again, I could keep going.</p> <p>Is there a way to fix all that? Is there some config where I can remap lexical units to some other font-faces, or some other way to make the syntax highlight less crazy?</p> <p>To avoid the "perl is unparsible" talk, here's a screenshot of the editor I'm migrating from, with the very same code: <a href="http://breqwas.net/dropbox/perlsyn_pn.png" rel="nofollow noreferrer">http://breqwas.net/dropbox/perlsyn_pn.png</a>. Looks much more reasonable. </p> <hr> <p><strong>Upd:</strong> By now (3 weeks after asking this question here) I did not find a cure. All perl programmers who use emacs I know just ignore these problems. No better perl highlighters for emacs seem to exist. Reading cperl-mode docs provides some explanations (the choice of faces for various elements seems less crazy now), but does not provide any answers. I wrote an email to cperl-mode maintainer with these questions and some more digging I did, but got no reply.</p> <p>Yep, you got that right: seems like emacs community was not able to make a good perl syntax highligting in 25 years that perl is around. That's a sad story.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload