Skip to content

Commit

Permalink
Construct sources on the fly.
Browse files Browse the repository at this point in the history
Allows people to change `helm-dictionary-database` without having to
restart Emacs.
  • Loading branch information
tmalsburg committed Jun 1, 2016
1 parent 9e80ea2 commit 21de838
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions helm-dictionary.el
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,6 @@ browser in `helm-browse-url-default-browser-alist'"
("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 @@ -271,10 +264,16 @@ browser in `helm-browse-url-default-browser-alist'"
;;;###autoload
(defun helm-dictionary ()
(interactive)
(helm :sources (append helm-source-dictionary (list helm-source-dictionary-online))
:full-frame t
:candidate-number-limit 500
:buffer "*helm dictionary*"))
(let ((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))))
(helm :sources (append helm-source-dictionary (list helm-source-dictionary-online))
:full-frame t
:candidate-number-limit 500
:buffer "*helm dictionary*")))

(provide 'helm-dictionary)

Expand Down

0 comments on commit 21de838

Please sign in to comment.