Initial Commit
[packages] / mule-packages / edict / dui-registry.el
1 ;;; dui-registry.el --- Registry of dui dictionary methods
2
3 ;; Copyright (C) 1998 Free Software Foundation
4
5 ;; Author:      Stephen J. Turnbull <stephen@xemacs.org>
6 ;; Keywords:    mule, dictionary
7 ;; Version:     0.6
8
9 ;;   This file is part of XEmacs.
10
11 ;;   XEmacs is free software; you can redistribute it and/or modify it
12 ;;   under the terms of the GNU General Public License as published by
13 ;;   the Free Software Foundation; either version 2, or (at your
14 ;;   option) any later version.
15
16 ;;   XEmacs is distributed in the hope that it will be useful, but
17 ;;   WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;;   General Public License for more details.
20 ;; 
21 ;;   You should have received a copy of the GNU General Public License
22 ;;   along with XEmacs; if not, write to the Free Software Foundation,
23 ;;   Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 ;;; Commentary:
26
27 ;;; To do:
28
29 ;;; Changelog:
30
31 ;; 1998-04-08  Stephen Turnbull  <stephen@xemacs.org>
32 ;;        (created):  broken out from edict.el
33
34 ;;; Code:
35
36 (require 'dui)
37
38 (dui-register-method
39  "ispell word"
40  'search
41  'ispell-word
42  "Invokes ispell on the word at point.
43
44 Heaven only knows what will happen if it's Japanese.")
45
46 (defun edict-search-english-wrapper ()
47   "Interface `edict-search-english' to `dui-invoke-method'."
48   (edict-search-english nil))
49
50 ;; Probably could do without the wrapper:
51 ;  (dui-register-method
52 ;    "EDICT search english"
53 ;    'search
54 ;    'edict-search-english
55 ;    "Attempts to translate the english word we are looking at. Picks the word 
56 ;  in the same way as ispell, ie backs up from whitespace, and then expands.
57 ;
58 ;  Result is presented in a window that is not selected."
59 ;    nil)
60
61 (dui-register-method
62   "EDICT search English"
63   'search
64   'edict-search-english-wrapper
65   "Attempts to translate the english word we are looking at. Picks the word 
66 in the same way as ispell, ie backs up from whitespace, and then expands.
67
68 Result is presented in a window that is not selected.")
69
70 (defun edict-search-kanji-wrapper ()
71   "Interface `edict-search-kanji' to `dui-invoke-method'."
72   (let ((m (mark))
73         (p (point)))
74     (cond
75      ((null m)
76       (error "Please set the region around the Japanese phrase to look up."))
77      ((< m p) (edict-search-kanji nil m p))
78      (t (edict-search-kanji nil p m)))))
79
80 (dui-register-method
81   "EDICT search Japanese"
82   'search
83   'edict-search-kanji-wrapper
84   "Attempts to translate the Japanese `word' between mark and point.
85
86 Verbs and adjectives will be deinflected, common auxiliaries and suffixes
87 removed, and all resulting candidates looked up.
88
89 Result is presented in a window that is not selected.")
90
91 ;; Make it default
92 (or (featurep 'dui-registry)
93     (setq dui-method-history
94           (cons "EDICT search Japanese" dui-method-history)))
95
96 (defun edict-add-kanji-wrapper ()
97   "Interface `edict-add-kanji' to `dui-invoke-method'."
98   (let ((m (mark))
99         (p (point)))
100     (cond
101      ((null m)
102       (error "Please mark the Japanese word to add to your private dictionary."))
103      ((< m p) (edict-add-kanji m p))
104      (t (edict-add-kanji p m)))))
105
106 (dui-register-method
107   "EDICT add Japanese to private dictionary"
108   'insert
109   'edict-add-kanji-wrapper
110   "Adds the Japanese `word' between mark and point to the private dictionary.
111
112 The entry is formatted for EDICT, and edict-edit-mode is entered.")
113
114 (dui-register-method
115   "EDICT add English to private dictionary"
116   'insert
117   'edict-add-kanji-wrapper
118   "Adds the English word near point to the private dictionary.
119
120 The entry is formatted for EDICT, and edict-edit-mode is entered.")
121
122 ;(dui-princ-errors)
123
124 (provide 'dui-registry)
125
126 ;;; dui-registry.el ends here