emacs-helm / emacs-helm/helm-dictionary

run with a single dictionary and provide default search term

Open
#31 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
33
Forks
12
PR merge metrics
No merged PRs in 30d

Description

i have various dictionaries specified in `helm-dictionary-database` and i'm interested in being able to choose which one of them to use when i run helm-dictionary. i'm mainly interested in this to speed it up. i have dicts for different languages but usually only want to search for a term in one of them at a time.

i'd also like to feed it a default input string, so i can call it from a function and provide the search term.

i came up with this:

```elisp
(defun helm-dictionary (&optional dictionary query)
(interactive)
(let ((helm-source-dictionary
(if dictionary
(helm-dictionary-build (car dictionary) (cdr 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))))
(input (or query (thing-at-point 'word))))
(helm :sources (append helm-source-dictionary (list helm-source-dictionary-online))
:full-frame t
:default input
:candidate-number-limit 500
:buffer "*helm dictionary*")))
```

then i call it like so:

```elisp
(let ((query (fetch-query-string-from-somewhere)))
(helm-dictionary (assoc "de-en" helm-dictionary-database) query)))
```

the dictionary arg seems to work right, though i'm not sure if thats the best way to do it?

and for now the query argument isn't respected by helm's `:default`. i then tried again without my new arg, and, at least for me, it also doesn't seem to use `(thing-at-point 'word)` either. helm-dictionary opens with no default input. am i missing something there?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the helm-dictionary entry point and inspect how helm-dictionary-build creates sources and how the helm call handles :default. Done means a caller can select one dictionary and provide an initial query, while the existing default behavior remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs-lisp
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.