commit db4e6bd34b992447748da10e8aae9b744d10b7fc
parent fc2ef459844d17527842553b5f2a103f92f459c3
Author: Iqbal Ansari <iqbalansari02@yahoo.com>
Date: Mon, 16 Nov 2015 09:12:01 +0530
Ensure the buffer is visible in current window, before using
`window-start` and `window-end`
Diffstat:
M | emojify.el | | | 36 | +++++++++++++++++++++--------------- |
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/emojify.el b/emojify.el
@@ -327,17 +327,20 @@ since our mechanisms do not work in it."
This is not accurate since it restricts the region to scan to
the visible area."
- (save-restriction
- (narrow-to-region (window-start) (window-end))
- (let ((list-start (ignore-errors (scan-sexps point -1))))
- (when list-start
- ;; If we got a list start make sure both start and end
- ;; belong to same string/comment
- (let ((syntax-beg (syntax-ppss list-start))
- (syntax-end (syntax-ppss point)))
- (and list-start
- (eq (nth 8 syntax-beg)
- (nth 8 syntax-end))))))))
+ (save-window-excursion
+ ;; So that we can determine window-start, window-end
+ (switch-to-buffer (current-buffer))
+ (save-restriction
+ (narrow-to-region (window-start) (window-end))
+ (let ((list-start (ignore-errors (scan-sexps point -1))))
+ (when list-start
+ ;; If we got a list start make sure both start and end
+ ;; belong to same string/comment
+ (let ((syntax-beg (syntax-ppss list-start))
+ (syntax-end (syntax-ppss point)))
+ (and list-start
+ (eq (nth 8 syntax-beg)
+ (nth 8 syntax-end)))))))))
(defun emojify-valid-text-context-p (beg end)
"Determine if the okay to display for text between BEG and END."
@@ -607,10 +610,13 @@ BEG and END are the beginning and end of the region respectively"
"Redisplay emojis in region between BEG and END.
Redisplay emojis in the visible region if BEG and END are not specified"
- (let ((beg (or beg (window-start)))
- (end (or end (window-end))))
- (emojify-undisplay-emojis-in-region beg end)
- (emojify-display-emojis-in-region beg end)))
+ (save-window-excursion
+ ;; So that we can determine window-start, window-end
+ (switch-to-buffer (current-buffer))
+ (let ((beg (or beg (window-start)))
+ (end (or end (window-end))))
+ (emojify-undisplay-emojis-in-region beg end)
+ (emojify-display-emojis-in-region beg end))))
(defun emojify-after-change-function (beg end _len)
"Redisplay emojis in region after change.