š¾ Archived View for apintandaparma.club āŗ ~ajc āŗ log āŗ 2020-08-14.gmi captured on 2024-05-26 at 14:45:23. Gemini links have been rewritten to link to archived content
ā¬ ļø Previous capture (2020-09-24)
-=-=-=-=-=-=-
Iāve loved Emacs ever since the early 90s when I got some work over the Christmas break during university. Iād been madly hoovering up everything I could learn about Unix at the time, and when I first met a few of the people in the company they asked me which editor I used. I quickly replied āemacs!ā and things continued from there. In the early 2000s I moved to using a Mac - my first laptop, and it really was the best Unix one you could get at the time. I tried embracing the possibilities afforded by the converged desktop environment, leaving behind a bunch of Emacs-based services. I tried VoodooPad for storing notes. I switched from Gnus to Apple Mail.
I couldnāt quite let go, though. Emacs still hung around for minor tasks, mainly as a mere text editor. I tried TextMate like all the cool Mac kids, but it just wasnāt the same. Eventually I left VoodooPad behind for EmacsWiki, planner, muse (though I forget the order for these three!), and eventually org-mode which remains my primary use of Emacs - keeping a log of my work day. Orgās agenda functionaility never quite stuck, I use it just a little. Some day Iāll try and get around to org-roam.
All of that is a long way of explaining that while Iāve been in lockdown and spending a bit more spare time back on my home server, especially in a terminal rather than at a full desktop, Iāve been spending lots of time polishing my Emacs config, and so when I started playing with Gemini it seemed natural to do it via Elpher.
I happened to see wgreenhouse ask in #gemini about teaching ābrowse-urlā to open gemini links, so with a day off work and a spare hour or two this morning I gave it a shot. Hereās my initial attempt, which does a bunch of useful stuff for me relating to gemini / gopher URLs:
(setq browse-url-browser-function '(("^\\(gemini\\|gopher\\):" . ajc/elpher-browse-url) ("." . ajc/browser-function))) (defun ajc/elpher-browse-url (url &rest args) (elpher-go url)) (defun ajc/browser-function (url &rest args) (interactive (browse-url-interactive-arg "URL: ")) (if (display-graphic-p) (browse-url-default-browser url args) (eww-browse-url url args))) (add-to-list 'thing-at-point-uri-schemes "gemini://") (defun ajc/follow-org-gemini-link (link) (elpher-go (concat "gemini:" link))) (defun ajc/follow-org-gopher-link (link) (elpher-go (concat "gopher:" link))) (org-link-set-parameters "gemini" :follow 'ajc/follow-org-gemini-link) (org-link-set-parameters "gopher" :follow 'ajc/follow-org-gopher-link)
I hope itās useful - Iāll continue tweaking, of course.
I also noticed acdw asking a little later on about screwing elpher into xdg-open so we can open gemini URLs in it from outside Emacs. I noticed this piece of news via Sacha Chuaās weekly emacs updates:
ā¦which I suspect will provide some hints, as will this, which Iād been fiddling with a weekend or two ago:
https://github.com/sprig/org-capture-extension
but Iāll give this one a go laterā¦
Update: looks like I was a bit too late!
gemini://gemlog.blue/users/acdw/1597354552.gmi
still, that doesnāt look too different to what I worked out on my own, so Iām happy.
Another update: hereās a first go at āorg-store-linkā support - it only fetches the page URL, not the title, though
(org-link-set-parameters "gemini" :follow 'ajc/follow-org-gemini-link :store #'org-elpher-store-link) (org-link-set-parameters "gopher" :follow 'ajc/follow-org-gopher-link :store #'org-elpher-store-link) (defun ajc/elpher-get-page-url (page) "Return the URL representation of address of PAGE." (let ((address (elpher-page-address page))) (if (elpher-address-special-p address) (error (format "Cannot represent %s as URL" (elpher-page-display-string page))) (elpher-address-to-url address)))) (defun ajc/elpher-get-link-url () "Return the URL of item at point." (interactive) (let ((button (button-at (point)))) (if button (ajc/elpher-get-page-url (button-get button 'elpher-page)) (error "No item selected")))) (defun ajc/elpher-get-current-url () "Return the URL of the current page." (interactive) (ajc/elpher-get-page-url elpher-current-page)) (defun org-elpher-store-link () "Store a link to a gemini page." (when (memq major-mode '(elpher-mode)) (let* ((link (ajc/elpher-get-current-url)) (type (url-type (elpher-address-from-url link))) (description (format "%s page %s" type link))) (org-link-store-props :type type :link link :description description))))
Obviously some of this stuff could/should fold back into the elpher source instead. Iāll look into how best to do that, and see if I can work with Tim Vaughan to make it so. The latter stuff might make a good patch or addon for org-mode.