diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README | 620 | ||||
-rw-r--r-- | connection.el | 4 | ||||
-rw-r--r-- | debian/changelog | 25 | ||||
-rw-r--r-- | dictionary-init.el | 6 | ||||
-rw-r--r-- | dictionary.el | 667 | ||||
-rw-r--r-- | link.el | 4 | ||||
-rw-r--r-- | lpath.el | 2 |
8 files changed, 750 insertions, 580 deletions
@@ -1,6 +1,6 @@ EMACS=emacs -VERSION=1.5 +VERSION=1.7 PACKAGE=dictionary TYPE=comm XEMACS-PACKAGE=$(PACKAGE)-$(VERSION)-pkg.tar.gz @@ -1,43 +1,46 @@ Emacs package for talking to a dictionary server - + Introduction - - In December 1998 I installed the [1]dictd server, which can be used to - access several dictionaries using a simple protocol as defined in - [2]RFC 2229 (Text Version). - - As my primary working environment is [3]XEmacs 21, I decided to write - an Emacs-Lisp package for accessing this dictionary server. The older - webster.el didn't worked with the newer protocol. After starting the - implementation I was pointed to an already existing implementation, + + In December 1998 I installed the dictd server, which can be used to + access several dictionaries using a simple protocol as defined in + RFC 2229 (Text Version). + + As my primary working environment is XEmacs 21, I decided to write + an Emacs-Lisp package for accessing this dictionary server. The older + webster.el didn't worked with the newer protocol. After starting the + implementation I was pointed to an already existing implementation, but this was basically a wrapper to the dict client program and didn't - have all the features I wanted. - - If you didn't received this file from its original location you can - visit it at [4]http://www.myrkr.in-berlin.de/dictionary.html - + have all the features I wanted and have now been implemented in this + dictionary client. + + If you didn't received this file from its original location you can + visit it at http://www.myrkr.in-berlin.de/dictionary.html + Features - + The dictionary mode provides the following features: * looking up word definitions in all dictionaries * search for matching word - * words/phrases marked with { } in the dictionary definitions are + * words/phrases marked with { } in the dictionary definitions are recognized as hyper links and browseable * easy selection of dictionary and search strategy * backward moving through the visited definitions * in the latest versions of GNU Emacs and XEmacs you get support for popup menus - * in GNU Emacs 21 you can lookup words by simply pointing the mouse + * in GNU Emacs 21 you can lookup words by simply pointing the mouse cursor to them (tool-tips) - + Here are three sample screenshot showing the dictionary mode in action within an Emacs 21 buffer: - - This buffer shows the result of searching the definition for Emacs. - Two entries have been found. The bold text on the top are buttons for - selecting action using the mouse or keyboard, the blue words are hyper - links that points to the definitions of these words. + + This buffer shows the result of searching the definition for + distinguished. A lot of entries have been found, including translation + into german and russian language. The blue words are hyper-links that + points to the definitions of these words. The hyper-link with the + green background will be activated when pressing the middle mouse + button. This buffer shows the result of looking for matching words to possible. You can now select one of the found entries or ignore the @@ -48,101 +51,102 @@ second) the word at cursor is looked up in the configured dictionary. This example shows the german translation for originally, in this context not the right one, ursprünglich would be better. - + Download and Requirements - - I have tested the package with a native GNU Emacs 19.34.1 and XEmacs - 20.4. I implemented some hacks to work with the very very old - custom.el file in the above GNU Emacs. Please update to the current - version whenever possible. XEmacs 21 and Emacs 20 as well as Emacs 21 + + I have tested the package with a native GNU Emacs 19.34.1 and XEmacs + 20.4. I implemented some hacks to work with the very very old + custom.el file in the above GNU Emacs. Please update to the current + version whenever possible. XEmacs 21 and Emacs 20 as well as Emacs 21 have been tested too. - * [5]Current version (1.5.1) of this package - * [6]Version 1.4.1 of this package - * [7]Version 1.3.3 of this package - * [8]Version 1.2.1 of this package - * [9]Version 1.1 of this package - * [10]Initial version (1.0) of this package - - I you want to know more about the differences please look at the - [11]ChangeLog. - + * Current version (1.7) of this package + * Version 1.5.1 of this package + * Version 1.4.1 of this package + * Version 1.3.3 of this package + * Version 1.2.1 of this package + * Version 1.1 of this package + * Initial version (1.0) of this package + + I you want to know more about the differences please look at the + ChangeLog. + You will need the custom package to use this package. For full support - please check if your system knows the defface function, if not please - download the [12]current version. - - For best usability I suggest using the mouse, but it provide good + please check if your system knows the defface function, if not please + download the current version. + + For best usability I suggest using the mouse, but it provide good keyboard support as well. - + Unpacking the archive - + The package is distributed as tar.gz file. You unpack it using: -gzip -dc dictionary-1.5.1.tar.gz | tar xf - +gzip -dc dictionary-1.7.tar.gz | tar xf - or -tar -xzf dictionary-1.5.1.tar.gz +tar -xzf dictionary-1.7.tar.gz - (with the version number subject to change) depending on whether you - are using GNU tar which support the z flag for compression. After - unpacking the archive a directory dictionary-1.5.1 has been created + (with the version number subject to change) depending on whether you + are using GNU tar which support the z flag for compression. After + unpacking the archive a directory dictionary-1.7 has been created containing the necessary files. - + Installation - + Debian - If you are using a current Debian distribution (one that support the - emacsen package system) and have the dpkg-dev installed (for running + If you are using a current Debian distribution (one that support the + emacsen package system) and have the dpkg-dev installed (for running dpkg-buildpackage) you can use the supplied debian support. make debian - This will create a package named dictionary-1.5.1-1_i386.deb or - similiar in the parent directory of dictionary-1.5.1. You can now - install this package as root, it will automatically byte-compile - itself for all installed emacs versions and provide a startup-file - which autoloads this package. In the configuration example given below - you can omit the autoload lines. - + This will create a package named dictionary-1.7-1_i386.deb or similiar + in the parent directory of dictionary-1.7. You can now install this + package as root, it will automatically byte-compile itself for all + installed emacs versions and provide a startup-file which autoloads + this package. In the configuration example given below you can omit + the autoload lines. + If you no longer want to use this package, you can remove it using: dpkg -r dictionary XEmacs 21 - The XEmacs version 21 support so called xemacs packages. These + The XEmacs version 21 support so called xemacs packages. These packages are also supported, you can create them using: make EMACS=xemacs package The created package will be named dictionary-1.5-pkg.tar.gz and stored - within the current directory. If you don't want to install this + within the current directory. If you don't want to install this package manually, you can use the following command, provided you have sufficient privileges (if unsure, login as super user): make EMACS=xemacs package-install - If you have more than one XEmacs versions installed make sure the + If you have more than one XEmacs versions installed make sure the EMACS argument to make points to the current binary. - + Manually Byte compiling - - For faster loading and executing of the package I strongly suggest - that you byte-compile the files. Emacs user please call make within - the create subdirectory, XEmacs user has to specify there favorite + + For faster loading and executing of the package I strongly suggest + that you byte-compile the files. Emacs user please call make within + the create subdirectory, XEmacs user has to specify there favorite tool using make EMACS=xemacs. If your custom package is not up-to-date expect some warnings about free variables. - + Installing the files - - To install the files into your GNU Emacs/XEmacs installation please - copy the *.elc files into a directory being in your load-path - variable. On most installations /usr/lib/emacs/site-lisp or + + To install the files into your GNU Emacs/XEmacs installation please + copy the *.elc files into a directory being in your load-path + variable. On most installations /usr/lib/emacs/site-lisp or /usr/local/lib/emacs/site-lisp are suitable locations. - + Loading the package - + You have to insert some instructions into your .emacs file to load the - dictionary package whenever needed. If you installed this dictionary - package as Debian package or XEmacs package you don't need the - autoloads, they are already supplied. Other users I suggest using the + dictionary package whenever needed. If you installed this dictionary + package as Debian package or XEmacs package you don't need the + autoloads, they are already supplied. Other users I suggest using the following lines: (autoload 'dictionary-search "dictionary" "Ask for a word and search it in all dictionaries" t) @@ -161,247 +165,291 @@ Manually (autoload 'global-dictionary-tooltip-mode "dictionary" "Enable/disable dictionary-tooltip-mode for all buffers" t) - In addition, some key bindings for faster access can be useful. I use + In addition, some key bindings for faster access can be useful. I use the following ones in my installation: ;; key bindings (global-set-key "\C-cs" 'dictionary-search) (global-set-key "\C-cm" 'dictionary-match-words) - I will describe the user-callable functions and the key bindings + I will describe the user-callable functions and the key bindings within dictionary mode later in this document. - + Using the package - + Glossary - Before I start describing how you use this package, please let me + Before I start describing how you use this package, please let me explain some words as they are used in this text: - + word This is a word you want to lookup in the dictionaries verbatim. - + pattern This is used for looking up matching words. A pattern can be as - simple as a single word but also as complex as a POSIX regular - expression. The meaning of a pattern depends on the strategy + simple as a single word but also as complex as a POSIX regular + expression. The meaning of a pattern depends on the strategy used for matching words. - + dictionary - The server can handle several distinct dictionaries. You can + The server can handle several distinct dictionaries. You can select specific dictionaries or ask the server to search in all - dictionaries or until matches or definitions are found. To - search in all dictionaries the special name * is used, the - special name ! requests to search until definitions are found. - For more details please take a look at the standards + dictionaries or until matches or definitions are found. To + search in all dictionaries the special name * is used, the + special name ! requests to search until definitions are found. + For more details please take a look at the standards definition. - + definition A dictionary entry that can be the result of a word search. - + search The operation of looking up a word in the dictionaries. - + match - The operation of comparing a pattern to all words in the + The operation of comparing a pattern to all words in the dictionary. - + strategy - While matching in a dictionary serveral methods for comparing - words can be used. These methods are named strategies and - include exact match, regular expression match, and soundex - match. The available strategies depends on the server, but a + While matching in a dictionary serveral methods for comparing + words can be used. These methods are named strategies and + include exact match, regular expression match, and soundex + match. The available strategies depends on the server, but a special name . can be used to denote a server-default strategy. - + Invoking There are five different (documented) ways of invoking the package. By - calling dictionary you can start a new dictionary buffer waiting for - your commands. If you want to create multiple buffers for searching - the dictionary, you can run this function multiple times. - dictionary-search will ask for a word a search defaulting to the word + calling dictionary you can start a new dictionary buffer waiting for + your commands. If you want to create multiple buffers for searching + the dictionary, you can run this function multiple times. + dictionary-search will ask for a word a search defaulting to the word at point and present all definitions found. - - If you want to lookup the word near the point without further - confirmation use the dictionary-lookup-definition function. The last + + If you want to lookup the word near the point without further + confirmation use the dictionary-lookup-definition function. The last one is dictionary-match-words which will ask for a pattern and display all matching words. - + You can also display a popup menu showing the definition for a certain - word. You just place the mouse cursor above the word you want to - lookup and press the assigned mouse button. The sample definition in - section [13]Customizing binds this command to the right mouse button - in GNU Emacs and to ctrl + right mouse button in XEmacs. For mouse + word. You just place the mouse cursor above the word you want to + lookup and press the assigned mouse button. The sample definition in + section Customizing binds this command to the right mouse button + in GNU Emacs and to ctrl + right mouse button in XEmacs. For mouse invocation use dictionary-mouse-popup-matching-words, for assigning to - a key combination use the dictionary-popup-matching-words function. + a key combination use the dictionary-popup-matching-words function. The latter function search for the word located at point. - - I have tested this feature in Emacs 21 and XEmacs 21. Emacs 20 do not + + I have tested this feature in Emacs 21 and XEmacs 21. Emacs 20 do not support this kind of popup menus (you will get an error message if you try anyway), XEmacs 20 or prior has not been tested yet. - - A new feature of version 1.5 is the tool-tip support. This will only - work in GNU Emacs 21, XEmacs uses a different mechanism (called - balloon help) which can not easily be adapted. Please note, the + + A new feature of version 1.5 is the tool-tip support. This will only + work in GNU Emacs 21, XEmacs uses a different mechanism (called + balloon help) which can not easily be adapted. Please note, the tool-tip mode may slow down your Emacs, especially if you prefer using the mouse. - - First you have to define the dictionary for looking up words to - display in the tool-tip window. You could use * to search in all + + First you have to define the dictionary for looking up words to + display in the tool-tip window. You could use * to search in all dictionaries, however tool-tip window should be rather small. I use an - english to german dictionary for myself, which is called eng-deu (you + english to german dictionary for myself, which is called eng-deu (you can find out the name if you look into contents of the square brackets - within the dictionary buffer; for example, the line From WordNet (r) + within the dictionary buffer; for example, the line From WordNet (r) 1.6[wn]: tells you the name of this dictionary is wn). (setq dictionary-tooltip-dictionary "eng-deu") - Next you have to decide if you want tool-tip support in the current - buffer only or in all buffers. For the first use the - dictionary-tooltip-mode command, for the latter + Next you have to decide if you want tool-tip support in the current + buffer only or in all buffers. For the first use the + dictionary-tooltip-mode command, for the latter global-dictionary-tooltip-mode. ;; choose on of the following lines (global-dictionary-tooltip-mode 1) (dictionary-tooltip-mode 1) - To turn the tool-tip support off, call these functions with a numeric + To turn the tool-tip support off, call these functions with a numeric argument of 0. - - If you get an error message that the server could not be contacted, - please check the values of the variables dictionary-server and - dictionary-port. The port should usually be 2628, the default server + + If you get an error message that the server could not be contacted, + please check the values of the variables dictionary-server and + dictionary-port. The port should usually be 2628, the default server as distributed is dict.org. - - You can have multiple independent dictionary buffer. If the above - functions are called from within dictionary mode they reuse the + + You can have multiple independent dictionary buffer. If the above + functions are called from within dictionary mode they reuse the existing buffer. Otherwise they create a new buffer. - + Quitting - Once a dictionary buffer is created you can close it by simply typing - q (dictionary-close) or pressing the [Quit] button on the top. - Another, more cruel, way is to use the kill-buffer function which is + Once a dictionary buffer is created you can close it by simply typing + q (dictionary-close) or pressing the [Quit] button on the top. + Another, more cruel, way is to use the kill-buffer function which is handled correctly. - - The dictionary mode save the window configuration on startup and try + + The dictionary mode save the window configuration on startup and try to reestablish it when the buffer is being closed. - + Using the buffer After a successful search the buffer is divided into two sections. The - first one is the button area at the top, the other one is the text - buffer displaying the result. By pressing the buttons you can select + first one is the button area at the top, the other one is the text + buffer displaying the result. By pressing the buttons you can select some functions that are otherwise inaccessible with the mouse. - - In the text are each definition is introduced by the name of the - database that contains it. In the default configuration this text is - in italic face. The definition itself can contains hyper links that - are marked using blue foreground and both sensitive to clicking with + + In the text are each definition is introduced by the name of the + database that contains it. In the default configuration this text is + in italic face. The definition itself can contains hyper links that + are marked using blue foreground and both sensitive to clicking with the mouse and pressing return while being within the link. - - Each link selection or otherwise selected new search or match will - create a new buffer showing the new result. You can use the [Back] - button on the top or the l key (dictionary-previous) to return the + + Each link selection or otherwise selected new search or match will + create a new buffer showing the new result. You can use the [Back] + button on the top or the l key (dictionary-previous) to return the previous buffer contents. - + Pressing Meta while clicking on a link to start the search will extent - the search to all dictionaries (dictionary-default-dictionary to be + the search to all dictionaries (dictionary-default-dictionary to be more precisely). - + If you prefer using the keyboard it can be very frustrating to use the - cursor key to position the point before pressing return to visit the - link is possible. Therefore, I defined the Tab and the n keys to jump - to the next link (dictionary-next-link) and the Shift-Tab and p keys - to jump to the previous one (dictionary-prev-link). Please note that - the Shift-Tab key may be the same as the Tab key when running Emacs + cursor key to position the point before pressing return to visit the + link is possible. Therefore, I defined the Tab and the n keys to jump + to the next link (dictionary-next-link) and the Shift-Tab and p keys + to jump to the previous one (dictionary-prev-link). Please note that + the Shift-Tab key may be the same as the Tab key when running Emacs within a tty (in contrast to a windowing system like X11). There is no - way for a application to differ Shift-Tab from Tab in this case, - please use the p key to visit the previous link if you run into this + way for a application to differ Shift-Tab from Tab in this case, + please use the p key to visit the previous link if you run into this problem. - + Searching - The search operation can be invoked by using the [Search Definition] - button on the top or by pressing s (dictionary-search). It will ask - for a word to search and will default to the word near point. This - allows you to edit the word before starting the search. The found - definitions will be displayed inside the buffer. If no entries could + The search operation can be invoked by using the [Search Definition] + button on the top or by pressing s (dictionary-search). It will ask + for a word to search and will default to the word near point. This + allows you to edit the word before starting the search. The found + definitions will be displayed inside the buffer. If no entries could not be found an error message will be displayed. - - If you want to quickly lookup the word at the point without further - confirmation use the d key (dictionary-lookup-definition). Except for - not allowing to edit the search word before asking the server it + + If you want to quickly lookup the word at the point without further + confirmation use the d key (dictionary-lookup-definition). Except for + not allowing to edit the search word before asking the server it behaves the same way as the normal search operation. - + Matching - The match operation is started upon pressing the [Matching Words] + The match operation is started upon pressing the [Matching Words] button or pressing the m key (dictionary-match-words). It will use the - current database and the current strategy and list matching words for + current database and the current strategy and list matching words for the one you entered at the prompt. The output is grouped by dictionary - and each found word can be looked up by clicking the word or pressing - return. Please note that in some cases not only the requested - definition but some similiar definitions are shown. This behaviour is + and each found word can be looked up by clicking the word or pressing + return. Please note that in some cases not only the requested + definition but some similiar definitions are shown. This behaviour is caused by the keyword lookup in the server. E.g., when you ask for the - definition of from in Webster you will presented with the definitions - of from and Thrust, the latter includes the phrase To thrust away or + definition of from in Webster you will presented with the definitions + of from and Thrust, the latter includes the phrase To thrust away or from which causes the display. - + Selecting dictionary - By default all dictionaries (special name is "*") are searched for a - word definition or for matching words. You can select a specific word - for both modi by pressing the [Select Default Dictionary] button or + By default all dictionaries (special name is "*") are searched for a + word definition or for matching words. You can select a specific word + for both modi by pressing the [Select Default Dictionary] button or the D key (dictionary-select-dictionary). You will get a message about successful selection. - - If you hold Meta while selecting a dictionary you will get more + + If you hold Meta while selecting a dictionary you will get more information displayed instead. - + If you want to restore the original behaviour select All dictionaries. - The first matching dictionary is a special dictionary (named "!") - where the search will stop at the first dictionary with found + The first matching dictionary is a special dictionary (named "!") + where the search will stop at the first dictionary with found definitions or matching words. - + Selection search strategy - While searching matching words to the pattern you entered the server - can use different comparison algorithm (aka search strategy). Every + While searching matching words to the pattern you entered the server + can use different comparison algorithm (aka search strategy). Every server provides a default strategy which is internally known as ".". - - After pressing the [Select Match Strategy] button or pressing the M - key (dictionary-select-strategy) all available strategies on this - server are presented. As in the "select dictionary" mode you can + + After pressing the [Select Match Strategy] button or pressing the M + key (dictionary-select-strategy) all available strategies on this + server are presented. As in the "select dictionary" mode you can select it by pressing the mouse button 2 or typing return. - + Going backward - If you visited a link and want to go back to the previous definition, - simply choose the [Back] button or press the l key + If you visited a link and want to go back to the previous definition, + simply choose the [Back] button or press the l key (dictionary-previous). The buffer contents and cursor position will be - restored. If you intented to go beyond the first definition an error + restored. If you intented to go beyond the first definition an error message will appear. - + Getting Help - If you are totally confused what all the keys do in your dictionary - buffer some help will displayed by pressing the h key. Within XEmacs - you can exit the help screen by pressing q, in GNU Emacs you have to - switch to the help window using C-x o (other-window) first. This help - buffer will display the default key bindings only as I had problems - with displaying multiple bindings for a single function (e.g., both + If you are totally confused what all the keys do in your dictionary + buffer some help will displayed by pressing the h key. Within XEmacs + you can exit the help screen by pressing q, in GNU Emacs you have to + switch to the help window using C-x o (other-window) first. This help + buffer will display the default key bindings only as I had problems + with displaying multiple bindings for a single function (e.g., both button2 and return select a link). Any suggestions are welcome. - + +Proxy support + + Starting from version 1.6 (not officially released) the dictionary + client supports connections via HTTP proxies. It uses the CONNECT + method which is usually used to relay SSL connections through a proxy. + On most proxies the dictionary port (2628) must be configured to be + allowed to connect through the proxy server. You will get an error + message like: +HTTP/1.0 500 WWWOFFLE Server Error + + if this is not the case. + + To enable proxy support, set the variable dictionary-use-http-proxy to + true. This can be done through the customize interface, there is a + sub-group named Dictionary Proxy of the Dictionary group. Other + settings you can modify are the name of the proxy server + (dictionary-proxy-server, Default proxy) and the port of the proxy + server (dictionary-proxy-port, Default 3128). + +Support for different encodings in dictionaries + + Although the standard definition specifies UTF-8 as character encoding + to be used for the protocol there exists dictionaries encoding in + other encodings like koi8-r for the russian language. To support these + dictionaries there exists starting from version 1.7 a variable named + dictionary-coding-systems-for-dictionaries. This is a list of cons + cell containing the dictionary name (as string) and the coding system + to use (as symbol). For modifying the variable the customize interface + should be used, it helps you selecting a valid charset and keeping the + lisp structure intact. + + If a dictionary is not specified in this list its encoding defaults to + UTF-8. + + The default setting + '( ("mueller" . koi8-r)) + + specifies that the koi8-r encoding should be used for the + english-russian dictionary internally called mueller. The internal + dictionary name can be found in brackets within the dictionaries + output buffer after the long dictionary name (for example, the output + From WordNet (r) 1.6[wn] specifies the internal name of the Wordnet + dictionary being wn. + Customizing - - If you have an sufficient recent custom version installed (e.g., the - one provided in XEmacs 20.4) you can use the customize-group with the - dictionary group to customize this package. For using the customize + + If you have an sufficient recent custom version installed (e.g., the + one provided in XEmacs 20.4) you can use the customize-group with the + dictionary group to customize this package. For using the customize buffer please refer to its online help. - - Of course you can set all the variables and hooks you want in the - startup file. Here is a little example that I use for selecting the - server on my local machine and for binding some function to the - user-reserved keys starting from C-c a to C-c z. It also shows how to - invoke popup menus (using the right button in GNU Emacs or ctrl+right + + Of course you can set all the variables and hooks you want in the + startup file. Here is a little example that I use for selecting the + server on my local machine and for binding some function to the + user-reserved keys starting from C-c a to C-c z. It also shows how to + invoke popup menus (using the right button in GNU Emacs or ctrl+right button in XEmacs) and installs the global tooltip-mode. (global-set-key "\C-cs" 'dictionary-search) (global-set-key "\C-cm" 'dictionary-match-words) @@ -417,136 +465,118 @@ Getting Help (global-dictionary-tooltip-mode 1) Thanks - - I want to thank Sam Steingold, Baoqiu Cui, Bruce Ravel, Pavel Janík, - Sergei Pokrovsky, Jeff Mincy, Serge Boiko, Enrico Scholz, Reuben - Thomas, and Rui Zhu for their valuable suggestions (including patches) - for improving this package. - + + I want to thank Sam Steingold, Baoqiu Cui, Bruce Ravel, Pavel Janík, + Sergei Pokrovsky, Jeff Mincy, Serge Boiko, Enrico Scholz, Reuben + Thomas, Rui Zhu, and Eugene Morozov for their valuable suggestions + (including patches) for improving this package. + License - - This file 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 2, or (at your option) any + + This file 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 2, or (at your option) any later version. - - This file is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + + This file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License + + You should have received a copy of the GNU General Public License version 2 along with this package; see the file GPL. - + ChangeLogs - + +Version 1.5.1 - 1.7 + + * added HTTP proxy support (using the CONNECT method) + * added support for dictionaries not encoded in utf-8 (suggested by + Eugene Morozov) + Version 1.5 - 1.5.1 * fixed bug with non-working dictionary-previous (found by Rui Zhu) * fixed key bindings in link.el - + Version 1.4.1 - 1.5 * tool-tip support for GNU Emacs 21 - + Version 1.4 - 1.4.1 * changed recognition of utf-8 support (suggested by Enrico Scholz) - + Version 1.3.3 - 1.4 * added popup menu for easier lookup of words - + Version 1.3.2 - 1.3.3 - * added support for XEmacs 21 packages to ease installation for + * added support for XEmacs 21 packages to ease installation for those users (suggested and reviewed by Enrico Scholz) - + Version 1.3.1 - 1.3.2 - * replaced set-text-properties by remove-text-properties and - add-text-properties because this function is not recommended + * replaced set-text-properties by remove-text-properties and + add-text-properties because this function is not recommended within XEmacs (reported by Serge Boiko) - + Version 1.3 - 1.3.1 - * small fix in dictionary function to check for availability of the - utf-8 encoding to prevent problems in certain xemacs versions + * small fix in dictionary function to check for availability of the + utf-8 encoding to prevent problems in certain xemacs versions (reported by Jeff Mincy) * added debian support (use dpkg-buildpackage to build a package) - + Version 1.2.1 - 1.3 * Implemented an automatic detection for line ends CR/LF and LF. The - variable connection-broken-end-of-line is no longer necessary and + variable connection-broken-end-of-line is no longer necessary and its value ignored. - * Added utf-8 support, the native character set of the dictionary - protocol. Using ISO-8859-1 (aka latin-1) was just a necessary + * Added utf-8 support, the native character set of the dictionary + protocol. Using ISO-8859-1 (aka latin-1) was just a necessary work-around. - + Version 1.2 - 1.2.1 * Corrected dictionary command to draw the button bar. * Improved documentation on dictionary to explicitly mention the use of multiple buffers. - + Version 1.1.1 - 1.2 - * Some users reported problems with GNU Emacs 20.3 and MULE. So I - introduced a new variable connection-broken-end-of-line which + * Some users reported problems with GNU Emacs 20.3 and MULE. So I + introduced a new variable connection-broken-end-of-line which controls whether a line is ended by \n or by \r\n. You can use the customize-group command on dictionary to change the setting of the variable. - + Version 1.1 - 1.1.1 * dictionary-search now allows editing the word to search for - * dictionary-search-word-near-point has been removed, you can use - dictionary-lookup-definition instead. It behaves like + * dictionary-search-word-near-point has been removed, you can use + dictionary-lookup-definition instead. It behaves like dictionary-search but don't allow the search word to be edited (to speed up looking up words). - + Version 1.0 - 1.1 * all dictionary buffers now share a single connection * added kill-all-local-variables * use cons instead of list where possible * dictionary-search now: - + use word as point as default (implementing + + use word as point as default (implementing dictionary-search-word-near-point too) + asks for dictionary with prefix argument * added help-echo tags which are used in XEmacs * mark has been replaced by generic marker - * added messages for communications to the dictionary server that + * added messages for communications to the dictionary server that may take a while * fixed bug with going to the previous link * replaced word-at-point by current-word _________________________________________________________________ - - - [14]Torsten Hilbrich - - Last modified: Tue Jul 17 21:22:58 CEST 2001 - -References - - Visible links - 1. http://www.dict.org/ - 2. http://www.dict.org/rfc2229.txt - 3. http://www.xemacs.org/ - 4. http://www.myrkr.in-berlin.de/dictionary.html - 5. http://localhost/~torsten/dictionary-1.5.1.tar.gz - 6. http://localhost/~torsten/dictionary-1.4.1.tar.gz - 7. http://localhost/~torsten/dictionary-1.3.3.tar.gz - 8. http://localhost/~torsten/dictionary-1.2.1.tar.gz - 9. http://localhost/~torsten/dictionary-1.1.tar.gz - 10. http://localhost/~torsten/dictionary-1.0.tar.gz - 11. http://localhost/~torsten/dictionary.html#changelog - 12. http://www.dina.kvl.dk/~abraham/custom/ - 13. http://localhost/~torsten/dictionary.html#Customizing - 14. mailto:Torsten.Hilbrich@gmx.net - - Hidden links: - 15. http://localhost/~torsten/dictionary-1.png - 16. http://localhost/~torsten/dictionary-2.png - 17. http://localhost/~torsten/dictionary-3.png + + E-Mail: dictionary@myrkr.in-berlin.de + Last modified: Sun Dec 9 21:07:51 CET 2001 + diff --git a/connection.el b/connection.el index 0a284bc..d21d1af 100644 --- a/connection.el +++ b/connection.el @@ -1,8 +1,8 @@ ;;; connection.el -- handling a tcp based connection -;; Author: Torsten Hilbrich <Torsten.Hilbrich@gmx.net> +;; Author: Torsten Hilbrich <dictionary@myrkr.in-berlin.de> ;; Keywords: network -;; $Id: connection.el,v 1.7 2001/04/26 16:56:21 torsten Exp torsten $ +;; $Id: connection.el,v 1.9 2001/11/24 12:18:26 torsten Exp $ ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/debian/changelog b/debian/changelog index a0cbc3f..490c1df 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,29 @@ +dictionary (1.7-1) unstable; urgency=low + + * Added first support for dictionaries with different encodings than + utf-8. + + -- Torsten Hilbrich <email@myrkr.in-berlin.de> Sun, 9 Dec 2001 14:21:57 +0100 + +dictionary (1.6-1) unstable; urgency=low + + * added HTTP proxy support using the CONNECT request type + + -- Torsten Hilbrich <dictionary@myrkr.in-berlin.de> Tue, 4 Dec 2001 20:22:03 +0100 + +dictionary (1.5.3-1) unstable; urgency=low + + * changed name of "select dictionary" button + * "select dictionary" and "select matching strategie" now has a better + feedback (by returning to the previous state) + * added support for non-colored display, the links are surrounded by + braces + + -- Torsten Hilbrich <Torsten.Hilbrich@gmx.net> Sun, 14 Oct 2001 16:08:12 +0200 + dictionary (1.5.2-1) unstable; urgency=low - * popup menu now correctly record the selected window + * popup menu now correctly records the selected window -- Torsten Hilbrich <Torsten.Hilbrich@gmx.net> Sun, 2 Sep 2001 10:40:59 +0200 diff --git a/dictionary-init.el b/dictionary-init.el index dfb022f..792f12b 100644 --- a/dictionary-init.el +++ b/dictionary-init.el @@ -1,3 +1,9 @@ +;; $Id: dictionary-init.el,v 1.1 2001/10/14 14:46:16 torsten Exp $ +;; This file contains the autoload definitions that are used by the +;; debian package and can also be used in a standalone installation +;; The XEmacs package has some other means to create the autoload +;; information. + (autoload 'dictionary-search "dictionary" "Ask for a word and search it in all dictionaries" t) (autoload 'dictionary-match-words "dictionary" diff --git a/dictionary.el b/dictionary.el index 9943ca4..db9cf9c 100644 --- a/dictionary.el +++ b/dictionary.el @@ -1,262 +1,310 @@ -; dictionary.el -- an interface to RFC 2229 dictionary server - -;; Author: Torsten Hilbrich <Torsten.Hilbrich@gmx.net> -;; Keywords: interface, dictionary -;; $Id: dictionary.el,v 1.27 2001/09/02 08:39:47 torsten Exp $ - -;; This file 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 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; 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., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -(eval-when-compile - (require 'cl)) - -(require 'easymenu) -(require 'custom) -(require 'connection) -(require 'link) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Stuff for customizing. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(eval-when-compile - (unless (fboundp 'defface) - (message "Please update your custom.el file: %s" - "http://www.dina.kvl.dk/~abraham/custom/")) - - (unless (fboundp 'defgroup) - (defmacro defgroup (&rest ignored)) - (defmacro defcustom (var value doc &rest ignored) - (list 'defvar var value doc)))) - -(defgroup dictionary nil - "Client for accessing the dictd server based dictionaries" - :group 'help - :group 'hypermedia) - -(defcustom dictionary-server - "dict.org" - "This server is contacted for searching the dictionary" - :group 'dictionary - :type 'string) - -(defcustom dictionary-port - 2628 - "The port of the dictionary server. -This port is propably always 2628 so there should be no need to modify it." - :group 'dictionary - :type 'number) - -(defcustom dictionary-identification - "dictionary.el emacs lisp dictionary client" - "This is the identification string that will be sent to the server." - :group 'dictionary - :type 'string) - -(defcustom dictionary-default-dictionary - "*" - "The dictionary which is used for searching definitions and matching. -* and ! have a special meaning, * search all dictionaries, ! search until -one dictionary yields matches." - :group 'dictionary - :type 'string) - -(defcustom dictionary-default-strategy - "." - "The default strategy for listing matching words." - :group 'dictionary - :type 'string) - -(defcustom dictionary-create-buttons - t - "Create some clickable buttons on top of the window if non-nil" - :group 'dictionary - :type 'boolean) - -(defcustom dictionary-mode-hook - nil - "Hook run in dictionary mode buffers." - :group 'dictionary - :type 'hook) - -(if (fboundp 'defface) - (progn - -(defface dictionary-word-entry-face - '((((type x)) - (:italic t)) - (((type tty) (class color)) - (:foreground "green")) - (t - (:inverse t))) - "The face that is used for displaying the initial word entry line." - :group 'dictionary) - -(defface dictionary-button-face - '((t - (:bold t))) - "The face that is used for displaying buttons." - :group 'dictionary) - -(defface dictionary-reference-face - '((((type x) - (class color) - (background dark)) - (:foreground "yellow")) - (((type tty) - (class color) - (background dark)) - (:foreground "cyan")) - (((class color) - (background light)) - (:foreground "blue")) - (t - (:underline t))) - - "The face that is used for displaying a reference word." - :group 'dictionary) + ;; dictionary.el -- an interface to RFC 2229 dictionary server + + ;; Author: Torsten Hilbrich <dictionary@myrkr.in-berlin.de> + ;; Keywords: interface, dictionary + ;; $Id: dictionary.el,v 1.30 2001/12/09 14:40:04 torsten Exp $ + + ;; This file 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 2, or (at your option) + ;; any later version. + + ;; This file is distributed in the hope that it will be useful, + ;; but WITHOUT ANY WARRANTY; without even the implied warranty of + ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ;; 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., 59 Temple Place - Suite 330, + ;; Boston, MA 02111-1307, USA. + + (eval-when-compile + (require 'cl)) + + (require 'easymenu) + (require 'custom) + (require 'connection) + (require 'link) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Stuff for customizing. + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + (eval-when-compile + (unless (fboundp 'defface) + (message "Please update your custom.el file: %s" + "http://www.dina.kvl.dk/~abraham/custom/")) + + (unless (fboundp 'defgroup) + (defmacro defgroup (&rest ignored)) + (defmacro defcustom (var value doc &rest ignored) + (list 'defvar var value doc)))) + + (defgroup dictionary nil + "Client for accessing the dictd server based dictionaries" + :group 'hypermedia) + + (defgroup dictionary-proxy nil + "Proxy configuration options for the dictionary client" + :group 'dictionary) + + (defcustom dictionary-server + "dict.org" + "This server is contacted for searching the dictionary" + :group 'dictionary + :type 'string) + + (defcustom dictionary-port + 2628 + "The port of the dictionary server. + This port is propably always 2628 so there should be no need to modify it." + :group 'dictionary + :type 'number) + + (defcustom dictionary-identification + "dictionary.el emacs lisp dictionary client" + "This is the identification string that will be sent to the server." + :group 'dictionary + :type 'string) + + (defcustom dictionary-default-dictionary + "*" + "The dictionary which is used for searching definitions and matching. + * and ! have a special meaning, * search all dictionaries, ! search until + one dictionary yields matches." + :group 'dictionary + :type 'string) + + (defcustom dictionary-default-strategy + "." + "The default strategy for listing matching words." + :group 'dictionary + :type 'string) + + (defcustom dictionary-create-buttons + t + "Create some clickable buttons on top of the window if non-nil." + :group 'dictionary + :type 'boolean) + + (defcustom dictionary-mode-hook + nil + "Hook run in dictionary mode buffers." + :group 'dictionary + :type 'hook) + + (defcustom dictionary-use-http-proxy + nil + "Connects via a HTTP proxy using the CONNECT command when not nil." + :group 'dictionary-proxy + :type 'boolean) + + (defcustom dictionary-proxy-server + "proxy" + "The name of the HTTP proxy to use when dictionary-use-http-proxy is set." + :group 'dictionary-proxy + :type 'string) + + (defcustom dictionary-proxy-port + 3128 + "The port of the proxy server, used only when dictionary-use-http-proxy is set." + :group 'dictionary-proxy + :type 'number) + +;; Define only when coding-system-list is available +(when (fboundp 'coding-system-list) + (defcustom dictionary-coding-systems-for-dictionaries + '( ("mueller" . koi8-r)) + "Mapping of dictionaries to coding systems. + Each entry in this list defines the coding system to be used for that + dictionary. The default coding system for all other dictionaries + is utf-8" + :group 'dictionary + :type `(repeat (cons :tag "Association" + (string :tag "Dictionary name") + (choice :tag "Coding system" + :value 'utf-8 + ,@(mapcar (lambda (x) (list 'const x)) + (coding-system-list)) + )))) ) -;; else -(copy-face 'italic 'dictionary-word-entry-face) -(copy-face 'bold 'dictionary-button-face) -(copy-face 'default 'dictionary-reference-face) -(set-face-foreground 'dictionary-reference-face "blue")) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Buffer local variables for storing the current state -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar dictionary-window-configuration - nil - "The window configuration to be restored upon closing the buffer") - -(defvar dictionary-selected-window - nil - "The currently selected window") - -(defvar dictionary-position-stack - nil - "The history buffer for point and window position") + (if (fboundp 'defface) + (progn + + (defface dictionary-word-entry-face + '((((type x)) + (:italic t)) + (((type tty) (class color)) + (:foreground "green")) + (t + (:inverse t))) + "The face that is used for displaying the initial word entry line." + :group 'dictionary) + + (defface dictionary-button-face + '((t + (:bold t))) + "The face that is used for displaying buttons." + :group 'dictionary) + + (defface dictionary-reference-face + '((((type x) + (class color) + (background dark)) + (:foreground "yellow")) + (((type tty) + (class color) + (background dark)) + (:foreground "cyan")) + (((class color) + (background light)) + (:foreground "blue")) + (t + (:underline t))) + + "The face that is used for displaying a reference word." + :group 'dictionary) + + ) + + ;; else + (copy-face 'italic 'dictionary-word-entry-face) + (copy-face 'bold 'dictionary-button-face) + (copy-face 'default 'dictionary-reference-face) + (set-face-foreground 'dictionary-reference-face "blue")) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Buffer local variables for storing the current state + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + (defvar dictionary-window-configuration + nil + "The window configuration to be restored upon closing the buffer") + + (defvar dictionary-selected-window + nil + "The currently selected window") + + (defvar dictionary-position-stack + nil + "The history buffer for point and window position") + + (defvar dictionary-data-stack + nil + "The history buffer for functions and arguments") + + (defvar dictionary-positions + nil + "The current positions") + + (defvar dictionary-current-data + nil + "The item that will be placed on stack next time") + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Global variables + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (defvar dictionary-mode-map + nil + "Keymap for dictionary mode") + + (defvar dictionary-connection + nil + "The current network connection") + + (defvar dictionary-instances + 0 + "The number of open dictionary buffers") + + (defvar dictionary-marker + nil + "Stores the point position while buffer display.") + + (defvar dictionary-color-support + (condition-case nil + (x-display-color-p) + (error nil)) + "Stores the point position while buffer display.") + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Basic function providing startup actions + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + ;;;###autoload + (defun dictionary-mode () + "This is a mode for searching a dictionary server implementing + the protocol defined in RFC 2229. + + This is a quick reference to this mode describing the default key bindings: + + * q close the dictionary buffer + * h display this help information + * s ask for a new word to search + * d search the word at point + * n or Tab place point to the next link + * p or S-Tab place point to the prev link + + * m ask for a pattern and list all matching words. + * D select the default dictionary + * M select the default search strategy + + * Return or Button2 visit that link + * M-Return or M-Button2 search the word beneath link in all dictionaries + " + + (unless (eq major-mode 'dictionary-mode) + (incf dictionary-instances)) + + (kill-all-local-variables) + (buffer-disable-undo) + (use-local-map dictionary-mode-map) + (setq major-mode 'dictionary-mode) + (setq mode-name "Dictionary") + + (make-local-variable 'dictionary-data-stack) + (setq dictionary-data-stack nil) + (make-local-variable 'dictionary-position-stack) + (setq dictionary-position-stack nil) + + (make-local-variable 'dictionary-current-data) + (make-local-variable 'dictionary-positions) + + (make-local-variable 'dictionary-default-dictionary) + (make-local-variable 'dictionary-default-strategy) + + (make-local-hook 'kill-buffer-hook) + (add-hook 'kill-buffer-hook 'dictionary-close t t) + (run-hooks 'dictionary-mode-hook)) + + ;;;###autoload + (defun dictionary () + "Create a new dictonary buffer and install dictionary-mode" + (interactive) + (let ((buffer (generate-new-buffer "*Dictionary buffer*")) + (window-configuration (current-window-configuration)) + (selected-window (frame-selected-window))) + + (switch-to-buffer-other-window buffer) + (dictionary-mode) + + (make-local-variable 'dictionary-window-configuration) + (make-local-variable 'dictionary-selected-window) + (setq dictionary-window-configuration window-configuration) + (setq dictionary-selected-window selected-window) + (dictionary-check-connection) + (dictionary-new-buffer) + (dictionary-store-positions) + (dictionary-store-state 'dictionary-new-buffer nil))) + +(defun dictionary-new-buffer (&rest ignore) + "Create a new and clean buffer" -(defvar dictionary-data-stack - nil - "The history buffer for functions and arguments") - -(defvar dictionary-positions - nil - "The current positions") - -(defvar dictionary-current-data - nil - "The item that will be placed on stack next time") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Global variables -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defvar dictionary-mode-map - nil - "Keymap for dictionary mode") - -(defvar dictionary-connection - nil - "The current network connection") - -(defvar dictionary-instances - 0 - "The number of open dictionary buffers") - -(defvar dictionary-marker - nil - "Stores the point position while buffer display.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Basic function providing startup actions -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;;###autoload -(defun dictionary-mode () - "This is a mode for searching a dictionary server implementing -the protocol defined in RFC 2229. - -This is a quick reference to this mode describing the default key bindings: - -* q close the dictionary buffer -* h display this help information -* s ask for a new word to search -* d search the word at point -* n or Tab place point to the next link -* p or S-Tab place point to the prev link - -* m ask for a pattern and list all matching words. -* D select the default dictionary -* M select the default search strategy - -* Return or Button2 visit that link -* M-Return or M-Button2 search the word beneath link in all dictionaries -" - - (unless (eq major-mode 'dictionary-mode) - (incf dictionary-instances)) - - (kill-all-local-variables) - (buffer-disable-undo) - (use-local-map dictionary-mode-map) - (setq major-mode 'dictionary-mode) - (setq mode-name "Dictionary") - - (make-local-variable 'dictionary-data-stack) - (setq dictionary-data-stack nil) - (make-local-variable 'dictionary-position-stack) - (setq dictionary-position-stack nil) - - (make-local-variable 'dictionary-current-data) - (make-local-variable 'dictionary-positions) - - (make-local-variable 'dictionary-default-dictionary) - (make-local-variable 'dictionary-default-strategy) + (dictionary-pre-buffer) + (dictionary-post-buffer)) - (make-local-hook 'kill-buffer-hook) - (add-hook 'kill-buffer-hook 'dictionary-close t t) - (run-hooks 'dictionary-mode-hook)) - -;;;###autoload -(defun dictionary () - "Create a new dictonary buffer and install dictionary-mode" - (interactive) - (let ((coding-system nil)) - (if (and (functionp 'coding-system-list) - (member 'utf-8 (coding-system-list))) - (setq coding-system 'utf-8)) - (let ((coding-system-for-read coding-system) - (coding-system-for-write coding-system)) - (let ((buffer (generate-new-buffer "*Dictionary buffer*")) - (window-configuration (current-window-configuration)) - (selected-window (frame-selected-window))) - - (switch-to-buffer-other-window buffer) - (dictionary-mode) - - (make-local-variable 'dictionary-window-configuration) - (make-local-variable 'dictionary-selected-window) - (setq dictionary-window-configuration window-configuration) - (setq dictionary-selected-window selected-window) - (dictionary-check-connection) - (dictionary-pre-buffer) - (dictionary-post-buffer))))) (unless dictionary-mode-map (setq dictionary-mode-map (make-sparse-keymap)) @@ -292,17 +340,43 @@ This is a quick reference to this mode describing the default key bindings: "Check if there is already a connection open" (if (not (and dictionary-connection (eq (connection-status dictionary-connection) 'up))) - (let ((coding-system nil)) - (if (and (functionp 'coding-system-list) - (member 'utf-8 (coding-system-list))) - (setq coding-system 'utf-8)) + (let ((wanted 'raw-text) + (coding-system nil)) + (if (and (fboundp 'coding-system-list) + (member wanted (coding-system-list))) + (setq coding-system wanted)) (let ((coding-system-for-read coding-system) (coding-system-for-write coding-system)) (message "Opening connection to %s:%s" dictionary-server dictionary-port) (connection-close dictionary-connection) (setq dictionary-connection - (connection-open dictionary-server dictionary-port)) + (if dictionary-use-http-proxy + (connection-open dictionary-proxy-server + dictionary-proxy-port) + (connection-open dictionary-server dictionary-port))) + + (when dictionary-use-http-proxy + (message "Proxy CONNECT to %s:%d" + dictionary-proxy-server + dictionary-proxy-port) + (dictionary-send-command (format "CONNECT %s:%d HTTP/1.1" + dictionary-server + dictionary-port)) + ;; just a \r\n combination + (dictionary-send-command "") + + ;; read first line of reply + (let* ((reply (dictionary-read-reply)) + (reply-list (dictionary-split-string reply))) + ;; first item is protocol, second item is code + (unless (= (string-to-number (cadr reply-list)) 200) + (error "Bad reply from proxy server %s" reply)) + + ;; skip the following header lines until empty found + (while (not (equal reply "")) + (setq reply (dictionary-read-reply))))) + (dictionary-check-initial-reply) (dictionary-send-command (concat "client " dictionary-identification)) (let ((reply (dictionary-read-reply-and-split))) @@ -350,7 +424,7 @@ This is a quick reference to this mode describing the default key bindings: (defun dictionary-read-reply () "Read the reply line from the server" (let ((answer (connection-read-crlf dictionary-connection))) - (if (string-match "\r" answer) + (if (string-match "\r?\n" answer) (substring answer 0 (match-beginning 0)) answer))) @@ -411,7 +485,33 @@ This function knows about the special meaning of quotes (\")" (let ((number (dictionary-reply-code reply))) (and (numberp number) (= number code)))) + +(defun dictionary-coding-system (dictionary) + "Select coding system to use for that dictionary" + (unless (boundp 'dictionary-coding-systems-for-dictionaries) + nil) + (let ((coding-system + (or (cdr (assoc dictionary + dictionary-coding-systems-for-dictionaries)) + 'utf-8))) + (if (member coding-system (coding-system-list)) + coding-system + nil))) +(defun dictionary-decode-charset (text dictionary) + "Convert the text from the charset defined by the dictionary given." + (let ((coding-system (dictionary-coding-system dictionary))) + (if coding-system + (decode-coding-string text coding-system) + text))) + +(defun dictionary-encode-charset (text dictionary) + "Convert the text to the charset defined by the dictionary given." + (let ((coding-system (dictionary-coding-system dictionary))) + (if coding-system + (decode-coding-string text coding-system) + text))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Communication functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -453,7 +553,6 @@ This function knows about the special meaning of quotes (\")" (goto-char (car position)) (setq dictionary-current-data data))) - ;; The normal search (defun dictionary-new-search (args &optional all) @@ -480,7 +579,8 @@ This function knows about the special meaning of quotes (\")" (message "Searching for %s in %s" word dictionary) (dictionary-send-command (concat "define \"" dictionary "\" \"" - word "\"")) + (dictionary-encode-charset word dictionary) + "\"")) (message nil) (let ((reply (dictionary-read-reply-and-split))) (if (dictionary-check-reply reply 552) @@ -521,11 +621,11 @@ This function knows about the special meaning of quotes (\")" (insert "\n ") - (link-insert-link "[Select Default Dictionary]" + (link-insert-link "[Select Dictionary]" 'dictionary-button-face 'dictionary-select-dictionary nil "Mouse-2 to select dictionary for future searches") - (insert " ") + (insert " ") (link-insert-link "[Select Match Strategy]" 'dictionary-button-face 'dictionary-select-strategy nil @@ -536,6 +636,7 @@ This function knows about the special meaning of quotes (\")" (defun dictionary-post-buffer () "These commands are executed at the end of a new buffer" (goto-char dictionary-marker) + (set-buffer-modified-p nil) (toggle-read-only 1)) @@ -568,24 +669,27 @@ This function knows about the special meaning of quotes (\")" (defun dictionary-display-word-definition (reply word dictionary) "Insert the definition for the current word" (let ((start (point))) - (insert reply) + (insert (dictionary-decode-charset reply dictionary)) (insert "\n\n") (let ((regexp "\\({+\\)\\([^ '\"][^}]*\\)\\(}+\\)")) (goto-char start) (while (< (point) (point-max)) (if (search-forward-regexp regexp nil t) - (progn - (replace-match "\\2") - ;; Compensate for the replacement - (let* ((brace-match-length (- (match-end 1) - (match-beginning 1))) - (match-start (- (match-beginning 2) - brace-match-length)) - (match-end (- (match-end 2) - brace-match-length))) - (dictionary-mark-reference match-start match-end - 'dictionary-new-search - word dictionary))) + (let ((match-start (match-beginning 1)) + (match-end (match-end 2))) + (if dictionary-color-support + (progn + (replace-match "\\2") + ;; Compensate for the replacement + (let ((brace-match-length (- (match-end 1) + (match-beginning 1)))) + (setq match-start (- (match-beginning 2) + brace-match-length)) + (setq match-end (- (match-end 2) + brace-match-length))))) + (dictionary-mark-reference match-start match-end + 'dictionary-new-search + word dictionary)) (goto-char (point-max))))))) (defun dictionary-mark-reference (start end call displayed-word dictionary) @@ -670,6 +774,7 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." (dictionary-display-more-info param) (let ((dictionary (car param))) (setq dictionary-default-dictionary dictionary) + (dictionary-restore-state) (message "Dictionary %s has been selected" dictionary)))) (defun dictionary-display-more-info (param) @@ -749,6 +854,7 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." (defun dictionary-set-strategy (strategy &rest ignored) "Select this strategy as new default" (setq dictionary-default-strategy strategy) + (dictionary-restore-state) (message "Strategy %s has been selected" strategy)) (defun dictionary-new-matching (word) @@ -817,8 +923,10 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." (word-list (cdr item))) (insert "Matches from " dictionary ":\n") (mapcar (lambda (word) + (setq word (dictionary-decode-charset word dictionary)) (insert " ") - (link-insert-link word 'dictionary-reference-face + (link-insert-link word + 'dictionary-reference-face 'dictionary-new-search (cons word dictionary) "Mouse-2 to lookup word") @@ -920,7 +1028,8 @@ It presents the word at point as default input and allows editing it." (let ((result (mapcar (lambda (item) (let* ((list (dictionary-split-string item)) (dictionary (car list)) - (word (cadr list))) + (word (dictionary-decode-charset + (cadr list) dictionary))) (if (equal word "") [ "-" nil nil] (vector (concat "[" dictionary "] " word) @@ -1,8 +1,8 @@ ;;; link.el -- putting clickable links into the buffer -;; Author: Torsten Hilbrich <Torsten.Hilbrich@gmx.net> +;; Author: Torsten Hilbrich <dictionary@myrkr.in-berlin.de> ;; Keywords: interface, hypermedia -;; $Id: link.el,v 1.8 2001/07/17 19:23:55 torsten Exp $ +;; $Id: link.el,v 1.9 2001/11/24 12:18:26 torsten Exp $ ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -1,2 +1,4 @@ +;; Shut up. + (setq load-path (cons "." load-path)) |