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.
This commit is contained in:
Lars Ingebrigtsen 2021-11-04 06:38:22 +01:00
parent 742879f1b3
commit 1b2588998a
5 changed files with 53 additions and 0 deletions

View file

@ -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)

View file

@ -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
+++

View file

@ -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]

View file

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

View file

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