emacs-emojify

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

commit 1954d887f1779fc9a38740d7d78bb9ac4637db97
parent a430d0a4607e160fbda822c2740264d8efc6cef1
Author: Iqbal Ansari <iqbalansari02@yahoo.com>
Date:   Tue, 27 Sep 2016 22:22:43 +0530

Wrap frequently executed (safe to fail) code in while-no-input

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

diff --git a/emojify.el b/emojify.el @@ -579,18 +579,19 @@ Does nothing if the value is anything else." (defun emojify-detect-emoji-entry/exit () "Detect emoji entry and exit and run appropriate handlers." - (emojify-with-saved-buffer-state - (when emojify--last-emoji-pos - (emojify-on-emoji-exit (car emojify--last-emoji-pos) (cdr emojify--last-emoji-pos))) - - (when (get-text-property (point) 'emojified) - (let* ((text-props (text-properties-at (point))) - (buffer (plist-get text-props 'emojify-buffer)) - (match-beginning (plist-get text-props 'emojify-beginning)) - (match-end (plist-get text-props 'emojify-end))) - (when (eq buffer (current-buffer)) - (emojify-on-emoji-enter match-beginning match-end) - (setq emojify--last-emoji-pos (cons match-beginning match-end))))))) + (while-no-input + (emojify-with-saved-buffer-state + (when emojify--last-emoji-pos + (emojify-on-emoji-exit (car emojify--last-emoji-pos) (cdr emojify--last-emoji-pos))) + + (when (get-text-property (point) 'emojified) + (let* ((text-props (text-properties-at (point))) + (buffer (plist-get text-props 'emojify-buffer)) + (match-beginning (plist-get text-props 'emojify-beginning)) + (match-end (plist-get text-props 'emojify-end))) + (when (eq buffer (current-buffer)) + (emojify-on-emoji-enter match-beginning match-end) + (setq emojify--last-emoji-pos (cons match-beginning match-end)))))))) (defun emojify-help-function (_window _string pos) "Function to get help string to be echoed when point/mouse into the point. @@ -1193,14 +1194,14 @@ report incorrect values. To work around this `emojify-update-visible-emojis-background-after-window-scroll' is added to `window-scroll-functions' to update emojis on window scroll." - (emojify--update-emojis-background-in-region-starting-at (window-start))) + (while-no-input (emojify--update-emojis-background-in-region-starting-at (window-start)))) (defun emojify-update-visible-emojis-background-after-window-scroll (_window display-start) "Function added to `window-scroll-functions' when region is active. This function updates the backgrounds of the emojis in the newly displayed area of the window. DISPLAY-START corresponds to the new start of the window." - (emojify--update-emojis-background-in-region-starting-at display-start)) + (while-no-input (emojify--update-emojis-background-in-region-starting-at display-start)))