emacs-emojify

fork of https://github.com/iqbalansari/emacs-emojify
Log | Files | Refs | LICENSE

commit 17dee8f70d4340aa6e1c17a77ee5acf11713d600
parent 9f6de028fd58b850c5684e3b8740baff5cdf9114
Author: Iqbal Ansari <iqbalansari02@yahoo.com>
Date:   Sun, 26 Apr 2020 14:11:21 +0530

Iterate through emojis from end to beginning in emojify-do-for-emojis-in-region

This allows `forms` passed to `emojify-do-for-emojis-in-region` to be
potentially mutate the buffer without the other emoji positions becoming invalid

Diffstat:
Memojify.el | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/emojify.el b/emojify.el @@ -227,13 +227,18 @@ and end of the emoji for which the form is being executed." (declare (debug t) (indent 2)) `(let ((--emojify-loop-current-pos ,beg) (--emojify-loop-end ,end) - emoji-start) + (--emoji-positions nil) + --emoji-start) (while (and (> --emojify-loop-end --emojify-loop-current-pos) - (setq emoji-start (text-property-any --emojify-loop-current-pos --emojify-loop-end 'emojified t))) - (let ((emoji-end (+ emoji-start - (length (get-text-property emoji-start 'emojify-text))))) - ,@forms - (setq --emojify-loop-current-pos emoji-end))))) + (setq --emoji-start (text-property-any --emojify-loop-current-pos --emojify-loop-end 'emojified t))) + (let ((--emoji-end (+ --emoji-start + (length (get-text-property --emoji-start 'emojify-text))))) + (push (cons --emoji-start --emoji-end) --emoji-positions) + (setq --emojify-loop-current-pos --emoji-end))) + (dolist (--position --emoji-positions) + (let ((emoji-start (car --position)) + (emoji-end (cdr --position))) + ,@forms)))) (defun emojify-message (format-string &rest args) "Log debugging messages to buffer named 'emojify-log'.