reddit / emacs
alphapapa/obvious.el: Who needs comments when the code is so obvious
github-alphapapa · 2022-07-21 20:06
ireallywantfreedom · 2022-07-21 21:03
Any timeline on notobvious.el?
agumonkey · 2022-07-21 21:19
too many users
cerka · 2022-07-21 21:19
Expected shortly after Microsoft releases its new product, GitHub Commentpilot /s
github-alphapapa · 2022-07-21 21:32
I think that's already been released as `alphapapa-mode`. ;)
whudwl · 2022-07-21 23:00
you have mastered package naming!!
MmmCurry · 2022-07-21 23:06
Nice. I remember using [hide-comnt.el](https://www.emacswiki.org/emacs/hide-comnt.el) for this in the past. Your taste in naming and use of overlays are better, and they definitely don't do fringe indicators!
stayclassytally · 2022-07-21 23:31
M-x describe-whats-going-on-here
TeMPOraL_PL · 2022-07-21 23:32
I'd like a mode that does the reverse, please. Almost all of the code I deal with is extremely underdocumented.
cellular--automaton · 2022-07-22 00:42
Brilliant package. So, are these packages are result of your own experiences? Like, you are doing something and feel like a certain improvement/service would be nice - so you just go ahead and create an entire package for it ?
Hooxen · 2022-07-22 02:38
neat!! but yes all the codebases i work with have the opposite problem - zero comments zero documentation 🤣
github-alphapapa · 2022-07-22 03:07
For a nominal fee, I'll be happy to document your code. ;)
github-alphapapa · 2022-07-22 03:09
Haha, thanks. There's also Anders Lindgren's `nocomments` package, but it works differently in that it replaces comments with whitespace. It didn't seem practical to patch it to do both that and hide them completely, so I used his example to write mine.
github-alphapapa · 2022-07-22 03:09
Haha, thanks. :)
github-alphapapa · 2022-07-22 03:14
Yes, that's usually how it goes. I tend to write a fair amount of comments in my packages, and sometimes that can make it hard to see the "shape" of code when I return to it much later (the screenshot in the readme is a good example of that). So it occurred to me that being able to hide the comments could be helpful. I found the `nocomments-mode` package, but it didn't quite do what I wanted, and it didn't seem practical to modify it to do that, so I studied its code to help me write `obvious-mode`. It took a few hours, because `font-lock` isn't easy to work with (and mistakes can lead to Emacs locking up), but I eventually got it working. Then it's just a matter of tidying up the code and posting it on GitHub. "Packaging" in Emacs is very simple.
_viz_ · 2022-07-22 04:45
Please document the Quail library. :P
ideasman_42 · 2022-07-22 05:11
I've written am approximate opposite package to this - [doc-show-inline](https://codeberg.org/ideasman42/emacs-doc-show-inline) - for projects that maintain doc-strings in their declarations.
emacs_expert · 2022-07-22 07:25
Very interesting idea, but is it only for C/C++? Doesn't seem to work in any of the languages I tried.
ideasman_42 · 2022-07-22 07:35
It should be language agnostic - as long as they support \`xref\`, however it depends on being able to lookup the declaration and then find some comment above it, so while I don't see why it wouldn't be able to work with other languages, I didn't try them.
What languages did you try?
CGenie · 2022-07-22 09:50
```
M-x wtf-thing-at-point
```
TeMPOraL_PL · 2022-07-22 11:07
I might bring it up with my employer :).
Seriously though, in my personal opinion, it would be absolutely worth it for software companies to hire extra developers and task them with commenting the code properly. That is, such a developer would have to comprehend the company's codebase, then document it properly (in code and outside of code), and then maintain those comments (including, but not limited to, by docking points for lack of comments in new code during code review). Theoretically, this is part of every dev's job responsibilities - in practice, almost nobody does it.
emacs_expert · 2022-07-22 11:11
> What languages did you try?
`rust-mode`:
> Doc-Show-Inline mode enabled in current buffer
(user-error "Doc-show-inline: ignoring request for file read") [2 times]
`typescript-mode`:
> (user-error "Unable to find symbol in current document")
`go-mode`:
> (user-error "Doc-show-inline: ignoring request for file read")
Maybe I'm doing something wrong -- I'm trying `M-x doc-show-inline-mode`. I want it to work, it's a really neat idea haha.
ideasman_42 · 2022-07-22 11:33
I'm not sure how these would work, don't go & rust document their functions in the same files as the implementations?
github-alphapapa · 2022-07-22 16:36
Agreed!
github-alphapapa · 2022-07-22 16:37
Cool! Emacs has it covered both ways. :)
emacs_expert · 2022-07-22 16:45
I guess I misunderstood! I thought that this would show inline docs above each function usage. Thought it'd be a neat thing to toggle on/off.
ideasman_42 · 2022-07-23 03:31
Ah, it could fairly easily do that (although it would quickly get noisy and you'd probably want to keep it off most of the time) - but no, that's not the intended purpose.
cellular--automaton · 2022-07-23 17:41
Hah! Nice.