From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18105 invoked from network); 6 Oct 2020 17:23:38 -0000 Received: from lists1.math.uh.edu (129.7.128.208) by inbox.vuxu.org with ESMTPUTF8; 6 Oct 2020 17:23:38 -0000 Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.94) (envelope-from ) id 1kPqfr-0016kJ-0I; Tue, 06 Oct 2020 12:22:51 -0500 Received: from mx2.math.uh.edu ([129.7.128.33]) by lists1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kPqfl-0016iP-2P for ding@lists.math.uh.edu; Tue, 06 Oct 2020 12:22:45 -0500 Received: from quimby.gnus.org ([95.216.78.240]) by mx2.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kPqfi-00HJlr-Ee for ding@lists.math.uh.edu; Tue, 06 Oct 2020 12:22:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:Mime-Version:Message-ID :Date:Subject:From:To:Sender:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lTYrVg3k7U1uIkY7co+BKXXneNGVLv13ZK5xTULjs88=; b=OxAAxE+Hw0TBmNdOUfKP2P4hNn tmw373qGwjZJVQ+HCS/eyCS+BEhXgc1rJKeB30Iq23MHIfEPYjY/K4GOI/VlqeEijCiwe8F71S8Jc WDTrgYqN8kQJL79nNC8Y7tYOm27kZ/BSrhh7Jj9U7VB5Cp5PfoN0hc/OJLXbbSQxiEpc=; Received: from static.214.254.202.116.clients.your-server.de ([116.202.254.214] helo=ciao.gmane.io) by quimby with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kPqfZ-0002m3-97 for ding@gnus.org; Tue, 06 Oct 2020 19:22:37 +0200 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kPqfY-0006Id-88 for ding@gnus.org; Tue, 06 Oct 2020 19:22:32 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: ding@gnus.org From: =?utf-8?Q?Adam_Sj=C3=B8gren?= Subject: [PATCH] Add new smiley-style emoji to Gnus Date: Tue, 06 Oct 2020 19:22:27 +0200 Organization: koldfront - analysis & revolution, Copenhagen, Denmark Message-ID: <87y2kjw9po.fsf@tullinup.koldfront.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cancel-Lock: sha1:6j3iR0MWylqCUKhlPidPh7uxbSQ= OpenPGP: id=476630590A231909B0A0961A49D0746121BDE416; url=https://asjo.koldfront.dk/gpg.asc Mail-Follow-Up-To: never X-Now-Playing: She Loves Us, To Be Kind (cd 2) (Swans) X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97,Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR Precedence: bulk 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