X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=b9c43f87183cab7affca96b4ea238d0ed7696d7c;hp=e6243e524a7a6ce5417cee8c11faac960fd14d79;hb=766a56746d122a9a35d5ac76830acb3123134c70;hpb=9194772213702aa5a1ab62637ad73b7f0aca3a1e diff --git a/elpher.el b/elpher.el index e6243e5..b9c43f8 100644 --- a/elpher.el +++ b/elpher.el @@ -20,7 +20,7 @@ ;; Author: Tim Vaughan ;; Created: 11 April 2019 -;; Version: 3.1.0 +;; Version: 3.2.1 ;; Keywords: comm gopher ;; Homepage: https://thelambdalab.xyz/elpher ;; Package-Requires: ((emacs "27.1")) @@ -85,7 +85,7 @@ ;;; Global constants ;; -(defconst elpher-version "3.1.0" +(defconst elpher-version "3.2.1" "Current version of elpher.") (defconst elpher-margin-width 6 @@ -577,13 +577,14 @@ previously-visited pages,unless NO-HISTORY is non-nil." "If `elpher-use-header' is true, display current page info in window header." (if elpher-use-header (let* ((display-string (elpher-page-display-string elpher-current-page)) + (sanitized-display-string (replace-regexp-in-string "%" "%%" display-string)) (address (elpher-page-address elpher-current-page)) (tls-string (if (and (not (elpher-address-about-p address)) (member (elpher-address-protocol address) '("gophers" "gemini"))) " [TLS encryption]" "")) - (header (concat display-string + (header (concat sanitized-display-string (propertize tls-string 'face 'bold)))) (setq header-line-format header)))) @@ -773,7 +774,7 @@ the host operating system and the local network capabilities.)" (elpher-process-cleanup) (cond ; Try again with IPv4 - ((not (or force-ipv4 socks)) + ((not (or elpher-ipv4-always force-ipv4 socks)) (message "Connection timed out. Retrying with IPv4.") (elpher-get-host-response address default-port query-string @@ -794,7 +795,9 @@ the host operating system and the local network capabilities.)" (proc (if socks (socks-open-network-stream "elpher-process" nil host service) (make-network-process :name "elpher-process" :host host - :family (and force-ipv4 'ipv4) + :family (and (or force-ipv4 + elpher-ipv4-always) + 'ipv4) :service service :buffer nil :nowait t @@ -1130,8 +1133,8 @@ If ADDRESS is not supplied or nil the record is rendered as an nil t)) (window (get-buffer-window elpher-buffer-name))) (when window - (setf (image-property image :max-width) (window-pixel-width window)) - (setf (image-property image :max-height) (window-pixel-height window))) + (setf (image-property image :max-width) (window-body-width window t)) + (setf (image-property image :max-height) (window-body-height window t))) (elpher-with-clean-buffer (insert-image image) (elpher-restore-pos))) @@ -1511,28 +1514,36 @@ by HEADER-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'." - (string-match "\\(^[ \t]*\\)\\(\\*[ \t]+\\|>[ \t]*\\)?" text-line) - (let* ((line-prefix (match-string 2 text-line)) - (processed-text-line - (if line-prefix - (cond ((string-prefix-p "*" line-prefix) - (concat - (replace-regexp-in-string "\\*" - elpher-gemini-bullet-string - (match-string 0 text-line)) - (substring text-line (match-end 0)))) - ((string-prefix-p ">" line-prefix) - (propertize text-line 'face 'elpher-gemini-quoted)) - (t text-line)) - text-line)) - (adaptive-fill-mode t) - ;; fill-prefix is important for adaptive-fill-mode: without - ;; it, multi-line list items are not indented correct - (fill-prefix (if (match-string 2 text-line) - (replace-regexp-in-string "[>\*]" " " (match-string 0 text-line)) - nil))) - (insert (elpher-process-text-for-display processed-text-line)) - (newline))) + (if (string-empty-p text-line) + (insert "\n") + (string-match + (rx (: line-start + (* (any " \t")) + (optional + (group (or (: "*" (+ (any " \t"))) + (: ">" (* (any " \t")))))))) + text-line) + (let* ((line-prefix (match-string 1 text-line)) + (processed-text-line + (if line-prefix + (cond ((string-prefix-p "*" line-prefix) + (concat + (replace-regexp-in-string "\\*" + elpher-gemini-bullet-string + (match-string 0 text-line)) + (substring text-line (match-end 0)))) + ((string-prefix-p ">" line-prefix) + (propertize text-line 'face 'elpher-gemini-quoted)) + (t text-line)) + text-line)) + (adaptive-fill-mode t) + ;; fill-prefix is important for adaptive-fill-mode: without + ;; it, multi-line list items are not indented correct + (fill-prefix (if (match-string 1 text-line) + (make-string (length (match-string 0 text-line)) ?\s) + nil))) + (insert (elpher-process-text-for-display processed-text-line)) + (newline)))) (defun elpher-render-gemini-map (data _parameters) "Render DATA as a gemini map file, PARAMETERS is currently unused."