From: Lars Ingebrigtsen Date: Thu, 4 Nov 2021 05:38:22 +0000 (+0100) Subject: Add a Gnus command to emojize symbols X-Git-Tag: emacs-29.0.90~3671^2~255 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1b2588998ac2e1b622a8e65be4951e4e5d5a8dc9;p=emacs.git Add a Gnus command to emojize symbols * doc/misc/gnus.texi (Article Display): Document it. * lisp/gnus/gnus-art.el (gnus-treat-emojize-symbols): New user option. (gnus-treatment-function-alist): Map. (article-emojize-symbols): New command and keystroke. --- diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 6c892bc80a9..796bb3bac84 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -9843,6 +9843,13 @@ Gravatarify the @code{From} header (@code{gnus-treat-from-gravatar}). Gravatarify all mail headers (i.e., @code{Cc}, @code{To}) (@code{gnus-treat-from-gravatar}). +@item W D e +@kindex W D e @r{(Summary)} +@findex gnus-article-emojize-symbols +Some symbols have both a non-emoji presentation and an emoji +presentation. This command will make Gnus choose the emoji presentation +(@code{gnus-article-emojize-symbols}). + @item W D D @kindex W D D @r{(Summary)} @findex gnus-article-remove-images @@ -12185,6 +12192,7 @@ controlling variable is a predicate list, as described above. @vindex gnus-treat-capitalize-sentences @vindex gnus-treat-overstrike @vindex gnus-treat-strip-cr +@vindex gnus-treat-emojize-symbols @vindex gnus-treat-strip-headers-in-body @vindex gnus-treat-strip-leading-blank-lines @vindex gnus-treat-strip-multiple-blank-lines @@ -12237,6 +12245,7 @@ possible but those listed are probably sufficient for most people. @item gnus-treat-capitalize-sentences (t, integer) @item gnus-treat-overstrike (t, integer) @item gnus-treat-strip-cr (t, integer) +@item gnus-treat-emojize-symbols (t, integer) @item gnus-treat-strip-headers-in-body (t, integer) @item gnus-treat-strip-leading-blank-lines (t, first, integer) @item gnus-treat-strip-multiple-blank-lines (t, integer) diff --git a/etc/NEWS b/etc/NEWS index 8161c5b4c5c..bd5dbf16e9a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -157,6 +157,18 @@ change the terminal used on a remote host. *** New user option 'mml-attach-file-at-the-end'. If non-nil, 'C-c C-a' will put attached files at the end of the message. +** Gnus + ++++ +*** New user option 'gnus-treat-emojize-symbols'. +If non-nil, symbols that have an emoji representation will be +displayed as emojis. + ++++ +*** New command 'gnus-article-emojize-symbols'. +This is bound to 'W D e' and will display symbols that have emoji +representation as emojis. + ** EIEIO +++ diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 6b33680871a..89b4a63ad92 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -1167,6 +1167,19 @@ predicate. See Info node `(gnus)Customizing Articles'." :link '(custom-manual "(gnus)Customizing Articles") :type gnus-article-treat-custom) +(defcustom gnus-treat-emojize-symbols nil + "Display emoji versions of symbol. +Some symbols have both a non-emoji presentation and an emoji +presentation. This treatment will make Gnus display the latter +as emojis even when they weren't sent as such. + +Valid values are nil, t, `head', `first', `last', an integer or a +predicate. See Info node `(gnus)Customizing Articles'." + :version "29.1" + :group 'gnus-article-treat + :link '(custom-manual "(gnus)Customizing Articles") + :type gnus-article-treat-custom) + (defcustom gnus-treat-unsplit-urls nil "Remove newlines from within URLs. Valid values are nil, t, `head', `first', `last', an integer or a @@ -1650,6 +1663,7 @@ regexp." (defvar gnus-article-mime-handle-alist-1 nil) (defvar gnus-treatment-function-alist '((gnus-treat-strip-cr gnus-article-remove-cr) + (gnus-treat-emojize-symbols gnus-article-emojize-symbols) (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig) (gnus-treat-strip-banner gnus-article-strip-banner) (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body) @@ -2360,6 +2374,20 @@ fill width." (while (search-forward "\r" nil t) (replace-match "\n" t t))))) +(defun article-emojize-symbols () + "Display symbols (that have an emoji version) as emojis." + (interactive nil gnus-article-mode) + (when-let ((font (and (display-multi-font-p) + (car (internal-char-font nil ?😀))))) + (save-excursion + (let ((inhibit-read-only t)) + (goto-char (point-min)) + (while (re-search-forward "[[:multibyte:]]" nil t) + ;; If there's already a grapheme cluster here, skip it. + (when (and (not (find-composition (point))) + (font-has-char-p font (char-after (match-beginning 0)))) + (insert "\N{VARIATION SELECTOR-16}"))))))) + (defun article-remove-trailing-blank-lines () "Remove all trailing blank lines from the article." (interactive nil gnus-article-mode) @@ -4341,6 +4369,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is article-fill-long-lines article-capitalize-sentences article-remove-cr + article-emojize-symbols article-remove-leading-whitespace article-display-x-face article-display-face @@ -4448,6 +4477,7 @@ If variable `gnus-use-long-file-name' is non-nil, it is ["Treat overstrike" gnus-article-treat-overstrike t] ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t] ["Remove carriage return" gnus-article-remove-cr t] + ["Emojize Symbols" gnus-article-emojize-symbols t] ["Remove leading whitespace" gnus-article-remove-leading-whitespace t] ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t] ["Remove base64" gnus-article-de-base64-unreadable t] diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index f7385d19c8d..3beeace8979 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -2267,6 +2267,7 @@ increase the score of each group you read." "x" #'gnus-article-display-x-face "d" #'gnus-article-display-face "s" #'gnus-treat-smiley + "e" #'gnus-article-emojize-symbols "D" #'gnus-article-remove-images "W" #'gnus-article-show-images "F" #'gnus-article-toggle-fonts diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index dbbbb71e57f..9b3181fd4d0 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el @@ -2660,6 +2660,7 @@ are always t.") gnus-article-hide-headers gnus-article-hide-boring-headers gnus-article-treat-overstrike gnus-article-remove-cr gnus-article-remove-trailing-blank-lines + gnus-article-emojize-symbols gnus-article-display-x-face gnus-article-de-quoted-unreadable gnus-article-de-base64-unreadable gnus-article-decode-HZ