Gnus development mailing list
 help / color / mirror / Atom feed
* [PATCH] Add new smiley-style emoji to Gnus
@ 2020-10-06 17:22 Adam Sjøgren
  2020-10-07  0:45 ` 황병희
  2020-10-07 16:12 ` Eric Abrahamsen
  0 siblings, 2 replies; 3+ messages in thread
From: Adam Sjøgren @ 2020-10-06 17:22 UTC (permalink / raw)
  To: ding

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add new smiley-style emoji to Gnus
  2020-10-06 17:22 [PATCH] Add new smiley-style emoji to Gnus Adam Sjøgren
@ 2020-10-07  0:45 ` 황병희
  2020-10-07 16:12 ` Eric Abrahamsen
  1 sibling, 0 replies; 3+ messages in thread
From: 황병희 @ 2020-10-07  0:45 UTC (permalink / raw)
  To: The Gnus

Adam Sjøgren <asjo@koldfront.dk> writes:

> The new smiley-style called emoji takes advantage of the harfbuzz glyph
> rendering to represent smileys as colorful unicode emoji rather than
> images.

Wow! I like this image-like features for Gnus^^^

Thank You Thank You Adam^^^

Sincerely, Gnus fan Byung-Hee

-- 
^고맙습니다 _地平天成_ 감사합니다_^))//


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add new smiley-style emoji to Gnus
  2020-10-06 17:22 [PATCH] Add new smiley-style emoji to Gnus Adam Sjøgren
  2020-10-07  0:45 ` 황병희
@ 2020-10-07 16:12 ` Eric Abrahamsen
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Abrahamsen @ 2020-10-07 16:12 UTC (permalink / raw)
  To: ding

Adam Sjøgren <asjo@koldfront.dk> writes:

> 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?

I don't know nothing about no emojis -- you should report an Emacs bug
and attach your patch!



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-07 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-06 17:22 [PATCH] Add new smiley-style emoji to Gnus Adam Sjøgren
2020-10-07  0:45 ` 황병희
2020-10-07 16:12 ` Eric Abrahamsen

Gnus development mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/ding

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 ding ding/ http://inbox.vuxu.org/ding \
		ding@inbox.vuxu.org
	public-inbox-index ding

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.emacs.gnus.general


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git