Home

Awesome

quick-sdcv.el - Emacs offline dictionary using 'sdcv'

Build Status License

The quick-sdcv package serves as a lightweight Emacs interface for the sdcv command-line interface, which is the console version of the StarDict dictionary application.

This package enables Emacs to function as an offline dictionary.

This integration allows users to access and utilize sdcv dictionary functionalities directly within the Emacs environment, leveraging the capabilities of sdcv to look up words and translations from various dictionary files.

Here are the main interactive functions:

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->

Table of Contents

<!-- markdown-toc end -->

Installation

Prerequisite: The sdcv command. It can usually be installed by installing the sdcv package.

Install with straight

To install quick-sdcv with straight.el:

  1. It if hasn't already been done, add the straight.el bootstrap code to your init file.
  2. Add the following code to the Emacs init file:
(use-package quick-sdcv
  :ensure t
  :straight (quick-sdcv
             :type git
             :host github
             :repo "jamescherti/quick-sdcv.el")
  :custom
  (quick-sdcv-dictionary-prefix-symbol "►")
  (quick-sdcv-ellipsis " ▼ "))

Usage

To retrieve the word under the cursor and display its definition in a buffer:

(quick-sdcv-search-at-point)

To prompt the user for a word and display its definition in a buffer:

(quick-sdcv-search-input)

Customizations

To create a unique buffer for each word lookup, set the following:

(setq quick-sdcv-unique-buffers t)

To perform exact word searches (as opposed to fuzzy searches), use:

(setq quick-sdcv-exact-search t)

To change the prefix character used before dictionary names, replacing the default -->, set:

(setq quick-sdcv-dictionary-prefix-symbol "►")

To customize the sdcv history size:

(setq quick-sdcv-hist-size 100)

To specify the path to the sdcv executable:

(setq quick-sdcv-program "/path/to/sdcv")

To customize the naming convention of the SDCV buffer:

(setq quick-sdcv-buffer-name-prefix "*sdcv"
      quick-sdcv-buffer-name-separator ":"
      quick-sdcv-buffer-name-suffix "*")

To specify a list of dictionaries:

(setq quick-sdcv-dictionary-complete-list '("stardict-WordNet"
                                            "stardict-Webster"
                                            "stardict-eng_eng_main"))

Usage

Below are the commands you can use:

CommandDescription
quick-sdcv-search-at-pointSearches the word around the cursor and displays the result in a buffer.
quick-sdcv-search-inputSearches the input word and displays the result in a buffer.

If the current mark is active, the quick-sdcv will translate the region string; otherwise, they will translate the word around the cursor.

Frequently asked question

How to make the sdcv buffer replace the current buffer?

To make K search for the word using quick-sdcv when editing Markdown, you can customize the behavior as follows:

(add-to-list 'display-buffer-alist '("\\*sdcv"
                                       (display-buffer-same-window)))

How to make links appear as links in an sdcv buffer?

To ensure that links appear as clickable links in the SDCV buffer while using quick-sdcv, add the following hook:

(add-hook 'quick-sdcv-mode-hook #'goto-address-mode)

Evil mode: How to configure the default K key to search for words using quick-sdcv?

In Evil mode, the K key in normal mode is typically bound to lookup the word under the cursor. By default, this usually triggers a help function.

To make K search for the word using quick-sdcv when editing, for instance, a markdown file (e.g. README.md), you can customize the behaviour as follows:

(add-hook 'markdown-mode-hook
          #'(lambda()
              (setq-local evil-lookup-func #'quick-sdcv-search-at-point)))

To make K look up a word in quick-sdcv buffers, you can also customize the evil-lookup-func variable using:

(add-hook 'quick-sdcv-mode-hook
          #'(lambda()
              (setq-local evil-lookup-func #'quick-sdcv-search-at-point)))

What is the difference between sdcv (MELPA) and quick-sdcv Emacs packages?

The quick-sdcv Emacs package is a fork of sdcv.el version 3.4, which is available on MELPA. The primary differences between the two packages are as follows:

Links

Other Emacs packages by the same author: