1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
[[!meta title="Improving compiler diagnostics with Overlays"]]
[[!meta copyright="Copyright © 2023 Jeff Trull"]]
[[!inline pages="internal(2023/info/overlay-nav)" raw="yes"]]
<!-- Initially generated with emacsconf-publish-talk-page and then left alone for manual editing -->
<!-- You can manually edit this file to update the abstract, add links, etc. --->
# Improving compiler diagnostics with Overlays
Jeff Trull (he/him) - Pronunciation: rhymes with "hull" and "dull", IRC: jaafar, @jaafar@hachyderm.io
[[!inline pages="internal(2023/info/overlay-before)" raw="yes"]]
Overlays are a feature of Emacs that allow changing the
appearance of text while preserving its contents. They play a prominent
role in packages like org-mode, which uses them to hide or reveal custom
properties and display inline images, and magit, which uses them to
highlight diffs.
The presenter will give a introduction to the features of overlays,
demonstrating how to:
- Create and use overlays in Emacs Lisp code
- Query locations in an existing buffer to find out what overlays are
present.
He will then demonstrate a new compilation minor mode for improving the
readability of error messages, using overlays to flexibly reformat portions
of the compiler output under user control.
# Discussion
## Questions and answers
- Q: How did you draw the underbraces and overbraces?
- A: TikZ, the greatest drawing tool ever :) See
<https://tex.stackexchange.com/a/128096/105203>. I went to some
effort to match up the colors, font, and background to Emacs. I
got quite close, I think.
- Q: You've got a nice sounding keyboard. What kind is it?
- A: Sorry about that. It's an ErgoDox EZ
- Q: Do you find that the "invasive" reformatting interferes with
navigation?
- A: A bit. You can't move your cursor into the not-real buffer
text (indentation). But the original text is still visible, so
that works fine.
- Q: Can you show us the keybindings of your minor map for editing
overlays?
- A: It's C-c - and C-c + but you can change it.
- Q:Your examples were with c++, have you experimented with any other
languages? Oh, thanks for the interesting talk by the way!
- A: Other languages don't have the same unpleasant behavior :) I
say this as a long time fan of C++. But it should be possible!
- Q: Would it be possible to include overlays in the source file
itself. There are some language modes (Rust, for instance) that do
this.
- A: [someone else] Sounds like enriched-mode. [Jeff] I'm not
sure what this question means; it's the error messages that are
the big issue
- Q: What are your plans for tspew in the future?
- A: Better future-proofing and more options for formatting
- Q: What is your repository link <https://github.com/jefftrull> ?
- A: <https://github.com/jefftrull/tspew>
- Q: What IDEs do C++ programmers use? If not emacs? How do they deal
with these error messages?
- A: VSCode is quite popular, as well as CLion and also XCode. I think they simply display the error messages as is.
- Q: Have you tried to use treesitter to parse the output?
- A: I think it wants to parse an entire buffer. If I could write a
grammar for a portion of the text and point it at that, that would be
great. I could have maybe made a tsit grammar if I could have applied it to a small bit of the output
- (not the speaker): ISTM that since you set up the syntax tables to recognize <> as parens/whatever that Emacs should be able to parse the effective lists as sexps, but I'm not an expert on that
- (not the speaker) ye it's true, often you want to select what the root source node type would be an AFAIK you cannot change it
- Q: "org-mode, which uses them to hide or reveal custom properties" I thought they used buffer-invisibility-spec or something like that
- A: yes that's part of it
- do you know of they also use text properties. org code is usually pretty messy, so I don't know much about it
- A: org has been moving toward text properties but I think there is a flag that will use overlays instead (!). There's some controversy about performance that I will touch on in a bit
- Interesting, does that initiative predate the recent performance improvements by Stefan Monnier?
- A: I think so. They were known to be a problem for some time, but then that happened?
- Q: Did you use, e.g. syntax-ppss to parse the depth using the syntax table?
- A: No I tried to though... maybe there's a better way
## Notes and discussion
- The org file containing the presentation is here:
<https://media.emacsconf.org/2023/emacsconf-2023-overlay--improving-compiler-diagnostics-with-overlays--jeff-trull.org>
- Tony Aldon's Reddit post on visibility
<https://www.reddit.com/r/emacs/comments/t1r2wq/have_you_ever_wondered_how_orgmode_toggles_the/>
- Overlay performance (maybe) fixed
<https://www.reddit.com/r/emacs/comments/yg4mvt/the_noverlay_branch_was_merged_to_master_this/>
- I think I might need to change subed-waveform to use text properties instead of overlays or fix something else that I'm doing incorrectly, since the overlays get left behind when I kill text
- A: yeah you have to track them yourself
- Can you put the overlay object in a text property to track it?
- A: I don't think you would mix properties and overlays in that manner. There are overlay search functions; people typically add a property that identifies them as theirs. or you can store references in a list or something
- A: One of my reasons for doing this was frustration and people talking about how great VSCode was and I *knew* that Emacs was a good match for certain kinds of problems people don't even try to solve in IDEs
- A: I actually edited this down I know it's still a lot of detail :)
- This is really good!
- Very impressive! And well explained. Thank you.
- yeah try doing that in VSCode! yeah.
- this is slick!
- i'm not a fan of ligatures, but imho :: just begs for it
- Same, I want to see the actual thing that'll be given to the compiler/interpreter/whatever.
- That was great, showing how relatively easy it is to extend Emacs with features like that.
- From the speaker: yantar92: your help was much appreciated in the weeks I spent putting this together :)
[[!inline pages="internal(2023/info/overlay-after)" raw="yes"]]
[[!inline pages="internal(2023/info/overlay-nav)" raw="yes"]]
|