reddit / emacs

c++ programming screenshot

ChristopherHGreen · 2022-08-25 15:26
I post a lot about math programming in c++ on twitter, and got a query about my code screenshots, wondering about their unique look. So I did some emacs promotion and posted this one. Sorry about the twitter damage to the image quality - this code is quite large and extremely readable on my big high DPI monitors: ​ ​ https://preview.redd.it/9w86olh2ovj91.png?width=2662&format=png&auto=webp&s=a5cd32986e0bf47122d3e63d6bb6470bed5f256f
kkvi115 · 2022-08-25 15:42
that’s very interesting idea. How do you render images and math symbol in cpp mode?
ChristopherHGreen · 2022-08-25 15:58
Images: a modified version of iimage-mode math symbols: a bunch of fancy font-lock-add-keywords patterns and a touch of prettify-symbols mode.
NoisyFrequency · 2022-08-25 17:31
What's your twitter? So we can follow along =)
scroy · 2022-08-25 17:31
That's cool, but do you really prefer a variable width font? I would do this for markdown or maybe org mode, but not code. It looks much harder to read.
sammymammy2 · 2022-08-25 18:21
Reminds me of Fortress: https://youtu.be/EZD3Scuv02g?t=638
ChristopherHGreen · 2022-08-25 18:59
It looks great and is super readable. I can't imagine going back to a fixed-width font. The double-compressed screenshot doesn't do justice to the way it looks on my 5K ultrawide monitor. ​ Also, giving up fixed-width is kind of a requirement for using multiple fonts/sizes/styles for highlighting.
ChristopherHGreen · 2022-08-25 19:00
https://twitter.com/ChrisGr93091552
mwzx · 2022-08-25 19:59
What is the font? I've became a heavy user of Lucida Grande for coding since I've read Bjarne Stroustrup's book.
AlanYx · 2022-08-25 20:43
I love how opinionated this configuration is and how it's intentional not gratuitous, like the triple stacked bars for "==" and the arrow for assignment. Do you also use org-mode? Do you have a similarly interesting configuration for that?
ChristopherHGreen · 2022-08-25 21:27
Yeah, I certainly never mix up assignment and equality comparison with that choice!
BecomingCass · 2022-08-25 21:33
I see people talking about configs being "opinionated" on here and stackexchange all the time, but Ive never seen anyone define that in an emacs context. What does it mean here? Im real new to doing anything other than picking a dark theme and using emacs like every other text editor so Im trying to figure everything out
ChristopherHGreen · 2022-08-25 21:40
The main one is Tahoma but I use a different one for block comments
CorysInTheHouse69 · 2022-08-25 22:13
I don’t think I’ve ever been blow away by an editor screenshot before. Do you have the config files by chance? I’d love to give them a look
mwzx · 2022-08-25 22:15
Is your Emacs configuration available somewhere? I would love to see it and replicate the theme and fonts. Loved it.
AlanYx · 2022-08-26 00:58
It basically means boldly making a design decision on something where there’s bound to be a strong difference of opinion. This configuration has a lot of interesting decisions like that, especially for C++ instead of something like maybe Haskell.
XMLHttpWTF · 2022-08-26 01:38
this is pretty remarkable. i could never work this way, but it's an interesting approach, just hope you clang-format if you're working with others!
ChristopherHGreen · 2022-08-26 02:30
That's why these are all display hacks. My co worker uses visual studio and we have a coding standard and identical indentation settings., no problems. Even most of the comment decorations are things we use for doxygen docs. I demo that it lines up the comments for me, but I comment using the standard esc-; sequence so outside of that example, my comments line up fine outside of emacs.
scroy · 2022-08-26 03:41
You do you, and may the sexps flow freely
arthurno1 · 2022-08-26 09:31
That looks pretty awesome. For me, using math symbols in programming is one of those things like when I see a really cool tattoo or some really extravagantly painted car or house: very cool, I love it, but wouldn't like to have it myself :). However, there is *a lot of potential* in doing something similar as org-babel does, like you do with images embedded in comments, evaluating code and displaying results etc. I think. But nice work indeed. I think I have seen in past years some other people's similar cool setups using math symbols for loops, and other stuff, but I never really got hooked on that, so I don't have any to paste straight out of my head, but if you dig around, you might find some other nice ones.
YesIAmFunAtParties · 2022-08-26 10:21
This is beautiful. I couldn't use it but that doesn't matter. You are using the shit out of your computer. Long live Emacs.
deaddyfreddy · 2022-08-26 10:38
What's the reason to use C++ for math programming instead of FP languages?
pathemata · 2022-08-26 12:50
On the topic of C++ environment. Anyone using `eglot` did something to make `eldoc` looks nicer? I'm using a library with heavy math documentation and wonder if it's possible to render the latex expressions.
[deleted] · 2022-08-26 14:52
[deleted]
ChristopherHGreen · 2022-08-26 14:54
I'm afraid they'd be too messy - I've been coding c++ in emacs for >20 years and my .emacs file shows it :-).
ChristopherHGreen · 2022-08-26 15:09
I gravitated to this (constantly refined) config for a few intentional reasons: \- I felt that doxygen docs were annoying - I wanted to be able to make pretty header files with good docs that I could just view in my IDE, since it already has things like jumping to symbol etc. I wanted to see if I could do a kind of "semi-literate" programming by having good ways to display descriptive text in-editor. Thus all of the different comment types I have. Still working on that - one thing missing is some way to attractively fill-justify text with proportional/mixed fonts. \- The human visual system is capable of processing a lot more symbols than just simple alphanumerics, and I wanted to take advantage of that by using a bunch of unicode characters,. Since I'm the only one who sees it and I'm programming for the long term, a small learning curve doesn't matter. \- I thought it would be nice to have my code look more like the kind of pseudo/math code used in publications so that I could publish code in papers as-is. \- I was tired of my previous typical heavily-colorized syntax highlighting. I thought it was unnatural for text to be in rainbow colors so wanted to use less color variation as opposed to things like bolding, font style and size. I also decided that having all the highlight colors is the same thing as having no highlighting - everything ends up emphasized equally. I mainly want to make the really important things (symbol names and operations on them) stand out.
ChristopherHGreen · 2022-08-26 15:21
c++ is the standard in the games industry for many reasons.
mwzx · 2022-08-26 15:30
Is the theme available somewhere? I tend to dislike dark-background themes and yours is so clean, so not-in-your-face. I'm really impressed by all this.
deaddyfreddy · 2022-08-26 15:32
did anyone mention the games industry?
ChristopherHGreen · 2022-08-26 15:41
Sorry I should have stated that code I write is for games or other real-time game-like things, thus c++.
ChristopherHGreen · 2022-08-26 16:45
I think its too messy and tied to the rest of my .emacs, and also my company's coding standards. The interest makes me think about cleaning it up into something that could be consumed by others though.
mwzx · 2022-08-26 17:22
I would love to use it.
KittyKutie · 2022-08-26 18:34
I don't think I've seen that lambda macro before, surprisingly.
AresAndy · 2022-08-26 19:14
I'm assuming that is a project where org-mode tangling is not an option. It still looks like this is requiring a level of effort that is superhuman. Major kudos But it is worth it. I wish I could do that on my projects at work, but alas I'm surrounded by non-emacs and non-vim users, so no tangling. And having org-mode makes me feel like doxygen is a bad compromise I envy you 😂
quote-only-eeee · 2022-08-27 00:54
Very cool! How do you get the comments to line up despite proportional fonts? Is it a package?
ChristopherHGreen · 2022-08-27 01:49
The little used "align-to" text property :)
Null-A · 2022-08-29 06:01
\+1 would love to see this shared, even just a gist that doesn't work
GJDitchfield · 2022-08-29 19:28
If you haven't tried it, you really should. Give it 48 hours. I switched my C++ editor font to Noto Serif.