[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/show-font 97b3301dd3 12/54: Add error checking in show-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/show-font 97b3301dd3 12/54: Add error checking in show-font--prepare-text |
Date: |
Tue, 10 Sep 2024 03:58:57 -0400 (EDT) |
branch: externals/show-font
commit 97b3301dd3787a178ad8c1c88e42721f4fd92d69
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add error checking in show-font--prepare-text
---
show-font.el | 46 +++++++++++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/show-font.el b/show-font.el
index 3f35623602..0ccb8f1614 100644
--- a/show-font.el
+++ b/show-font.el
@@ -192,23 +192,35 @@ With optional ATTRIBUTE use it instead of \"family\"."
(defun show-font--prepare-text ()
"Prepare pangram text at varying font heights."
- (let ((pangram (show-font--get-pangram))
- (faces '(show-font-small show-font-regular show-font-medium
show-font-large))
- (list-of-lines nil)
- (list-of-blocks nil)
- (name (show-font--get-attribute "fullname"))
- (family (show-font--get-attribute "family")))
- (dolist (face faces)
- (push (propertize pangram 'face (list face :family family))
list-of-lines)
- (push (propertize show-font-character-sample 'face (list face :family
family)) list-of-blocks))
- (concat
- (propertize name 'face (list 'show-font-title :family family)) "\n"
- (propertize (make-string (length name) ?-) 'face (list 'show-font-title
:family family)) "\n"
- (propertize "Rendered with parent family:" 'face (list 'show-font-regular
:family family)) "\n"
- (propertize family 'face (list 'show-font-subtitle :family family)) "\n"
- (propertize (make-string (length family) ?=) 'face (list
'show-font-subtitle :family family)) "\n\n"
- (mapconcat #'identity (nreverse list-of-lines) "\n") "\n"
- (mapconcat #'identity (nreverse list-of-blocks) "\n") "\n")))
+ (let* ((pangram (show-font--get-pangram))
+ (appeasement-message (concat "But here is a pangram to make you
happy..." "\n\n" pangram)))
+ (cond
+ ((not (display-graphic-p))
+ (concat (propertize "Fonts cannot be displayed in a terminal or TTY."
'face 'show-font-title)
+ "\n\n" appeasement-message))
+ ((not (show-font--installed-p buffer-file-name))
+ (concat (propertize "Cannot preview this font" 'face 'show-font-title)
+ "\n\n"
+ (propertize buffer-file-name 'face 'bold)
+ " is not installed"
+ "\n\n" appeasement-message))
+ (t
+ (let ((faces '(show-font-small show-font-regular show-font-medium
show-font-large))
+ (list-of-lines nil)
+ (list-of-blocks nil)
+ (name (show-font--get-attribute "fullname"))
+ (family (show-font--get-attribute "family")))
+ (dolist (face faces)
+ (push (propertize pangram 'face (list face :family family))
list-of-lines)
+ (push (propertize show-font-character-sample 'face (list face
:family family)) list-of-blocks))
+ (concat
+ (propertize name 'face (list 'show-font-title :family family)) "\n"
+ (propertize (make-string (length name) ?-) 'face (list
'show-font-title :family family)) "\n"
+ (propertize "Rendered with parent family:" 'face (list
'show-font-regular :family family)) "\n"
+ (propertize family 'face (list 'show-font-subtitle :family family))
"\n"
+ (propertize (make-string (length family) ?=) 'face (list
'show-font-subtitle :family family)) "\n\n"
+ (mapconcat #'identity (nreverse list-of-lines) "\n") "\n"
+ (mapconcat #'identity (nreverse list-of-blocks) "\n") "\n"))))))
(defmacro show-font-with-unmodified-buffer (&rest body)
"Run BODY while not making the buffer appear modified."
- [elpa] externals/show-font f90e03c5e8 22/54: Refine how the title faces are produced, (continued)
- [elpa] externals/show-font f90e03c5e8 22/54: Refine how the title faces are produced, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c10b077657 25/54: Add TODO about how best to support multiple languages, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font b572bacf0c 26/54: Make the major mode disable line numbers locally, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 5cf734e21a 35/54: Define a button and use it to help the user install current file, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c5d7fd6e34 01/54: Add initial version of show-font, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 460da112ed 08/54: Add TODO about other operating systems, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font a1ffe8afdf 05/54: Autoload show-font-extensions-regexp to make the package install correctly, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 1ab166f5df 14/54: Remove done to-do items, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 791416d748 16/54: Rework how we expand the pangrams for the defcustom :type, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font d3a51209eb 09/54: Use setq-local consistency in the major mode definition, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 97b3301dd3 12/54: Add error checking in show-font--prepare-text,
ELPA Syncer <=
- [elpa] externals/show-font 9a40c37d54 04/54: Add link to demo in the README, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font b951202b9b 29/54: Define commands to (i) preview an installed font (ii) list+preview all installed fonts, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 36d3197e13 43/54: Autoload `show-font-handler`, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font a38c7ba286 53/54: Fix a couple of typos, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 0d5978f07b 52/54: Add link with sample pictures, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font da30bb5554 06/54: Add FIXME for how the file handler is added (also see commit a1ffe8a), ELPA Syncer, 2024/09/10
- [elpa] externals/show-font c41443f03a 03/54: Tweak how the font is propertized, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 6ca36f382e 23/54: Add some outline headings, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font b1bf2837f9 36/54: Rename helper function that check FILE font attributes, ELPA Syncer, 2024/09/10
- [elpa] externals/show-font 8ed7c66c63 44/54: Merge pull request #3 from swapnilsm/main, ELPA Syncer, 2024/09/10