[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 371c4f642a 1/2: Add new commands to zoom emojis
From: |
Lars Ingebrigtsen |
Subject: |
master 371c4f642a 1/2: Add new commands to zoom emojis |
Date: |
Thu, 30 Jun 2022 04:47:50 -0400 (EDT) |
branch: master
commit 371c4f642a1476ce2cd3514caeb66125c53aea26
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
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 ce32542028..14747eaf92 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 8970a466b7..6a65bc43dc 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 27defef648..48c8d2b081 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)))