branch: externals/ement commit ebc04f129da96c0e0e0b1033de7a174684578c08 Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Add: (ement-room-list-avatars-generation) --- README.org | 1 + ement-room-list.el | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.org b/README.org index c5570e3da9..36d4100a11 100644 --- a/README.org +++ b/README.org @@ -303,6 +303,7 @@ Ement.el doesn't support encrypted rooms natively, but it can be used transparen + Customization groups for faces. (Thanks to [[https://github.com/phil-s][Phil Sainty]].) + Option ~ement-room-hide-redacted-message-content~, which hides the content of redacted messages by default. It may be disabled to keep redacted content visible with a strikethrough face, which may be useful for room moderators, but users should keep in mind that doing so will leave unpleasant content visible in the current session, even after being redacted by moderators. ++ Option ~ement-room-list-avatars-generation~: if disabled, SVG-based room avatars are not generated. This option automatically tests whether SVG support is available in Emacs, and should allow use with builds of Emacs that lack =librsvg= support. *Changes* diff --git a/ement-room-list.el b/ement-room-list.el index 748d89a304..d567fc1ac8 100644 --- a/ement-room-list.el +++ b/ement-room-list.el @@ -140,6 +140,10 @@ Set automatically when `ement-room-list-mode' is activated.") "Show room avatars in the room list." :type 'boolean) +(defcustom ement-room-list-avatars-generation (image-type-available-p 'svg) + "Generate SVG-based avatars for rooms that have none." + :type 'boolean) + (defcustom ement-room-list-space-prefix "Space: " "Prefix applied to space names." :type 'string) @@ -416,15 +420,18 @@ from recent to non-recent for rooms updated in the past hour." (propertize " " 'display (ement--resize-image (get-text-property 0 'display avatar) nil (frame-char-height))) - ;; Room has no avatar: make one. - (let* ((string (or display-name (ement--room-display-name room))) - (ement-room-prism-minimum-contrast 1) - (color (ement--prism-color string :contrast-with "white"))) - (when (string-match (rx bos (or "#" "!" "@")) string) - (setf string (substring string 1))) - (propertize " " 'display (svg-lib-tag (substring string 0 1) nil - :background color :foreground "white" - :stroke 0)))))) + ;; Room has no avatar. + (if ement-room-list-avatars-generation + (let* ((string (or display-name (ement--room-display-name room))) + (ement-room-prism-minimum-contrast 1) + (color (ement--prism-color string :contrast-with "white"))) + (when (string-match (rx bos (or "#" "!" "@")) string) + (setf string (substring string 1))) + (propertize " " 'display (svg-lib-tag (substring string 0 1) nil + :background color :foreground "white" + :stroke 0))) + ;; Avatar generation disabled: use a two-space string. + " ")))) (setf (alist-get 'room-list-avatar (ement-room-local room)) new-avatar))) ;; Avatars disabled: use a two-space string. " ")))