Fix "wrong type argument" messages when fetching from Gemini.
authorChristopher Brannon <chris@the-brannons.com>
Fri, 19 Feb 2021 03:15:13 +0000 (19:15 -0800)
committerChristopher Brannon <chris@the-brannons.com>
Fri, 19 Feb 2021 04:04:39 +0000 (20:04 -0800)
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

index 4c34f52..92215fa 100644 (file)
--- 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)))
 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))
       (unless (display-graphic-p)
         (insert (make-string level ?#) " "))
       (insert (propertize header 'face face))