💾 Archived View for alltext.umaneti.net › emacs.gmi captured on 2023-03-20 at 17:25:47. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

➡️ Next capture (2023-09-28)

-=-=-=-=-=-=-

GNU/Emacs and Gemini

Gemini and Org mode

Improve some default settings and keybinding of this Gemini browser.

(with-eval-after-load 'elpher
  ;; Remove trailing whitespace warnings
  (add-hook 'elpher-mode-hook
	    #'(lambda () (setq-local show-trailing-whitespace nil)))

  ;; (elpher-address-to-url (elpher-page-address elpher-current-page))
  (define-key elpher-mode-map (kbd "b") #'elpher-bookmark-current)
  (define-key elpher-mode-map (kbd "f") #'elpher-jump)
  (define-key elpher-mode-map (kbd "G") #'elpher-go-current)
  (define-key elpher-mode-map (kbd "k") #'(lambda () (interactive)(quit-window t)))
  (define-key elpher-mode-map (kbd "p") #'elpher-root-dir)
  (define-key elpher-mode-map (kbd "v") #'elpher-info-link)
  (define-key elpher-mode-map (kbd "<delete>") #'elpher-back)
  (define-key elpher-mode-map (kbd "DEL") #'elpher-back))

Associate gemini, gopher and finger org links with elpher.

;; ‘thing-at-point’ is a lib used by mu4e for exemple
(with-eval-after-load 'thingatpt
  ;; This list already support gopher scheme
  (add-to-list 'thing-at-point-uri-schemes "gemini://"))
;; Make mu4e aware of the gemini world
(with-eval-after-load 'mu4e-view
  (setq mu4e~view-beginning-of-url-regexp
	"\\(?:https?\\|gemini\\|gopher\\)://\\|mailto:"))

;; Finally make gemini, gopher, etc. open with Elpher
(setq browse-url-browser-function
      #'(lambda (url &rest args)
	  (let ((scheme (downcase (car (split-string url ":" t)))))
	    (if (member scheme '("gemini" "gopher"))
		(elpher-go url)
	      (browse-url-default-browser url args)))))

(defun elpher-org-export-link (link description format protocol)
  "Export a LINK with DESCRIPTION for the given PROTOCOL and FORMAT.

FORMAT is an org export backend.  DESCRIPTION may be nil.  PROTOCOL may be one
of gemini, gopher or finger."
  (let* ((url (format "%s:%s" protocol link))
	 (desc (or description url)))
    (pcase format
      (`gemini (format "=> %s %s" url desc))
      (`html (format "<a href=\"%s\">%s</a>" url desc))
      (`latex (format "\\href{%s}{%s}" url desc))
      (_ (if (not description)
	     url
	   (format "%s (%s)" desc url))))))

(defun elpher-org-follow-link (link protocol)
  "Visit a LINK for the given PROTOCOL.
PROTOCOL may be one of gemini, gopher or finger."
  (elpher-go (format "%s:%s" protocol link)))

(with-eval-after-load 'org
  (org-link-set-parameters
   "gemini"
   :export #'(lambda (link description format _plist)
	       (elpher-org-export-link link description format "gemini"))
   :follow #'(lambda (link _arg) (elpher-org-follow-link link "gemini")))
  (org-link-set-parameters
   "gopher"
   :export #'(lambda (link description format _plist)
	       (elpher-org-export-link link description format "gopher"))
   :follow #'(lambda (link _arg) (elpher-org-follow-link link "gopher")))
  (org-link-set-parameters
   "finger"
   :export #'(lambda (link description format _plist)
	       (elpher-org-export-link link description format "finger"))
   :follow #'(lambda (link _arg) (elpher-org-follow-link link "finger"))))

Gemini mode

I maintain a little fork of gemini-mode to improve preformatted or quote blocks, and make links active (open either in elpher or edit targetted file).

My fork of gemini-mode.el (HTTPS)

--

📅 dernière modification le mardi 8 décembre 2020 à 09:37

📝 Écrit par Étienne Deparis avec GNU/Emacs 27.2 (Org mode 9.4.6) et publié avec Fronde 0.3.2