emacs-emojify

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

commit 77d8481bd387e27ecaf4ad6b7011a898469c175f
parent d0715d0a41fe820bcbab9f3d99ccb77029ce6f81
Author: Iqbal Ansari <iqbalansari02@yahoo.com>
Date:   Sat, 31 Oct 2015 10:21:36 +0530

Extract point-left hook to a separate function

Diffstat:
Memojify.el | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/emojify.el b/emojify.el @@ -287,11 +287,9 @@ OLD-POINT and NEW-POINT are the point before entering and after entering." (with-silent-modifications (add-text-properties match-end match-beginning - (list 'point-left (lambda (old-point new-point) - (when (and (equal buffer (current-buffer)) - (or (< match-end new-point) - (< new-point match-beginning))) - (emojify-display-emojis-in-region match-beginning match-end)))))))) + (list 'point-left (emojify--get-point-left-function buffer + match-beginning + match-end)))))) ((functionp 'emojify-point-entered-behaviour) (funcall emojify-point-entered-behaviour buffer match match-beginning match-end)))))) @@ -307,6 +305,17 @@ To understand WINDOW, STRING and POS see the function documentation for ;; Core functions and macros +(defun emojify--get-point-left-function (buffer match-beginning match-end) + "Create a function that can be executed in point-left hook for emoji text. + +BUFFER is the buffer where the text is from, MATCH-BEGINNING and MATCH-END. +mark the start and end of region containing the text." + (lambda (old-point new-point) + (when (and (equal buffer (current-buffer)) + (or (< match-end new-point) + (< new-point match-beginning))) + (emojify-display-emojis-in-region match-beginning match-end)))) + (defun emojify--get-image-display (data) "Get the display text property to display the emoji specified in DATA as an image." (let ((image-file (expand-file-name (concat (ht-get data "unicode") ".png")