News for hackers. Stuff that matters.
Re:Compiler Errors for Humans (2015) by renox on Thursday November 24, 2022 @02:00PM (#33735029)
I still wonder why editors don't understand line numbers on the CLI <editor> file:5

The editor should try to find if 'file:5' exist and open it if so, if it doesn't it should try to open 'foo' and then go to line 5.

Sounds sensible no? But I don't know any editor which does this.

Re:Compiler Errors for Humans (2015) by euiq on Thursday November 24, 2022 @02:33PM (#33735331)
Visual Studio Code does this (see "File links"): <https://code.visualstudio.com/docs/terminal/basics#_links>
Re:Compiler Errors for Humans (2015) by renox on Thursday November 24, 2022 @05:09PM (#33736798)
I don't think it works from the CLI: code <file>:5 doesn't do what's expected.
Re:Compiler Errors for Humans (2015) by Measter on Friday November 25, 2022 @06:09AM (#33741284)
You have to use the `-g` command line option: `code -g <file>:<line>`
Re:Compiler Errors for Humans (2015) by renox on Friday November 25, 2022 @11:59AM (#33744351)
Thanks I didn't know this.
Re:Compiler Errors for Humans (2015) by 1-more on Monday December 05, 2022 @12:45PM (#33868909)
huge, tysm
Re:Compiler Errors for Humans (2015) by oftenwrong on Thursday November 24, 2022 @02:42PM (#33735413)
vim does:

    vim file +5
Re:Compiler Errors for Humans (2015) by renox on Thursday November 24, 2022 @05:07PM (#33736785)
But compiler error messages are file:5 so this isn't good enough.
Re:Compiler Errors for Humans (2015) by imran-iq on Thursday November 24, 2022 @06:11PM (#33737265)
That's why you have `:make` which uses `errorfmt` to populate your quickfix list, which is covered in the help `:h make`
Re:Compiler Errors for Humans (2015) by renox on Friday November 25, 2022 @01:57AM (#33739958)
I'm not sure if you're joking or not but if you're not: I usually don't call the compiler from my vim session..
Re:Compiler Errors for Humans (2015) by imran-iq on Saturday November 26, 2022 @06:28AM (#33751808)
Right but if you want to edit and fix files that failed compilation, using `:make` and the quickfix list is the vim way of doing it
Re:Compiler Errors for Humans (2015) by matsemann on Thursday November 24, 2022 @03:53PM (#33736107)
JetBrains products do this for lots of stuff if you use the built in terminal to launch stuff or their runner.
Re:Compiler Errors for Humans (2015) by masklinn on Thursday November 24, 2022 @04:29PM (#33736450)
> The editor should try to find if 'file:5' exist and open it if so, if it doesn't it should try to open 'foo' and then go to line 5.

Opening a file is often done in creation, and `file:5` is a perfectly valid filename, so it's a bit debatable for a default.

OTOH in Emacs you should be able to define a find-file-not-found-functions hook[0] and implement whatever fallback you want. I assume `emacs <file>` calls `find-file` after it's initialised the editor itself.

[0] https://www.gnu.org/software/emacs/manual/html_node/elisp/Vi...

Re:Compiler Errors for Humans (2015) by renox on Thursday November 24, 2022 @05:11PM (#33736816)
> Opening a file is often done in creation, and `file:5` is a perfectly valid filename, so it's a bit debatable for a default

You're right, but even as an option I think it'd be nice.

Re:Compiler Errors for Humans (2015) by Measter on Friday November 25, 2022 @06:14AM (#33741310)
> Opening a file is often done in creation, and `file:5` is a perfectly valid filename, so it's a bit debatable for a default.

It gets even more fun on Windows! Giving a filename of `foo:5` can result in a file called `foo` with an alternate datastream called `5`.

Re:Compiler Errors for Humans (2015) by LtWorf on Thursday November 24, 2022 @06:18PM (#33737309)
It works with kwrite/kate/kdevelop.
Re:Compiler Errors for Humans (2015) by yakubin on Thursday November 24, 2022 @07:17PM (#33737648)
That works in Emacs compilation buffers. You can also define custom patterns to match the output formats of different compilers.