X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=6268cb6af5f5bff7e560cd2209f97c5aa455bda8;hp=b264dccc41ec3873ff29110e4ca8b92e1d0a6455;hb=d31e967beeba40a32e4da0b36d8fbb47b6bfb228;hpb=61d565ce18392a8a92347cb3376f7cd8d1092fe5 diff --git a/elpher.el b/elpher.el index b264dcc..6268cb6 100644 --- a/elpher.el +++ b/elpher.el @@ -5,7 +5,7 @@ ;; Author: Tim Vaughan ;; Created: 11 April 2019 -;; Version: 3.4.0 +;; Version: 3.4.1 ;; Keywords: comm gopher ;; Homepage: https://thelambdalab.xyz/elpher ;; Package-Requires: ((emacs "27.1")) @@ -70,7 +70,7 @@ ;;; Global constants ;; -(defconst elpher-version "3.4.0" +(defconst elpher-version "3.4.1" "Current version of elpher.") (defconst elpher-margin-width 6 @@ -310,14 +310,14 @@ meaningfully." '((t :inherit bold :height 1.2)) "Face used for gemini heading level 3.") -(defface elpher-gemini-preformatted - '((t :inherit fixed-pitch)) - "Face used for pre-formatted gemini text blocks.") - (defface elpher-gemini-quoted '((t :inherit font-lock-doc-face)) "Face used for gemini quoted texts.") +(defface elpher-gemini-preformatted + '((t :inherit elpher-text)) + "Face used for gemini preformatted text.") + (defface elpher-gemini-preformatted-toggle '((t :inherit button)) "Face used for buttons used to toggle display of preformatted text.") @@ -429,11 +429,11 @@ address refers to, via the table `elpher-type-map'." (_ 'other-url))) (defun elpher-address-about-p (address) - "Return non-nil if ADDRESS is an about address." + "Return non-nil if ADDRESS is an about address." (pcase (elpher-address-type address) (`(about ,_) t))) (defun elpher-address-gopher-p (address) - "Return non-nill if ADDRESS object is a gopher address." + "Return non-nil if ADDRESS object is a gopher address." (pcase (elpher-address-type address) (`(gopher ,_) t))) (defun elpher-address-protocol (address) @@ -467,7 +467,8 @@ For gopher addresses this is a combination of the selector type and selector." "Retrieve port from ADDRESS object. If no address is defined, returns 0. (This is for compatibility with the URL library.)" - (url-port address)) + (let ((port (url-portspec address))) ; (url-port) is too slow! + (if port port 0))) (defun elpher-gopher-address-selector (address) "Retrieve gopher selector from ADDRESS object." @@ -747,14 +748,21 @@ away CRs and any terminating period." #'ansi-color-apply) "A function to apply ANSI escape sequences.") +(defun elpher-text-has-ansi-escapes-p (string) + "Return non-nil if STRING includes an ANSI escape code." + (save-match-data + (string-match "\x1b\\[" string))) + ;;; Processing text for display (defun elpher-process-text-for-display (string) "Perform any desired processing of STRING prior to display as text. Currently includes buttonifying URLs and processing ANSI escape codes." - (elpher-buttonify-urls (if elpher-filter-ansi-from-text - (elpher-color-filter-apply string) - (elpher-color-apply string)))) + (elpher-buttonify-urls (if (elpher-text-has-ansi-escapes-p string) + (if elpher-filter-ansi-from-text + (elpher-color-filter-apply string) + (elpher-color-apply string)) + string))) ;;; Network error reporting @@ -1641,8 +1649,9 @@ If non-nil, ALT-TEXT is displayed alongside the button." "Insert a LINE of preformatted text. PREF-ID is the value assigned to the \"invisible\" text attribute, which can be used to toggle the display of the preformatted text." - (insert (propertize (concat (elpher-process-text-for-display line) "\n") - 'face 'elpher-gemini-preformatted + (insert (propertize (concat (elpher-process-text-for-display + (propertize line 'face 'elpher-gemini-preformatted)) + "\n") 'invisible pref-id 'rear-nonsticky t))) @@ -1879,8 +1888,9 @@ Assumes UTF-8 encoding for all text files." 'help-echo help-string)) (insert "\n") (insert (propertize - (concat "(These documents should be available if you have installed Elpher \n" - " using MELPA. Otherwise you may have to install the manual yourself.)\n") + (concat "(These documents should be available if you have installed Elpher\n" + " from MELPA or non-GNU ELPA. Otherwise you may have to install the\n" + " manual yourself.)\n") 'face 'shadow)) (elpher-restore-pos)))