Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cute-jumper/bing-dict.el
Minimalists' Bing dictionary for Emacs
https://github.com/cute-jumper/bing-dict.el
bing bing-dict emacs
Last synced: 3 months ago
JSON representation
Minimalists' Bing dictionary for Emacs
- Host: GitHub
- URL: https://github.com/cute-jumper/bing-dict.el
- Owner: cute-jumper
- Created: 2015-04-28T05:12:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-16T01:11:10.000Z (over 4 years ago)
- Last Synced: 2024-05-09T21:03:00.172Z (6 months ago)
- Topics: bing, bing-dict, emacs
- Language: Emacs Lisp
- Homepage:
- Size: 343 KB
- Stars: 53
- Watchers: 7
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bing-dict.el
[![MELPA](http://melpa.org/packages/bing-dict-badge.svg)](http://melpa.org/#/bing-dict)
[![MELPA Stable](http://stable.melpa.org/packages/bing-dict-badge.svg)](http://stable.melpa.org/#/bing-dict)A **minimalists'** Emacs extension to search http://www.bing.com/dict.
Support English to Chinese and Chinese to English.极简主义者的 Emacs 必应词典。 支持中英互译。
## Setup
You can install via [melpa](http://melpa.org).
If installing this package manually:
(add-to-list 'load-path "/path/to/bing-dict.el")
(require 'bing-dict)## Usage
You can call `bing-dict-brief` to get the explanations of you query. The results
will be shown in the echo area.Here is the screenshot:
![bing-dict-screenshot1](./screenshot1.png)
You should probably give this command a key binding:
(global-set-key (kbd "C-c d") 'bing-dict-brief)
## Customization
You can set the value of `bing-dict-add-to-kill-ring` to control whether the
result should be added to the `kill-ring` or not. By default, the value is
`nil`. If set to `t`, the result will be added to the `kill-ring` and you are
able to use `C-y` to paste the result.Also, sometimes synonyms and antonyms could be useful, set
`bing-dict-show-thesaurus` to control whether you need them or not. The value of
`bing-dict-show-thesaurus` could be either `nil`, `'synonym`, `'antonym` or
`'both`. The default value is `nil`. Setting the vaule to `'synonym` or
`'antonym` only shows the corresponding part, and setting it to `'both` will
show both synonyms and antonyms at the same time:(setq bing-dict-show-thesaurus 'both)
The variable `bing-dict-pronunciation-style` controls how the pronunciation is
shown. By default, its value is `'us` and the pronunciation is shown using
"American Phonetic Alphabet" (APA). You can choose the "International Phonetic
Alphabet" (IPA) by setting its value to `'uk` (In fact, any value other than
`'us` will work):(setq bing-dict-pronunciation-style 'uk)
You can also build your own vocabulary by saving all your queries and their
results into `bing-dict-vocabulary-save` (which points to
`~/.emacs.d/var/bing-dict/vocabulary.org` by default):(setq bing-dict-vocabulary-save t)
By setting `bing-dict-vocabulary-file`, you can change where all the queries and
results are saved:(setq bing-dict-vocabulary-file "/path/to/your_vocabulary.org")
screenshot:
![bing-dict-screenshot2](./screenshot2.png)
Use the following configuration if you want bing-dict.el to cache all your
queries and results:(setq bing-dict-cache-auto-save t)
You can customize the value of `bing-dict-cache-file` to change the location
where bing-dict.el stores the cache. The default value is
`~/.emacs.d/var/bing-dict/bing-dict-save.el`.## Command Line Usage
Add the following script to your `PATH` to look up a word from the command line:
```
#!/path/to/emacs --script
(add-to-list 'load-path "/path/to/bing-dict.el")
(require 'bing-dict)
(defun main ()
(bing-dict-brief (format "%s" command-line-args-left) t))
(main)
```## For Features Requests
This extension aims for a quick search for a word. Currently this extension only
parses several sections in the search results and show a brief message in the
echo area using `bing-dict-brief`. I don't plan to write parsers for all the
sections of the search results. At least, for `bing-dict-brief`, it should not
present too much information which may not fit into the echo area.If you want to view the complete results of your query word, there are two
options: using the external browser to do this or contributing to the repo by
adding more parsers. For the first option, the following code could partly
achieve the goal:(browse-url
(concat "http://www.bing.com/dict/search?mkt=zh-cn&q="
(url-hexify-string
(read-string "Query: "))))If you prefer to browse inside Emacs, use `eww` instead:
```
(eww-browse-url
(concat "http://www.bing.com/dict/search?mkt=zh-cn&q="
(url-hexify-string
(read-string "Query: "))))
```Or open the web page in other window:
```
(switch-to-buffer-other-window
(eww-browse-url
(concat "http://www.bing.com/dict/search?mkt=zh-cn&q="
(url-hexify-string
(read-string "Query: ")))))
```For the second option, you're welcome to contribute to this extension by adding
more parsers. For example, you could try to add a parser for the "Sample
Sentences" section. If you're able to write parsers to parse many sections,
which turns out to be too large to be shown in the echo area, you should
probably define a new command, maybe called `bing-dict-complete`. I'm totally OK
with new commands that could present more results, as long as `bing-dict-brief`
remains its original simplicity.