Elpher, Random Links, and Queuing Links (publ. 2024-10-10)

I recently made the switch from Lagrange to Emacs Elpher as my go-to gemini client.

Elpher: a gopher and gemini client for GNU Emacs

Elpher is a beautiful client and, very importantly, provides great integration into the Emacs interface. This includes nice things like completion for all the links on a page — the keybinding is "m" on my system.

Elpher screenshot (with phosphor theme)

A major concern that was holding me back on the switch: there is some quirk in the design of the Emacs networking library — I don't understand all the details — that prevents one from using elpher's SOCKS support and certificate verification at the same time. You have to pick one or the other. SOCKS support is needed to route the traffic through the TOR daemon. There is a bug report open about it already. I decided, finally, that I wanted to be using Elpher badly enough that I would just use it without TOR, while keeping the certificate verification.

Another issue was switching from a tabbed to a non-tab paradigm. I don't really like tabs, frankly, but with Lagrange I could use my elisp to open up a bunch of random links (from the Kennedy database) into separate tabs in Lagrange, and then work through them quickly that way. Also, if I wanted to investigate a link on some page, but not just yet, I could open the link in a background tab.

Over the lunch break, I acheived a similar functionality in Elpher, using a FIFO queue of links. First of all, I slightly modified my functions for getting the random links, so that they are put into the queue, instead of being immediately opened in a browser:

(defvar gemini-link-queue nil)

(defun queue-gemini-links-from-buffer ()
  "Finds all the gemini links in the current buffer and adds them to a \
FIFO queue."
  (interactive)
  (save-excursion
    (beginning-of-buffer)
    (while
        (re-search-forward "^=> \\([[:graph:]]+\\) " nil t)
      (setq gemini-link-queue
            (cons
             (buffer-substring
              (match-beginning 1)
              (match-end 1))
             gemini-link-queue)))))

(defun pull-random-gemini-capsules (n)
  "Pulls random capsule links from Kennedy search engine and add them to gemini-link-queue. Specify the number of links with N, or interactively. Requires the following shell utilities: gmni, grep, sort, and tail."
  (interactive "NCount: ")
  (let ((nbuff (generate-new-buffer "*random-gemini-capsules*")))
    (message "pulling data from gemini://kennedy.gemi.dev, standby...")
    (shell-command
     (concat
      "gmni -L -j always \
gemini://kennedy.gemi.dev/observatory/known-hosts \
| grep '^=>' | sort -R | tail -n "
      (number-to-string n))
     nbuff)
    (save-excursion
      (switch-to-buffer nbuff)
      (queue-gemini-links-from-buffer))))

I can run M-x pull-random-gemini-capsules to put some arbitrary number of random links in the queue. Then, I run this pop-gemini-link to pop one off and view it in Elpher.

(defun pop-gemini-link ()
  (interactive)
  (if (not gemini-link-queue)
      (message "%s" "no links in queue")
    (progn
      (elpher-go (car gemini-link-queue))
      (setq gemini-link-queue (cdr gemini-link-queue)))))

I can keep popping links until the queue runs out or I get bored.

One note: I decided to increase elpher-connection-timeout to 30 so that I had some extra time to look at the cert before actually loading the page. I could of course just hit "a" (accept permanently) immediately every time to simulate TOFU.

To replace the "background tab" idea, I have this function:

(defun elpher-queue-gemini-link ()
  (interactive)
  (elpher-copy-link-url)
  (let ((link (car kill-ring)))
  (setq gemini-link-queue
        (cons link gemini-link-queue))
  (message "%s %s" "queued" link)))

This copies the link at point to the kill ring, then puts that link into the queue. So I could queue a link, or multiple links, and then browse around the current page a bit, and then pop the link(s) back off the queue.

Incidently, this is similar to the "tour" feature implemented in the original "av-98" gemini client.

Copyright

This work © 2024 by Christopher Howard is licensed under Attribution-ShareAlike 4.0 International.

CC BY-SA 4.0 Deed


Source