commit 19b9bae79f33fe6c455fa638afb386044c92a1e3
parent 2b14e902849c9e6ef90e71ea0b259dbd668d219a
Author: Iqbal Ansari <iqbal.ansari@ignitesol.com>
Date: Sat, 16 Jul 2016 10:51:52 +0530
Change emojify-image-dir to a function
It didn't make much sense to have it as a customizable variable since
its value depended on the another customizable value
`emojify-emojis-dir`, causing confusion when one of the two was
customized without updating the other variable. See #22
Diffstat:
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/emojify.el b/emojify.el
@@ -225,11 +225,6 @@ visible in the selected window."
:type 'directory
:group 'emojify)
-(defcustom emojify-image-dir
- (expand-file-name emojify-emoji-set
- emojify-emojis-dir)
- "Path to emoji images.")
-
(defcustom emojify-display-style
'image
"How the emoji's be displayed.
@@ -590,6 +585,11 @@ To understand WINDOW, STRING and POS see the function documentation for
(define-key map [remap backward-delete-char-untabify] #'emojify-delete-emoji-backward)
map))
+(defun emojify-image-dir ()
+ "Get the path to directory containing images for currently selected emoji set."
+ (expand-file-name emojify-emoji-set
+ emojify-emojis-dir))
+
(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.
@@ -717,7 +717,7 @@ selection, but for some reason it does not work well."
DATA holds the emoji data, BEG and END delimit the region where emoji will
be displayed."
(let* ((image-file (expand-file-name (ht-get data "image")
- emojify-image-dir))
+ (emojify-image-dir)))
(image-type (intern (upcase (file-name-extension image-file)))))
(when (file-exists-p image-file)
(create-image image-file
@@ -1037,7 +1037,7 @@ of the window. DISPLAY-START corresponds to the new start of the window."
(defun emojify-download-emoji-maybe ()
"Download emoji images if needed."
(when (and (equal emojify-display-style 'image)
- (not (file-exists-p emojify-image-dir))
+ (not (file-exists-p (emojify-image-dir)))
(not emojify--refused-image-download-p))
(unwind-protect
;; Do not prompt for download if download is in progress
diff --git a/test/test-helper.el b/test/test-helper.el
@@ -32,7 +32,6 @@
Helps isolate tests from each other's customizations."
(declare (indent 0))
`(let ((emojify-saved-emoji-json emojify-emoji-json)
- (emojify-saved-image-dir emojify-image-dir)
(emojify-saved-display-style emojify-display-style)
(emojify-saved-inhibit-major-modes emojify-inhibit-major-modes)
(emojify-saved-inhibit-in-buffer-functions emojify-inhibit-in-buffer-functions)
@@ -45,11 +44,10 @@ Helps isolate tests from each other's customizations."
(emojify-debug-mode t))
(unwind-protect
(progn
- (unless (file-exists-p emojify-image-dir)
+ (unless (file-exists-p (emojify-image-dir))
(emojify-download-emoji emojify-emoji-set))
,@forms)
(setq emojify-emoji-json emojify-saved-emoji-json
- emojify-image-dir emojify-saved-image-dir
emojify-display-style emojify-saved-display-style
emojify-inhibit-major-modes emojify-saved-inhibit-major-modes
emojify-inhibit-in-buffer-functions emojify-saved-inhibit-in-buffer-functions