X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=c6b94ad97bb23890c2167b8ac96a0444b775437b;hp=4ae15d29f7b00dc5c6f732f18b6eebe80d6a4f23;hb=refs%2Fheads%2Fbookmarks-history;hpb=b5600b7e1b01eea2d896c00e308bafcf1f8e37e9 diff --git a/elpher.el b/elpher.el index 4ae15d2..c6b94ad 100644 --- a/elpher.el +++ b/elpher.el @@ -4,7 +4,7 @@ ;; Author: Tim Vaughan ;; Created: 11 April 2019 -;; Version: 2.9.1 +;; Version: 2.10.2 ;; Keywords: comm gopher ;; Homepage: http://thelambdalab.xyz/elpher ;; Package-Requires: ((emacs "26.2")) @@ -71,7 +71,7 @@ ;;; Global constants ;; -(defconst elpher-version "2.9.1" +(defconst elpher-version "2.10.2" "Current version of elpher.") (defconst elpher-margin-width 6 @@ -209,7 +209,7 @@ some servers which do not support IPv6 can take a long time to time-out." "Face used for html type directory records.") (defface elpher-gemini - '((t :inherit font-lock-regexp-grouping-backslash)) + '((t :inherit font-lock-constant-face)) "Face used for Gemini type directory records.") (defface elpher-other-url @@ -403,6 +403,17 @@ If no address is defined, returns 0. (This is for compatibility with the URL li ;; Cache +;; We use the following pair of hashmaps to form the cache: one +;; for the content (rendered server responses), and one for the +;; position of point within the content. +;; +;; The keys for both of these hashmaps are the page addresses, and +;; the cache persists for as long as the emacs session. +;; +;; Whether or not to use cached content is a decision made by the +;; specific renderer. Some renderers, such as elpher-render-download, +;; never cache. + (defvar elpher-content-cache (make-hash-table :test 'equal)) (defvar elpher-pos-cache (make-hash-table :test 'equal)) @@ -425,6 +436,11 @@ If no address is defined, returns 0. (This is for compatibility with the URL li ;; Page +;; In our model, a "page" merely represents a combination of a +;; display string and an elpher address. The distinction exists +;; because caching, server response acquisition, etc deal only +;; with addresses. + (defun elpher-make-page (display-string address) "Create a page with DISPLAY-STRING and ADDRESS." (list display-string address)) @@ -763,8 +779,8 @@ longer needed for this session." (cert-file (concat temporary-file-directory file-base ".crt"))) (elpher-generate-certificate file-base key-file cert-file t))) -(defun elpher-generate-permanent-certificate (file-base common-name) - "Generate and return details of a persistant certificate. +(defun elpher-generate-persistent-certificate (file-base common-name) + "Generate and return details of a persistent certificate. The argument FILE-BASE is used as the base for the key and certificate files, while COMMON-NAME specifies the common name field of the certificate. @@ -803,7 +819,9 @@ base for the installed key and certificate files." (expand-file-name cert-file)))) (defun elpher-list-existing-certificates () - "Return a list of the persistant certificates in `elpher-certificate-directory'." + "Return a list of the persistent certificates in `elpher-certificate-directory'." + (unless (file-directory-p elpher-certificate-directory) + (make-directory elpher-certificate-directory)) (mapcar (lambda (file) (file-name-sans-extension file)) @@ -1190,13 +1208,13 @@ that the response was malformed." (pcase (read-answer "What do you want to do? " '(("throwaway" ?t "generate and use throw-away certificate") - ("persistant" ?p - "generate new or use existing persistant certificate") + ("persistent" ?p + "generate new or use existing persistent certificate") ("abort" ?a "stop immediately"))) ("throwaway" (setq elpher-client-certificate (elpher-generate-throwaway-certificate))) - ("persistant" + ("persistent" (let* ((existing-certificates (elpher-list-existing-certificates)) (file-base (completing-read "Nickname for new or existing certificate (autocompletes, empty response aborts): " @@ -1218,7 +1236,7 @@ that the response was malformed." file-base))) (message "New key and self-signed certificate written to %s" elpher-certificate-directory) - (elpher-generate-permanent-certificate file-base common-name))) + (elpher-generate-persistent-certificate file-base common-name))) ("install" (let* ((cert-file (read-file-name "Certificate file: " nil nil t)) (key-file (read-file-name "Key file: " nil nil t))) @@ -1363,17 +1381,20 @@ treatment that a separate function is warranted." The gemini map file line describing the header is given by HEADER-LINE." (when (string-match "^\\(#+\\)[ \t]*" header-line) - (let ((level (length (match-string 1 header-line))) - (header (substring header-line (match-end 0)))) + (let* ((level (length (match-string 1 header-line))) + (header (substring header-line (match-end 0))) + (face (pcase level + (1 'elpher-gemini-heading1) + (2 'elpher-gemini-heading2) + (3 'elpher-gemini-heading3) + (_ 'default))) + (fill-column (/ (* fill-column + (font-get (font-spec :name (face-font 'default)) :size)) + (font-get (font-spec :name (face-font face)) :size)))) (unless (display-graphic-p) (insert (make-string level ?#) " ")) - (insert (propertize header 'face - (pcase level - (1 'elpher-gemini-heading1) - (2 'elpher-gemini-heading2) - (3 'elpher-gemini-heading3) - (_ 'default))) - "\n")))) + (insert (propertize header 'face face)) + (newline)))) (defun elpher-gemini-insert-text (text-line) "Insert a plain non-preformatted TEXT-LINE into a text/gemini document.