Syntax highlighting is activated on a site-by-site basis.
Should we have syntax highlighting for Emacs Lisp by default? I don't expect the presence of Emacs Lisp to be correlated with tags: any question can be answered by “put this little chunk of code in your .emacs
”. However code blocks are sometimes used to present buffer contents (example).
Ideally there would be a heuristic: in the absence of a magic comment, highlight for Emacs Lisp if the code block starts with one of the characters `(;'
(skipping leading whitespace), otherwise don't highlight. I don't know if this is possible with the current code; treat this answer as a feature request.
I had a go at extracting all code blocks from the site (questions and answers), classifying them according to their first non-whitespace character, and visually inspecting each category.
# 31 1 Lisp
' 3 all Lisp
( 342 all but 2 Lisp
; 30 all Lisp
[ 14 none Lisp
` 4 all Lisp
other 199 1 Lisp
The Lisp snippet beginning with #
is #(…)
syntax. The “other” Lisp snippet begins with ...
. The two non-Lisp blocks beginning with (
are part of a LaTeX error log and a regular expression (not in Emacs syntax). The non-Lisp blocks are as you'd expect a mix of content with no coherent theme, mainly anything that one could edit (LaTeX, C, Org headers, ASCII art tables, etc.).
22 Lisp blocks start with whitespace. They're probably over-indented but I didn't investigate further.
Thus highlighting blocks as Lisp by default would work about 63% of the time. The heuristic above would work with a very high success rate: 0.5% false positive and 1% false negative (my original proposal of just (;
would miss about 2% of the blocks to be highlighted).
Conclusion: we should have syntax highlighting. Preferably with the heuristic above, otherwise with Elisp syntax by default.
I haven't studied the correlation with tags. I don't expect the tags to give much information since just about any question could have a Lisp snippet in an answer.