From 371c4f642a1476ce2cd3514caeb66125c53aea26 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 30 Jun 2022 10:46:59 +0200 Subject: [PATCH] Add new commands to zoom emojis * lisp/international/emoji.el (emoji-zoom-map) (emoji-zoom-increase, emoji-zoom-decrease): New commands. * lisp/international/mule-cmds.el (ctl-x-map): Bind them. --- etc/NEWS | 5 +++++ lisp/international/emoji.el | 40 +++++++++++++++++++++++++++++++++ lisp/international/mule-cmds.el | 4 +++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index ce325420289..14747eaf92e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -607,6 +607,11 @@ inserted. This command will tell you the name of the Emoji at point. (This command also works for non-Emoji characters.) +--- +*** New commands 'emoji-zoom-increase' and 'emoji-zoom-decrease'. +These are bound to 'C-x 8 e +' and 'C-x 8 e -', respectively. They +can be used on any character, but are mainly useful for emoji. + --- *** New input method 'emoji'. This allows you to enter emoji using short strings, eg ':face_palm:' diff --git a/lisp/international/emoji.el b/lisp/international/emoji.el index 8970a466b7c..6a65bc43dc7 100644 --- a/lisp/international/emoji.el +++ b/lisp/international/emoji.el @@ -700,6 +700,46 @@ We prefer the earliest unique letter." (emoji--define-transient (cons "Choose Emoji" (cons glyph derived)))))))))) +(defvar-keymap emoji-zoom-map + "+" #'emoji-zoom-increase + "-" #'emoji-zoom-decrease) + +;;;###autoload +(defun emoji-zoom-increase (&optional factor) + "Increase the size of the character under point. +FACTOR is the multiplication factor for the size. + +This command will be repeatable if `repeat-mode' is switched on." + (interactive) + (let* ((factor (or factor 1.1)) + (old (get-text-property (point) 'face)) + (height (or (and (consp old) + (plist-get old :height)) + 1.0)) + (inhibit-read-only t)) + (with-silent-modifications + (if (consp old) + (add-text-properties + (point) (1+ (point)) + (list 'face (plist-put (copy-sequence old) :height (* height factor)) + 'rear-nonsticky t)) + (add-face-text-property (point) (1+ (point)) + (list :height (* height factor))) + (put-text-property (point) (1+ (point)) + 'rear-nonsticky t))))) + +(put 'emoji-zoom-increase 'repeat-map 'emoji-zoom-map) + +;;;###autoload +(defun emoji-zoom-decrease () + "Decrease the size of the character under point. + +This command will be repeatable if `repeat-mode' is switched on." + (interactive) + (emoji-zoom-increase 0.9)) + +(put 'emoji-zoom-decrease 'repeat-map 'emoji-zoom-map) + (provide 'emoji) ;;; emoji.el ends here diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 27defef6480..48c8d2b0818 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -3257,7 +3257,9 @@ as names, not numbers." "s" #'emoji-search "d" #'emoji-describe "r" #'emoji-recent - "l" #'emoji-list)) + "l" #'emoji-list + "+" #'emoji-zoom-increase + "-" #'emoji-zoom-decrease)) (defface confusingly-reordered '((((supports :underline (:style wave))) -- 2.39.5