emacs-emojify

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

commit 8ddcba097c710c6adc41246f81306eca1b8dfb99
parent 0978bee24f30138236ef751a1359837dc319e1de
Author: Iqbal Ansari <iqbalansari02@yahoo.com>
Date:   Mon,  5 Sep 2016 13:06:37 +0530

Minor restructuring of the code

Diffstat:
Memojify.el | 56++++++++++++++++++++++++++++----------------------------
1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/emojify.el b/emojify.el @@ -331,30 +331,9 @@ can customize `emojify-inhibit-major-modes' and ;; Customizations to control display of emojis -(defvar emojify-emojis nil - "Data about the emojis, this contains only the emojis that come with emojify.") - -(defvar emojify-regexps nil - "Regexp to match text to emojified.") - (defvar emojify-emoji-style-change-hooks nil "Hooks run when emoji style changes.") -(defun emojify-set-emoji-data () - "Read the emoji data for STYLES and set the regexp required to search them." - (setq emojify-emojis (let ((json-array-type 'list) - (json-object-type 'hash-table)) - (json-read-file emojify-emoji-json))) - - ;; Construct emojify-regexps in descending order of length, this is important - ;; so that larger emojis are searched first and get precedence over smaller - ;; ones (see also `emojify-display-emojis-in-region') - (setq emojify-regexps (seq-map #'regexp-opt - (seq-partition (sort (ht-keys emojify-emojis) - (lambda (string1 string2) (> (length string1) - (length string2)))) - 1000)))) - ;;;###autoload (defun emojify-set-emoji-styles (styles) "Set the type of emojis that should be displayed. @@ -604,6 +583,27 @@ To understand WINDOW, STRING and POS see the function documentation for ;; Core functions and macros +(defvar emojify-emojis nil + "Data about the emojis, this contains only the emojis that come with emojify.") + +(defvar emojify-regexps nil + "Regexp to match text to emojified.") + +(defun emojify-set-emoji-data () + "Read the emoji data for STYLES and set the regexp required to search them." + (setq-default emojify-emojis (let ((json-array-type 'list) + (json-object-type 'hash-table)) + (json-read-file emojify-emoji-json))) + + ;; Construct emojify-regexps in descending order of length, this is important + ;; so that larger emojis are searched first and get precedence over smaller + ;; ones (see also `emojify-display-emojis-in-region') + (setq-default emojify-regexps (seq-map #'regexp-opt + (seq-partition (sort (ht-keys emojify-emojis) + (lambda (string1 string2) (> (length string1) + (length string2)))) + 1000)))) + (defvar emojify-emoji-keymap (let ((map (make-sparse-keymap))) (define-key map [remap delete-char] #'emojify-delete-emoji-forward) @@ -1230,9 +1230,9 @@ run the command `emojify-download-emoji'"))) ;; calculated using `apropos-score-str' (maphash (lambda (key value) (when (or (string-match apropos-regexp key) - (string-match apropos-regexp (gethash "name" value))) + (string-match apropos-regexp (ht-get value "name"))) (push (list (max (apropos-score-str key) - (apropos-score-str (gethash "name" value))) + (apropos-score-str (ht-get value "name"))) key value) matching-emojis))) @@ -1256,8 +1256,8 @@ run the command `emojify-download-emoji'"))) (dolist (emoji sorted-emojis) (insert (format "%s - %s (%s)" (car emoji) - (gethash "name" (cadr emoji)) - (gethash "style" (cadr emoji)))) + (ht-get (cadr emoji) "name") + (ht-get (cadr emoji) "style"))) (insert "\n")) (goto-char (point-min)) (emojify-apropos-mode) @@ -1277,11 +1277,11 @@ This respects the `emojify-emoji-styles' variable." (completion-ignore-case t) (candidates (let (emojis) (maphash (lambda (key value) - (when (member (gethash "style" value) styles) + (when (member (ht-get value "style") styles) (push (format "%s - %s (%s)" key - (gethash "name" value) - (gethash "style" value)) + (ht-get value "name") + (ht-get value "style")) emojis))) emojify-emojis) emojis)))