Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow helm-dictionary-database to be an alist #27

Merged
merged 1 commit into from
Jun 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions helm-dictionary.el
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,13 @@
:group 'helm)

(defcustom helm-dictionary-database "/usr/share/trans/de-en"
"The file containing the dictionary."
"The file containing the dictionary, or an alist of offline
dictionaries where the key of each entry is the name of the
dictionary and the value is the file."
:group 'helm-dictionary
:type 'file)
:type '(choice
(file)
(alist :key-type string :value-type: file)))

(defcustom helm-dictionary-online-dicts
'(("translate.reference.com de->eng" .
Expand Down Expand Up @@ -237,13 +241,20 @@ browser in `helm-browse-url-default-browser-alist'"
(replace-regexp-in-string
" *{.+}\\| *\\[.+\\]" "" (cdr entry))))


(defvar helm-source-dictionary
(helm-build-in-file-source "Search dictionary" helm-dictionary-database
(defun helm-dictionary-build (name file)
(helm-build-in-file-source name file
:candidate-transformer 'helm-dictionary-transformer
:action '(("Insert source language term" . helm-dictionary-insert-l1term)
("Insert target language term" . helm-dictionary-insert-l2term))))


(defvar helm-source-dictionary
(mapcar
(lambda (x) (helm-dictionary-build (car x) (cdr x)))
(if (stringp helm-dictionary-database)
(list (cons "Search dictionary" helm-dictionary-database))
helm-dictionary-database)))

(defvar helm-source-dictionary-online
(helm-build-sync-source "Look up online"
:match (lambda (_candidate) t)
Expand All @@ -260,7 +271,7 @@ browser in `helm-browse-url-default-browser-alist'"
;;;###autoload
(defun helm-dictionary ()
(interactive)
(helm :sources '(helm-source-dictionary helm-source-dictionary-online)
(helm :sources (append helm-source-dictionary (list helm-source-dictionary-online))
:full-frame t
:candidate-number-limit 500
:buffer "*helm dictionary*"))
Expand Down