emacs-emojify

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

commit 5af2947cd878465c650f2a09d8adb919037af5ed
parent 0bffa9223f76dc8dcf5d3e207b9dc7ba4c381ec4
Author: Iqbal Ansari <iqbal.ansari@ignitesol.com>
Date:   Mon, 26 Oct 2015 11:09:48 +0530

Better check for 'emojis inside words'

Diffstat:
Memojify.el | 21+++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/emojify.el b/emojify.el @@ -1,6 +1,6 @@ ;; -*- lexical-binding: t; -*- -;; Another plugin to waste time in Emacs :sweat: :worried: :unamused: :p :) :P -;; +;; Another plugin to waste time in Emacs :sweat: :worried: :unamused: :p :) :p :p +;; ;; TODO: Bug in org-capture (what causes this) ;; Sometimes point is changed after adding emoji ;; Custom images @@ -20,7 +20,7 @@ (defun emojify--emojify-buffer-p () (not (or (minibufferp) - (string-match-p "helm" (symbol-name major-mode))))) + (string-match-p "\\*helm" (buffer-name))))) ;; Can be one of image, unicode, ascii (defvar emoji-substitution-style 'image) @@ -31,7 +31,6 @@ (create-image (expand-file-name (concat (gethash "unicode" emoji-one) ".png") emoji-image-dir) ;; Use imagemagick if available (allows resizing images - (when (fboundp 'imagemagick-types) 'imagemagick) nil @@ -41,14 +40,19 @@ (defun emojify--setup-emoji-display (start end match) "Emojify the text between start and end" + ;; TODO Generalize these into a set of predicates (when (and (or (not (derived-mode-p 'prog-mode)) + ;; TODO: Handle emojis with quotes or comment character :sweat: (nth 8 (syntax-ppss))) - (not (and (char-before start) - (eq (char-syntax (char-before start)) ?w))) - (not (and (char-after end) - (eq (char-syntax (char-after end)) ?w))) + (or (not (char-before start)) + ;; 32 space since ? i.e. (? followed by a space is not readable) + (memq (char-syntax (char-before start)) '(32 ?- ?<))) + (or (not (char-after end)) + ;; 32 space since ? i.e. (? followed by a space is not readable) + (memq (char-syntax (char-after end)) '(32 ?- ?>))) (or (not (equal major-mode 'org-mode)) (equal (face-at-point) 'org-tag))) + ;; TODO: Remove double checks (when (gethash match emoji-parsed) (add-text-properties start end (list 'display (pcase emoji-substitution-style (`image (emojify-get-image match))) @@ -108,6 +112,7 @@ ;; (font-lock-fontify-buffer)) ;; (ad-activate 'text-scale-increase) + (defun emojify-turn-on-emojify-mode () (when (emojify--emojify-buffer-p) (save-restriction