Skip to content

Instantly share code, notes, and snippets.

@takaxp takaxp/dict-app.el
Last active Aug 29, 2015

What would you like to do?
Displaying content through
;;; dict-app.el --- Displaying content through
;; Copyright (C) 2014 Takaaki ISHIKAWA
;; Author: Takaaki ISHIKAWA <takaxp at ieee dot org>
;; Maintainer: Takaaki ISHIKAWA <takaxp at ieee dot org>
;; Twitter: @takaxp
;; Repository:
;; Keywords: dictionary,
;; Committers:
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Requirement:
;;; Usage:
;; 1. Put this elisp into your load-path
;; 2. Add (require 'dict-app) in your .emacs
;; 3. Call dict-app-search on a query word
;;; Recommended minimum settings:
;;; Note:
;; - this elisp is based on a lisp shared in
;; -
(defconst dict-app "1.0.1"
"The version number of the dict-app.el")
(defgroup dict-app nil
"User variables for dict-app."
:group 'dict-app)
(defvar dict-app-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "q") 'dict-app-quit)
"The default key bindings for dict-app.")
(defvar dict-app-mode nil)
(defvar display-dict-app-string nil)
(defvar dict-app-buffer-name "dict-app-result")
(defvar dict-bin-name ""
" is CLI for connecting with
This command should be placed in exec-path.
see also")
(define-minor-mode dict-app-mode
"Displaying content through
:lighter " D"
:keymap dict-app-mode-map
:group 'dict-app
(defun dict-app-search ()
"Lookup a word through"
(;; on the dict-app-result buffer
(equal (buffer-name) dict-app-buffer-name)
(setq buffer-read-only nil)
(set-buffer-modified-p t))
;; not on the dict-app-buffer-name, but dict-app-buffer-name exists
((get-buffer dict-app-buffer-name)
(kill-buffer dict-app-buffer-name))
(t nil))
(let ((editable (not buffer-read-only))
(pt (save-excursion (mouse-set-point last-nonmenu-event)))
beg end)
(if (and mark-active
(<= (region-beginning) pt) (<= pt (region-end)) )
(setq beg (region-beginning)
end (region-end))
(goto-char pt)
(setq end (progn (forward-word) (point)))
(setq beg (progn (backward-word) (point)))
(let ((word (buffer-substring-no-properties beg end))
(tmpbuf dict-app-buffer-name))
(pop-to-buffer tmpbuf)
(insert "Query: " word "\n\n")
(start-process "dict-process" tmpbuf dict-bin-name word)
(goto-char 0)
(dict-app-mode t)
(setq buffer-read-only t)
(set-buffer-modified-p nil))))
(defun dict-app-quit ()
"Delete the window and quit dict-app."
(when (equal (buffer-name) dict-app-buffer-name)
(kill-buffer dict-app-buffer-name))
(message "Quit"))
;;; Internal functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun da-setup ()
;; do nothing
(defun da-abort ()
;; do nothing
(provide 'dict-app)
;;; dict-app.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.