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.
text/gemini; lang=en
This content has been proxied by September (3851b).