Fix Warning: reference to free variable.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Thu, 26 Jan 2017 23:08:44 +0200
changeset 745 4679b9e75798
parent 744 4d78dbc5a9b0
child 746 73abbe6d4bd3
Fix Warning: reference to free variable.
contrib/gadict.el
--- a/contrib/gadict.el	Thu Jan 26 23:07:23 2017 +0200
+++ b/contrib/gadict.el	Thu Jan 26 23:08:44 2017 +0200
@@ -38,10 +38,64 @@
   "Remove whitespace at the beginning and end of S."
   (gadict--trim-left (gadict--trim-right s)))
 
+
+
 (defun gadict--espeak-cleanup (s)
   "Cleanup espeak IPA output."
   (replace-regexp-in-string "[\x200D]" "" (gadict--trim s)))
 
+(defvar gadict-espeak-enabled nil
+  "Is espeak used.")
+
+(defvar gadict-espeak-program "espeak")
+(defvar gadict-espeak-program-ipa-args "-q --ipa=2")
+;; "en" "en-gb" "en-us" "en-sc"
+(defvar gadict-espeak-voices-list '("en-gb" "en-us")
+  "What voices to show. Look to 'espeak --voices' for full list.")
+(defvar gadict-espeak-default-voice "en-us"
+  "Default voice for espeak. Used in article template.")
+
+(defun gadict-espeak-ipa (str &optional voice)
+  (gadict--espeak-cleanup
+   (shell-command-to-string
+    (format "%s %s %s %s"
+            gadict-espeak-program
+            gadict-espeak-program-ipa-args
+            (if (stringp voice) (concat "-v" (shell-quote-argument voice)) "")
+            (shell-quote-argument str)))))
+
+(defun gadict-espeak-headline-line (headword)
+  (mapconcat (lambda (voice) (format "%s: %s"
+                                (propertize voice 'face '(:foreground "red"))
+                                (gadict-espeak-ipa headword voice)))
+             (if (listp gadict-espeak-voices-list) gadict-espeak-voices-list '(nil))
+             " | "))
+
+;; (defun gadict-espeak-headline-display ()
+;;   (interactive)
+;;   (message (gadict-espeak-headline-line)))
+
+(defvar gadict-espeak-headline-headword nil)
+
+(defun gadict-espeak-headline-display ()
+  (when (eq major-mode 'gadict-mode)
+    (let ( (headword (condition-case nil (gadict-nearest-headword) (error nil))) )
+      (unless (eq headword gadict-espeak-headline-headword)
+        (setq gadict-espeak-headline-headword headword)
+        (setq header-line-format (if headword (gadict-espeak-headline-line headword) nil))
+        (force-mode-line-update)))))
+
+(defvar gadict-espeak-headline-timer nil)
+(defun gadict-espeak-headline-enable ()
+  (unless gadict-espeak-headline-timer
+    (setq gadict-espeak-headline-timer (run-with-idle-timer 1 t #'gadict-espeak-headline-display))))
+(defun gadict-espeak-headline-disable ()
+  (when gadict-espeak-headline-timer
+    (cancel-timer gadict-espeak-headline-timer))
+  (setq gadict-espeak-headline-timer nil))
+
+
+
 (defconst gadict--pos '("n" "v" "adj" "adv" "pron" "det" "prep" "num" "conj" "int" "phr" "phr.v" "contr" "abbr" "prefix")
   "Defined parts of speech.")
 
@@ -294,56 +348,6 @@
       (match-string 1)
       )))
 
-(defvar gadict-espeak-enabled nil
-  "Is espeak used.")
-
-(defvar gadict-espeak-program "espeak")
-(defvar gadict-espeak-program-ipa-args "-q --ipa=2")
-;; "en" "en-gb" "en-us" "en-sc"
-(defvar gadict-espeak-voices-list '("en-gb" "en-us")
-  "What voices to show. Look to 'espeak --voices' for full list.")
-(defvar gadict-espeak-default-voice "en-us"
-  "Default voice for espeak. Used in article template.")
-
-(defun gadict-espeak-ipa (str &optional voice)
-  (gadict--espeak-cleanup
-   (shell-command-to-string
-    (format "%s %s %s %s"
-            gadict-espeak-program
-            gadict-espeak-program-ipa-args
-            (if (stringp voice) (concat "-v" (shell-quote-argument voice)) "")
-            (shell-quote-argument str)))))
-
-(defun gadict-espeak-headline-line (headword)
-  (mapconcat (lambda (voice) (format "%s: %s"
-                                (propertize voice 'face '(:foreground "red"))
-                                (gadict-espeak-ipa headword voice)))
-             (if (listp gadict-espeak-voices-list) gadict-espeak-voices-list '(nil))
-             " | "))
-
-;; (defun gadict-espeak-headline-display ()
-;;   (interactive)
-;;   (message (gadict-espeak-headline-line)))
-
-(defvar gadict-espeak-headline-headword nil)
-
-(defun gadict-espeak-headline-display ()
-  (when (eq major-mode 'gadict-mode)
-    (let ( (headword (condition-case nil (gadict-nearest-headword) (error nil))) )
-      (unless (eq headword gadict-espeak-headline-headword)
-        (setq gadict-espeak-headline-headword headword)
-        (setq header-line-format (if headword (gadict-espeak-headline-line headword) nil))
-        (force-mode-line-update)))))
-
-(defvar gadict-espeak-headline-timer nil)
-(defun gadict-espeak-headline-enable ()
-  (unless gadict-espeak-headline-timer
-    (setq gadict-espeak-headline-timer (run-with-idle-timer 1 t #'gadict-espeak-headline-display))))
-(defun gadict-espeak-headline-disable ()
-  (when gadict-espeak-headline-timer
-    (cancel-timer gadict-espeak-headline-timer))
-  (setq gadict-espeak-headline-timer nil))
-
 (defun gadict-setup-keymap ()
   "Setup gadict keymap."
   (define-key (current-local-map) [M-return] 'gadict-search)