I find myself often opening an issue in the Guix 'R Us issue tracker to package something new:
My workflow is the following more or less:
I come across a cool package on GitHub or some other forge that would be a good candidate for packaging in the Guix 'R Us channel so I:
- Copy the link
- Open a new tab
- Navigate to guixrus — sourcehut todo
- Create a new issue
- Give the issue the title of the package
- Paste the package’s home page url in the issue description
- Tag the issue (e.g. cargo-build-system, python-build-system, etc.)
- Submit the issue
I’d like to be able to just press a keybind and do all of the above 8 steps in one go.
I guess I need to look into a GraphQL library for CL and then extend nyxt with it?
I guess I need to look into a GraphQL library for CL
Normally I like Shinmera’s work, but the README for cl-graphql makes it seem like it’s alpha quality. gql looks like your best bet these days, but I haven’t looked too extensively. It’s Scheme, but there’s a CHICKEN egg for the SourceHut API, although now that I think of it, I don’t think it’s GraphQL…
I don’t want to discourage you from working on this, but wouldn’t it be better to contribute to existing solutions for this on Emacs’s side? Forge’s sr.ht integration is partial but it’d be amazing to be able to interact with repos in the same way as with GitHub’s. I also find srht.el quite handy for basic operations, albeit being based on sr.ht’s REST API.
I may be out of context here, but for most of those actions (except maybe 7), you’d only need access to the page, and Nyxt can work with that. The simplest approach to the problem (and the one I’d likely take) would be to hack up a command to scrape the info from the original repo and then go to SourceHut to fill the issue page with the relevant info. Here’s a small snippet for how it might look:
(define-command open-guixrus-issue ()
(let* ((buffer (current-buffer))
(url (url buffer))
;; I don't have a SourceHut account, but there should be some
;; URL for new issue creation, right?
(new-issue-url (quri:uri "https://todo.sr.ht/~whereiseveryone/guixrus/newissue")))
;; Bind an action to a hook. Arguments:
;; - Hook.
;; - Argument list for a hook, in this case the sole buffer.
;; - Body of the handler/callback.
(hooks:on (buffer-loaded-hook buffer)
(when (quri:uri= (url buffer) new-issue-url)
;; `peval' is used to evaluate some Parenscript right away.
;; `nyxt/ps:insert-at` inserts the text into an element. It's
;; quite rought around the edges, so you most probably want
;; something else, but here it is, for the sake of example.
;; I tend to reproduce the initial text of the issue. See
;; for a use-case similar to yours.
(nyxt/ps:insert-at (ps:@ document active-element)
For sure, using something more structured, like GraphQL, is preferable to the fuzzy world of URLs and web-pages, but I find it quite tempting to work with this primordial soup anyway
Also note that, if you’re on 3.*, there’s a part of the manual (
nyxt:manual#headless-mode) dedicated to headless mode (unambiguously named “Headless Mode”), where you can find lots of useful things for web scraping and routine automation.
EDIT: Link to the manual.