3 ms·
No, not sarcastic at all. It never occurred to me that we could have a simple rich-text rendering for code. For example, render code in html, and strip all tags
by akkartik 10y ago
No, not sarcastic at all. It never occurred to me that we could have a simple rich-text rendering for code. For example, render code in html, and strip all tags before passing through to the compiler. Why don't we do this?!
- smitherfield 10y agoBut that or something along the same lines is how syntax highlighting is typically implemented.
- akkartik 10y agoSyntax highlighting is nothing like that. It's one-size-fits-all. All types/keywords/whatever get the same color. It doesn't support font changes. If I was to hack this into say Neovim, I'd leave color alone and focus on just wysiwyg markup for font size/style. Imagine being able to bold the key call inside a function that does all the important work.
- TeMPOraL 10y ago> Syntax highlighting is nothing like that. It's one-size-fits-all. All types/keywords/whatever get the same color. It doesn't support font changes. That's if you have a crappy editor. Emacs supports font changes for syntax coloring since... forever? ;). Here is a test I did just now: http://i.imgur.com/Xrgaixu.png http://i.imgur.com/Xrgaixu.png
- akkartik 10y agoNice![1] What happens when you quit and restart? [1] No need to get personal, though :p
- TeMPOraL 10y agoDidn't mean to sound personal - I was just involuntarily baiting the editor war discussion ;). > What happens when you quit and restart? I'd lose the changes because I applied them only to the runtime configuration. It'd be a few seconds more of work to save them permanently to my configuration though. In general, Emacs implements syntax highlighting by applying various "faces" to the highlighted parts. Those faces are highly customizable - including font foundry/family, various sizes, slant, as well as various decorations, foreground & background colors, etc. It has no problem rendering multiple fonts simultaneously (which is actually pretty useful if you're dealing with Unicode characters - your typical programmer's font won't have glyphs for many Unicode characters, so you can set "fallback fonts" for those). To de-bait the editor war trap, I think Eclipse can also pull that off, but I've left the only instance I have at work so I can't confirm it now :). --- EDIT: Crap, I think I misunderstood you. Did you mean "annotating" code with temporary style changes, especially in a semantic way? If so, I don't know of any editor that would support it out-of-the-box. In Emacs, you could probably hack your way around this with temporary font-locking (aka. adding an on-the-spot syntax highlighting for a particular symbol, and applying all the face-configuration-magic I described earlier), which I sometimes do when digging through log-files or grep results - there's a family of functions like "highlight-line-matching-regexp" or "highlight-symbol-at-point" with which you can quickly assign such highlights (and then there's a command that will write out all highlights in the format that you can save as a file-comment so that Emacs will reapply them the next time you open that file). But this is a hacky solution, IMO. This also brings me to my observation that there's literally zero tools out there for reading code. Something I'd love to change, and I keep gathering ideas, but I sadly lack time ATM to make even a proof-of-concept.
- akkartik 10y agoI have no doubt that you can apply various decorations to text, but that is also the part relatively less interesting to me. I'm more interested to see in what format you would save emacs's runtime configuration that would allow it to embiggen just one '&rest' in a file. Can you show an example of what this elisp would look like? Markup seems the most natural approach to me, to avoid issues with files getting renamed, etc.
- andrewchambers 10y agoThat's sort of what literate programming does.
- akkartik 10y agoYes, certainly a connection to Literate Programming there. Probably why I like the idea (http://akkartik.name/post/wart-layers http://akkartik.name/post/wart-layers). That said, I think wysiwyg is a huge deal here (http://akkartik.name/post/literate-programming http://akkartik.name/post/literate-programming) because it makes the difference between maintaining a document for others vs yourself.