Closed ignacio-casso closed 3 months ago
Like many other parts of Forge, this area also received some heavy refactoring over the last few months. I've concentrated on paying of technical dept in core abstractions and the fine-tuning on top of that isn't quite done yet. (Over the next two weeks I will finish the last core refactoring and then I plan to do about two weeks of fine-tuning, before I create a release.)
Regarding
forge-repository-at-point
, I'm not sure how it worked before, but I think it's broken. I expect it to work in any file belonging to a repository or at least in the Magit buffer, but it always tells me that there is no repository at point. So I think it does not work andforge-browse-this-repository
does not work either.
As the name suggests, this returns the repository at point. There is no repository at point in a file visiting buffer, so here that returns nil. (Well okay, there may be a file-name at point, which could be resolved to a repository, but this function ignores that, as it is only intended to work in magit-mode
derived buffers, and some tabulated-list-mode
derived buffers.)
The two functions you might want to use instead are forge-current-repository
and forge-get-repository
, the workhorse.
Since the fine-tuning is still two weeks of, here's what you probably need:
(browse-url (forge-get-url (forge-get-repository :stub)))
forge-browse-this-repository
should probably behave like that (except it should also use forge-repository-at-point
), but I'll have to think about that some more in two weeks (e.g., should forge-current-repository
also get a demand
argument?).
I recommend you read the short implementations of forge-current-repository
and forge-repository-at-point
, and the docstring of forge-get-repository
.
Thanks for your advice! I will try with that for my function.
Regarding forge-repository-at-point
:
I expect it to work in any file belonging to a repository or at least in the Magit buffer, but it always tells me that there is no repository at point.
it is only intended to work in magit-mode derived buffers
Well then it should work in the Magit status buffer right? Because I tried using forge-browse-this-repository
there and it didn't work, it also says "No repository at point". Anyway, I always use forge-browse-repository
which still works fine, it was just to let you know. Thanks!
it is only intended to work in magit-mode derived buffers
Well then it should work in the Magit status buffer right?
There operative term is at point. The fact that it only works in magit buffers is an additional restriction, which could, and might be, lifted. But this function and other forge-...-at-point functions will always just return the thing at point, that's their purpose. The forge-current-... functions were created to handle the "the thing at point, or if there is no thing at point, then fall back to the thing the buffer as a whole is about" case.
Hi!
I upgraded all my Emacs packages a few days ago, I'm not sure what Magit version I was using before, but now I'm using 20240415.1557. Since then,
forge-repository-at-point
and a custom function I had no longer work.Regarding
forge-repository-at-point
, I'm not sure how it worked before, but I think it's broken. I expect it to work in any file belonging to a repository or at least in the Magit buffer, but it always tells me that there is no repository at point. So I think it does not work andforge-browse-this-repository
does not work either.I realize this while trying to debug my custom function, which is the one I really care about. It closely related, so maybe the underlying issue is the same. It relies on Magit internals, which I understand that could change at any moment, so I don't expect you to fix anything nor try to debug it (I haven't even tried myself yet). My hope is that fixing the other issue will fix this one automatically or give me some insights about how to fix/adapt my function without me having to invest too much time in it.
I'll describe the issue here anyway, in case you find it useful or know what happens at first glance or want to share any advice about it. The function tries to open a link in Github for the file and line at point, and the code is the following:
It fails when trying to get the repository url, with the following trace:
Thanks!