From: "Adam Sjøgren" <asjo@koldfront.dk>
To: ding@gnus.org
Subject: [PATCH] Add new smiley-style emoji to Gnus
Date: Tue, 06 Oct 2020 19:22:27 +0200 [thread overview]
Message-ID: <87y2kjw9po.fsf@tullinup.koldfront.dk> (raw)
The new smiley-style called emoji takes advantage of the harfbuzz glyph
rendering to represent smileys as colorful unicode emoji rather than
images.
* lisp/gnus/smiley.el (smiley-style): Add emoji
tag. (smiley-emoji-regexp-alist): New defcustom. (smiley-update-cache,
smiley-region): Support emoji (non-image) replacement.
---
How about an option to use emoji for smileys in Gnus?
lisp/gnus/smiley.el | 76 +++++++++++++++++++++++++++++++++------------
1 file changed, 56 insertions(+), 20 deletions(-)
diff --git a/lisp/gnus/smiley.el b/lisp/gnus/smiley.el
index 5504a52078..7d6efacfe0 100644
--- a/lisp/gnus/smiley.el
+++ b/lisp/gnus/smiley.el
@@ -44,6 +44,7 @@
;; cry ;-(
;; dead X-)
;; grin :-D
+;; halo O:-)
;;; Code:
@@ -64,7 +65,8 @@ smiley-style
"Smiley style."
:type '(choice (const :tag "small, 3 colors" low-color) ;; 13x14
(const :tag "medium, ~10 colors" medium) ;; 16x16
- (const :tag "dull, grayscale" grayscale)) ;; 14x14
+ (const :tag "dull, grayscale" grayscale) ;; 14x14
+ (const :tag "emoji, full color" emoji))
:set (lambda (symbol value)
(set-default symbol value)
(setq smiley-data-directory (smiley-directory))
@@ -96,6 +98,35 @@ smiley-data-directory
:type 'directory
:group 'smiley)
+(defcustom smiley-emoji-regexp-alist
+ '(("\\(;-)\\)\\W" 1 "😉")
+ ("[^;]\\(;)\\)\\W" 1 "😉")
+ ("\\(:-]\\)\\W" 1 "😬")
+ ("\\(8-)\\)\\W" 1 "🥴")
+ ("\\(:-|\\)\\W" 1 "😐")
+ ("\\(:-[/\\]\\)\\W" 1 "😕")
+ ("\\(:-(\\)\\W" 1 "😠")
+ ("\\(X-)\\)\\W" 1 "😵") ; 💀
+ ("\\(:-{\\)\\W" 1 "😦")
+ ("\\(>:-)\\)\\W" 1 "😈")
+ ("\\(;-(\\)\\W" 1 "😢")
+ ("\\(:-D\\)\\W" 1 "😀")
+ ("\\(O:-)\\)\\W" 1 "😇")
+ ;; "smile" must be come after "evil"
+ ("\\(\\^?:-?)\\)\\W" 1 "🙂"))
+ "A list of regexps to map smilies to emoji.
+The elements are (REGEXP MATCH EMOJI), where MATCH is the submatch in
+regexp to replace with EMOJI."
+ :version "28.1"
+ :type '(repeat (list regexp
+ (integer :tag "Regexp match number")
+ (string :tag "Emoji")))
+ :set (lambda (symbol value)
+ (set-default symbol value)
+ (smiley-update-cache))
+ :initialize 'custom-initialize-default
+ :group 'smiley)
+
;; The XEmacs version has a baroque, if not rococo, set of these.
(defcustom smiley-regexp-alist
'(("\\(;-)\\)\\W" 1 "blink")
@@ -142,23 +173,25 @@ smiley-cached-regexp-alist
(defun smiley-update-cache ()
(setq smiley-cached-regexp-alist nil)
- (dolist (elt (if (symbolp smiley-regexp-alist)
- (symbol-value smiley-regexp-alist)
- smiley-regexp-alist))
- (let ((types gnus-smiley-file-types)
- file type)
- (while (and (not file)
- (setq type (pop types)))
- (unless (file-exists-p
- (setq file (expand-file-name (concat (nth 2 elt) "." type)
- smiley-data-directory)))
- (setq file nil)))
- (when type
- (let ((image (gnus-create-image file (intern type) nil
- :ascent 'center)))
- (when image
- (push (list (car elt) (cadr elt) image)
- smiley-cached-regexp-alist)))))))
+ (if (eq smiley-style 'emoji)
+ (setq smiley-cached-regexp-alist smiley-emoji-regexp-alist)
+ (dolist (elt (if (symbolp smiley-regexp-alist)
+ (symbol-value smiley-regexp-alist)
+ smiley-regexp-alist))
+ (let ((types gnus-smiley-file-types)
+ file type)
+ (while (and (not file)
+ (setq type (pop types)))
+ (unless (file-exists-p
+ (setq file (expand-file-name (concat (nth 2 elt) "." type)
+ smiley-data-directory)))
+ (setq file nil)))
+ (when type
+ (let ((image (gnus-create-image file (intern type) nil
+ :ascent 'center)))
+ (when image
+ (push (list (car elt) (cadr elt) image)
+ smiley-cached-regexp-alist))))))))
;; Not implemented:
;; (defvar smiley-mouse-map
@@ -190,8 +223,11 @@ smiley-region
(when image
(push image images)
(gnus-add-wash-type 'smiley)
- (gnus-add-image 'smiley image)
- (gnus-put-image image string 'smiley))))
+ (if (symbolp image)
+ (progn
+ (gnus-add-image 'smiley image)
+ (gnus-put-image image string 'smiley))
+ (insert image)))))
images))))
;;;###autoload
--
2.28.0
--
"I'm sorry I sound calm. I assure you that Adam Sjøgren
I am hysterical." asjo@koldfront.dk
next reply other threads:[~2020-10-06 17:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-06 17:22 Adam Sjøgren [this message]
2020-10-07 0:45 ` 황병희
2020-10-07 16:12 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y2kjw9po.fsf@tullinup.koldfront.dk \
--to=asjo@koldfront.dk \
--cc=ding@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).