From fbb52a780ac26d328d930ddfd20ec67ce282cb6f Mon Sep 17 00:00:00 2001 From: Christopher Brannon Date: Thu, 18 Feb 2021 19:15:13 -0800 Subject: [PATCH] Fix "wrong type argument" messages when fetching from Gemini. This is a problem that has affected people using elpher under emacs in a tty. I tracked down the cause. The header filling calculations fail because the tty font doesn't have a :size property. There's another proposed fix in patch_header_text_termina, but I couldn't get that one to work. --- elpher.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/elpher.el b/elpher.el index 4c34f52..92215fa 100644 --- a/elpher.el +++ b/elpher.el @@ -1366,15 +1366,16 @@ 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))) - (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)))) + (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 (if (display-graphic-p) + (/ (* fill-column + (font-get (font-spec :name (face-font 'default)) :size)) + (font-get (font-spec :name (face-font face)) :size)) fill-column))) (unless (display-graphic-p) (insert (make-string level ?#) " ")) (insert (propertize header 'face face)) -- 2.20.1