commit c3ae260af4451d1d4e68ce73ff0624b1fd39c490 parent 0a0dc0bf0f7778b14c899659231e0eb492c45aa1 Author: Iqbal Ansari <iqbalansari02@yahoo.com> Date: Thu, 25 Apr 2019 03:37:11 +0530 Reimplement `emojify-string` using `emojify-display-emojis-in-region` Avoid the need to duplicate display logic Diffstat:
M | emojify.el | | | 31 | ++----------------------------- |
1 file changed, 2 insertions(+), 29 deletions(-)
diff --git a/emojify.el b/emojify.el @@ -1230,37 +1230,10 @@ TARGET can either be a buffer object or a special value mode-line. It is used to indicate where EMOJI would be displayed, properties like font-height are inherited from TARGET if provided. See also `emojify--get-text-display-props'." (emojify-create-emojify-emojis) - (let ((target (or target (current-buffer)))) + (let ((emojify-emoji-styles (or styles emojify-emoji-styles))) (with-temp-buffer (insert string) - (let ((beg (point-min)) - (end (point-max)) - (styles (or styles emojify-emoji-styles))) - (seq-doseq (regexp (apply #'append - (when emojify--user-emojis-regexp - (list emojify--user-emojis-regexp)) - (list emojify-regexps))) - (goto-char beg) - (while (and (> end (point)) - (search-forward-regexp regexp end t)) - (let* ((match-beginning (match-beginning 0)) - (match-end (match-end 0)) - (match (match-string-no-properties 0)) - (buffer (current-buffer)) - (emoji (emojify-get-emoji match))) - (when (and emoji - (not (or (get-text-property match-beginning 'emojify-inhibit) - (get-text-property match-end 'emojify-inhibit))) - (memql (intern (ht-get emoji "style")) styles) - ;; Skip displaying this emoji if the its bounds are - ;; already part of an existing emoji. Since the emojis - ;; are searched in descending order of length (see - ;; construction of emojify-regexp in `emojify-set-emoji-data'), - ;; this means larger emojis get precedence over smaller - ;; ones - (not (or (get-text-property match-beginning 'emojified) - (get-text-property (1- match-end) 'emojified)))) - (emojify--propertize-text-for-emoji emoji match buffer match-beginning match-end target)))))) + (emojify-display-emojis-in-region (point-min) (point-max) target) (buffer-string))))