diff -r 4769d4b48590 -r 5a5be84a113d contrib/gadict.el --- a/contrib/gadict.el Sat Jan 21 00:15:20 2017 +0200 +++ b/contrib/gadict.el Thu Jan 26 22:40:25 2017 +0200 @@ -157,7 +157,10 @@ (put 'gadict-tr 'safe-local-variable 'string-or-null-p) (defun gadict-insert-template (&optional headword) - "Insert new article template after the current place." + "Insert new article template after the current place. + +If `gadict-espeak-enabled' is `t' pronunciation will be filled +with espeak `gadict-espeak-default-voice'." (interactive) (if (re-search-forward "^__" nil t) (beginning-of-line) @@ -179,8 +182,15 @@ (backward-char) (when headword (insert headword) - (insert "\n []") - (backward-char))) + (insert "\n [") + (if gadict-espeak-enabled + (progn + (insert (gadict-espeak-ipa headword gadict-espeak-default-voice)) + (insert "]") + (when gadict-tr + (search-forward ": "))) + (insert "]") + (backward-char)))) (defun gadict-search-floor (headword) "Move to HEADWORD definition or place on posiiton for new corresponding @@ -280,11 +290,16 @@ (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--trim @@ -343,6 +358,7 @@ (gadict-setup-indent) (gadict-setup-expansions) (when (executable-find gadict-espeak-program) + (setq gadict-espeak-enabled t) (gadict-espeak-ipa-enable))) (provide 'gadict)