initial commit
[emacs-init.git] / nxhtml / util / tyda.el
1 ;;; tyda.el --- Lookup words in swe/eng dictionary at tyda.se
2 ;;
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: 2008-08-26T02:51:27+0200 Tue
5 ;; Version: 0.2
6 ;; Last-Updated:
7 ;; URL:
8 ;; Keywords:
9 ;; Compatibility:
10 ;;
11 ;; Features that might be required by this library:
12 ;;
13 ;;   None
14 ;;
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 ;;
17 ;;; Commentary:
18 ;;
19 ;; Lookup swedish or english words in the dictionary at
20 ;;
21 ;;   http://www.tyda.se/
22 ;;
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24 ;;
25 ;;; Change log:
26 ;;
27 ;;
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29 ;;
30 ;; This program is free software; you can redistribute it and/or
31 ;; modify it under the terms of the GNU General Public License as
32 ;; published by the Free Software Foundation; either version 2, or
33 ;; (at your option) any later version.
34 ;;
35 ;; This program is distributed in the hope that it will be useful,
36 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
37 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
38 ;; General Public License for more details.
39 ;;
40 ;; You should have received a copy of the GNU General Public License
41 ;; along with this program; see the file COPYING.  If not, write to
42 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
43 ;; Floor, Boston, MA 02110-1301, USA.
44 ;;
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 ;;
47 ;;; Code:
48
49 (eval-when-compile (require 'appmenu))
50
51 (defun tyda-lookup-word (word)
52   "Look up word WORD at URL `http://tyda.se/'.
53 This site translates between English and Swedish.  The site will
54 be opened in your webbrowser with WORD looked up."
55   (interactive (list (or (thing-at-point 'word)
56                          (read-string "Lookup word: "))))
57   ;; http://tyda.se/search?form=1&w=weird&w_lang=&x=0&y=0
58   (browse-url
59    ;;(concat "http://www.tyda.se/?rid=651940&w=" word)
60    (format "http://tyda.se/search?form=1&w=%s&w_lang=&x=0&y=0" word)
61    ))
62
63 (defvar tyda-appmenu-map
64   (let ((map (make-sparse-keymap)))
65     (define-key map [tyda-lookup]
66       (list 'menu-item "Lookup word at point in Tyda"
67             'tyda-lookup-word))
68     map))
69
70 (defvar tyda-mode-map
71   (let ((map (make-sparse-keymap)))
72     (define-key map [(alt mouse-1)] 'tyda-lookup-word)
73     (define-key map [(control ?c) ?=] 'tyda-lookup-word)
74     map))
75
76 ;;;###autoload
77 (define-minor-mode tyda-mode
78   "Minor mode for key bindings for `tyda-lookup-word'.
79 It binds Alt-Mouse-1 just as the Tyda add-on does in Firefox.
80 Here are all key bindings
81
82 \\{tyda-mode-map}
83 "
84   :global t
85   (if tyda-mode
86       (progn
87         (require 'appmenu nil t)
88         (when (featurep 'appmenu)
89           (appmenu-add 'tyda nil tyda-mode "Lookup word" tyda-appmenu-map)))))
90
91
92 (provide 'tyda)
93 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
94 ;;; tyda.el ends here