From 305246d9726bbe05a65ad3836880138db5c01dfa Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Wed, 5 Apr 2023 17:24:38 +0200 Subject: [PATCH] Add emoji-zoom-reset * lisp/international/emoji.el (emoji-zoom-map): Add emoji-zoom-reset. (emoji-zoom-reset): New function, it resets the zoom level. * lisp/international/mule-cmds.el (ctl-x-map): Add emoji-zoom-reset. * etc/NEWS: Announce new command. --- etc/NEWS | 5 +++++ lisp/international/emoji.el | 16 +++++++++++++++- lisp/international/mule-cmds.el | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 9adeb47db8c..dc4eb64a63a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1021,6 +1021,11 @@ works for non-Emoji characters.) 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 command 'emoji-zoom-reset'. +This is bound to 'C-x 8 e 0', and undoes any size changes performed by +'emoji-zoom-increase' and 'emoji-zoom-decrease'. + --- *** 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 ffff2aa1236..04854ede6be 100644 --- a/lisp/international/emoji.el +++ b/lisp/international/emoji.el @@ -700,7 +700,8 @@ We prefer the earliest unique letter." (defvar-keymap emoji-zoom-map "+" #'emoji-zoom-increase - "-" #'emoji-zoom-decrease) + "-" #'emoji-zoom-decrease + "0" #'emoji-zoom-reset) ;;;###autoload (defun emoji-zoom-increase (&optional factor) @@ -741,6 +742,19 @@ FACTOR is the multiplication factor for the size." (interactive) (emoji-zoom-increase 0.9)) +;;;###autoload +(defun emoji-zoom-reset () + "Reset the size of the character under point." + (interactive) + (with-silent-modifications + (let ((old (get-text-property (point) 'face))) + (when (and (consp old) + (remove-text-properties (point) (1+ (point)) '(rear-nonsticky nil))) + (if (eq (car old) :height) + (remove-text-properties (point) (1+ (point)) '(face nil)) + (add-text-properties (point) (1+ (point)) (list 'face + (cdr old)))))))) + (provide 'emoji) ;;; emoji.el ends here diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 4e38b13b1a5..3d6d66970d3 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -3269,7 +3269,8 @@ single characters to be treated as standing for themselves." "r" #'emoji-recent "l" #'emoji-list "+" #'emoji-zoom-increase - "-" #'emoji-zoom-decrease)) + "-" #'emoji-zoom-decrease + "0" #'emoji-zoom-reset)) (defface confusingly-reordered '((((supports :underline (:style wave))) -- 2.39.2