X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=f2ea9874043d3bd7d8770314196f248ef455d949;hp=ca076d040dd4e0ec851419a5f1c751db9b523a58;hb=119e298777b89072794799dcb12b0d77ce8f441b;hpb=c0cd7a5c233006cfb53cf8b71b04e4ac5c6c1bac diff --git a/elpher.el b/elpher.el index ca076d0..f2ea987 100644 --- a/elpher.el +++ b/elpher.el @@ -4,7 +4,7 @@ ;; Author: Tim Vaughan ;; Created: 11 April 2019 -;; Version: 2.7.6 +;; Version: 2.7.8 ;; Keywords: comm gopher ;; Homepage: http://thelambdalab.xyz/elpher ;; Package-Requires: ((emacs "26")) @@ -70,7 +70,7 @@ ;;; Global constants ;; -(defconst elpher-version "2.7.6" +(defconst elpher-version "2.7.8" "Current version of elpher.") (defconst elpher-margin-width 6 @@ -358,7 +358,7 @@ If no address is defined, returns 0. (This is for compatibility with the URL li "Retrieve gopher selector from ADDRESS object." (if (member (url-filename address) '("" "/")) "" - (substring (url-filename address) 2))) + (url-unhex-string (substring (url-filename address) 2)))) ;; Cache @@ -1146,6 +1146,18 @@ by HEADER-LINE." (_ 'default))) "\n")))) +(defun elpher-gemini-insert-text (text-line) + "Insert a plain non-preformatted TEXT-LINE into a text/gemini document. +This function uses Emacs' auto-fill to wrap text sensibly to a maximum +width defined by elpher-gemini-max-fill-width." + (insert (elpher-process-text-for-display text-line)) + (let* ((prefix-end-idx (string-match "[^ \t*]" text-line)) + (fill-prefix (if prefix-end-idx + (let ((raw-prefix (substring text-line 0 prefix-end-idx))) + (replace-regexp-in-string "\*" " " raw-prefix)) + nil))) + (newline))) + (defun elpher-render-gemini-map (data _parameters) "Render DATA as a gemini map file, PARAMETERS is currently unused." (elpher-with-clean-buffer @@ -1160,7 +1172,7 @@ by HEADER-LINE." "\n")) ((string-prefix-p "=>" line) (elpher-gemini-insert-link line)) ((string-prefix-p "#" line) (elpher-gemini-insert-header line)) - (t (insert (elpher-process-text-for-display line)) (newline))))) + (t (elpher-gemini-insert-text line))))) (elpher-cache-content (elpher-page-address elpher-current-page) (buffer-string)))) @@ -1779,6 +1791,7 @@ functions which initialize the gopher client, namely (switch-to-buffer "*elpher*") (switch-to-buffer "*elpher*") (setq elpher-current-page nil) + (setq elpher-history nil) (let ((start-page (elpher-make-page "Elpher Start Page" (elpher-make-special-address 'start)))) (elpher-visit-page start-page)))