aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Hilbrich <torsten.hilbrich@gmx.net>2001-07-06 22:51:00 +0200
committerTorsten Hilbrich <torsten@hilbrich.net>2011-08-27 20:47:38 +0200
commitac0f2756e83f9c216f1e365cacb07f6369cb15c8 (patch)
treed3aa670da79bea605a83fd1130a01b87d61633ff
parent7a078122248883ca70b6defcdc7305c92fa4bc2b (diff)
Imported version 1.4 from tarball
added popup menu for easier lookup of words
-rw-r--r--Makefile2
-rw-r--r--README93
-rw-r--r--debian/changelog6
-rw-r--r--debian/files2
-rw-r--r--dictionary-init.el4
-rw-r--r--dictionary.el144
6 files changed, 181 insertions, 70 deletions
diff --git a/Makefile b/Makefile
index bcac5c8..9d7e829 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
EMACS=emacs
-VERSION=1.3
+VERSION=1.4
PACKAGE=dictionary
TYPE=comm
XEMACS-PACKAGE=$(PACKAGE)-$(VERSION)-pkg.tar.gz
diff --git a/README b/README
index ceaed67..1a21c0d 100644
--- a/README
+++ b/README
@@ -27,15 +27,18 @@
* easy selection of dictionary and search strategy
* backward moving through the visited definitions
- Here is a sample screenshot showing the dictionary mode in action
+ Here are two ample screenshot showing the dictionary mode in action
within an Emacs 21 buffer:
- [dictionary-1.png]
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 looking for matching words to
+ possible. You can now select one of the found entries or ignore the
+ search by pressing any mouse button outside the menu.
+
Download and Requirements
I have tested the package with a native GNU Emacs 19.34.1 and XEmacs
@@ -43,17 +46,18 @@
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.3.3) of this package
- * [6]Version 1.2.1 of this package
- * [7]Version 1.1 of this package
- * [8]Initial version (1.0) of this package
+ * [5]Current version (1.4) of this package
+ * [6]Version 1.3.3 of this package
+ * [7]Version 1.2.1 of this package
+ * [8]Version 1.1 of this package
+ * [9]Initial version (1.0) of this package
I you want to know more about the differences please look at the
- [9]ChangeLog.
+ [10]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 [10]current version.
+ download the [11]current version.
For best usability I suggest using the mouse, but it provide good
keyboard support as well.
@@ -61,14 +65,14 @@
Unpacking the archive
The package is distributed as tar.gz file. You unpack it using:
-gzip -dc dictionary-1.3.3.tar.gz | tar xf -
+gzip -dc dictionary-1.4.tar.gz | tar xf -
or
-tar -xzf dictionary-1.3.3.tar.gz
+tar -xzf dictionary-1.4.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.3.3 has been created
+ unpacking the archive a directory dictionary-1.4 has been created
containing the necessary files.
Installation
@@ -80,12 +84,12 @@ Debian
dpkg-buildpackage) you can use the supplied debian support.
make debian
- This will create a package named dictionary-1.3.3-1_i386.deb or
- similiar in the parent directory of dictionary-1.3.3. 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.4-1_i386.deb or similiar
+ in the parent directory of dictionary-1.4. 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
@@ -137,11 +141,18 @@ Manually
"Unconditionally lookup the word at point." t)
(autoload 'dictionary "dictionary"
"Create a new dictionary buffer" t)
+(autoload 'dictionary-mouse-popup-matching-words "dictionary"
+ "Display entries matching the word at the cursor" t)
+(autoload 'dictionary-popup-matching-words "dictionary"
+ "Display entries matching the word at the point" t)
In addition, some key bindings for faster access can be useful. I use
the following ones in my installation:
(global-set-key [(control c) ?s] 'dictionary-search)
(global-set-key [(control c) ?m] 'dictionary-match-words)
+(if (boundp 'running-xemacs)
+ (global-set-key [(control button3)] 'dictionary-mouse-popup-matching-words)
+ (global-set-key [mouse-3] 'dictionary-mouse-popup-matching-words))
I will describe the user-callable functions and the key bindings
within dictionary mode later in this document.
@@ -190,7 +201,7 @@ Glossary
Invoking
- There are four different (documented) ways of invoking the package. By
+ 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.
@@ -202,6 +213,19 @@ Invoking
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 above sample keyboard
+ definition binds this command to the right mouse button in GNU Emacs
+ and to ctrl + right mouse button in XEmacs. If you want this function
+ using a mouse event use the dictionary-mouse-popup-matching-words, for
+ assigning to 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
+ 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.
+
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
@@ -343,8 +367,9 @@ Getting Help
Thanks
I want to thank Sam Steingold, Baoqiu Cui, Bruce Ravel, Pavel Janík,
- Sergei Pokrovsky, Jeff Mincy, Serge Boiko, Enrico Scholz for their
- valuable suggestions (including patches) for improving this package.
+ Sergei Pokrovsky, Jeff Mincy, Serge Boiko, Enrico Scholz, and Reuben
+ Thomas for their valuable suggestions (including patches) for
+ improving this package.
License
@@ -363,6 +388,10 @@ Getting Help
ChangeLogs
+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
@@ -430,20 +459,26 @@ Version 1.0 - 1.1
_________________________________________________________________
- [11]Torsten Hilbrich
+ [12]Torsten Hilbrich
- Last modified: Fri Jun 29 08:02:46 CEST 2001
+ Last modified: Fri Jul 6 21:55:15 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.3.3.tar.gz
- 6. http://localhost/~torsten/dictionary-1.2.1.tar.gz
- 7. http://localhost/~torsten/dictionary-1.1.tar.gz
- 8. http://localhost/~torsten/dictionary-1.0.tar.gz
- 9. http://localhost/~torsten/dictionary.html#changelog
- 10. http://www.dina.kvl.dk/~abraham/custom/
- 11. mailto:Torsten.Hilbrich@gmx.net
+ 5. http://localhost/~torsten/dictionary-1.4.tar.gz
+ 6. http://localhost/~torsten/dictionary-1.3.3.tar.gz
+ 7. http://localhost/~torsten/dictionary-1.2.1.tar.gz
+ 8. http://localhost/~torsten/dictionary-1.1.tar.gz
+ 9. http://localhost/~torsten/dictionary-1.0.tar.gz
+ 10. http://localhost/~torsten/dictionary.html#changelog
+ 11. http://www.dina.kvl.dk/~abraham/custom/
+ 12. mailto:Torsten.Hilbrich@gmx.net
+
+ Hidden links:
+ 13. http://localhost/~torsten/dictionary-1.png
+ 14. http://localhost/~torsten/dictionary-2.png
diff --git a/debian/changelog b/debian/changelog
index 53e0385..abf296f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+dictionary (1.4-1) unstable; urgency=low
+
+ * support for popup menus
+
+ -- Torsten Hilbrich <Torsten.Hilbrich@gmx.net> Fri, 6 Jul 2001 19:54:54 +0200
+
dictionary (1.3.3-1) unstable; urgency=low
* added support for xemacs 21 packages (no changes for debian)
diff --git a/debian/files b/debian/files
index 2fe6d94..fe8c69f 100644
--- a/debian/files
+++ b/debian/files
@@ -1 +1 @@
-dictionary_1.3.3-1_i386.deb unknown optional
+dictionary_1.4-1_i386.deb unknown optional
diff --git a/dictionary-init.el b/dictionary-init.el
index 5f21a39..5a2c7c2 100644
--- a/dictionary-init.el
+++ b/dictionary-init.el
@@ -6,4 +6,8 @@
"Unconditionally lookup the word at point." t)
(autoload 'dictionary "dictionary"
"Create a new dictionary buffer" t)
+(autoload 'dictionary-mouse-popup-matching-words "dictionary"
+ "Display entries matching the word at the cursor" t)
+(autoload 'dictionary-popup-matching-words "dictionary"
+ "Display entries matching the word at the point" t)
diff --git a/dictionary.el b/dictionary.el
index c27b3bc..e8a9c69 100644
--- a/dictionary.el
+++ b/dictionary.el
@@ -2,7 +2,7 @@
;; Author: Torsten Hilbrich <Torsten.Hilbrich@gmx.net>
;; Keywords: interface, dictionary
-;; $Id: dictionary.el,v 1.20 2001/06/27 16:44:27 torsten Exp $
+;; $Id: dictionary.el,v 1.22 2001/07/06 20:50:18 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
@@ -22,6 +22,7 @@
(eval-when-compile
(require 'cl))
+(require 'easymenu)
(require 'custom)
(require 'connection)
(require 'link)
@@ -60,9 +61,9 @@ This port is propably always 2628 so there should be no need to modify it."
(defcustom dictionary-identification
"dictionary.el emacs lisp dictionary client"
- "This is the identification string that will be send to the server."
+ "This is the identification string that will be sent to the server."
:group 'dictionary
- :type 'number)
+ :type 'string)
(defcustom dictionary-default-dictionary
"*"
@@ -234,21 +235,21 @@ This is a quick reference to this mode describing the default key bindings:
(interactive)
(let ((coding-system nil))
(if (and (boundp 'coding-system-alist)
- (assoc "utf-8" coding-system-alist))
- (setq coding-system 'utf-8))
+ (assoc "utf-8" coding-system-alist))
+ (setq coding-system 'utf-8))
(let ((coding-system-for-read coding-system)
- (coding-system-for-write coding-system))
+ (coding-system-for-write coding-system))
(let ((buffer (generate-new-buffer "*Dictionary buffer*"))
- (window-configuration (current-window-configuration)))
-
- (switch-to-buffer-other-window buffer)
- (dictionary-mode)
-
- (make-local-variable 'dictionary-window-configuration)
- (setq dictionary-window-configuration window-configuration)
- (dictionary-check-connection)
- (dictionary-pre-buffer)
- (dictionary-post-buffer)))))
+ (window-configuration (current-window-configuration)))
+
+ (switch-to-buffer-other-window buffer)
+ (dictionary-mode)
+
+ (make-local-variable 'dictionary-window-configuration)
+ (setq dictionary-window-configuration window-configuration)
+ (dictionary-check-connection)
+ (dictionary-pre-buffer)
+ (dictionary-post-buffer)))))
(unless dictionary-mode-map
(setq dictionary-mode-map (make-sparse-keymap))
@@ -284,18 +285,25 @@ 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)))
- (progn
- (message "Opening connection to %s:%s" dictionary-server
- dictionary-port)
- (connection-close dictionary-connection)
- (setq dictionary-connection
- (connection-open dictionary-server dictionary-port))
- (dictionary-check-initial-reply)
- (dictionary-send-command (concat "client " dictionary-identification))
- (let ((reply (dictionary-read-reply-and-split)))
- (message nil)
- (unless (dictionary-check-reply reply 250)
- (error "Unknown server answer: %s" (dictionary-reply reply)))))))
+ (let ((coding-system nil))
+ (if (and (boundp 'coding-system-alist)
+ (assoc "utf-8" coding-system-alist))
+ (setq coding-system 'utf-8))
+ (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))
+ (dictionary-check-initial-reply)
+ (dictionary-send-command (concat "client " dictionary-identification))
+ (let ((reply (dictionary-read-reply-and-split)))
+ (message nil)
+ (unless (dictionary-check-reply reply 250)
+ (error "Unknown server answer: %s"
+ (dictionary-reply reply))))))))
+
(defun dictionary-mode-p ()
"Return non-nil if current buffer has dictionary-mode"
(eq major-mode 'dictionary-mode))
@@ -309,7 +317,7 @@ This is a quick reference to this mode describing the default key bindings:
;; Dealing with closing the buffer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defun dictionary-close ()
+(defun dictionary-close (&rest ignore)
"Close the current dictionary buffer and its connection"
(interactive)
(if (eq major-mode 'dictionary-mode)
@@ -381,13 +389,12 @@ This function knows about the special meaning of quotes (\")"
"Read an answer delimited by a . on a single line"
(let ((answer (connection-read-to-point dictionary-connection))
(start 0))
- (while (string-match "^\\." answer start)
- (setq answer (replace-match "" t t answer))
- (setq start (match-end 0)))
- (setq start 0)
(while (string-match "\r\n" answer start)
(setq answer (replace-match "\n" t t answer))
(setq start (1- (match-end 0))))
+ (setq start 0)
+ (if (string-match "\n\\.\n.*" answer start)
+ (setq answer (replace-match "" t t answer)))
answer))
(defun dictionary-check-reply (reply code)
@@ -442,13 +449,14 @@ This function knows about the special meaning of quotes (\")"
(defun dictionary-new-search (args &optional all)
"Save the current state and start a new search"
+ (interactive)
(dictionary-store-positions)
- (dictionary-ensure-buffer)
(let ((word (car args))
(dictionary (cdr args)))
(if all
(setq dictionary dictionary-default-dictionary))
+ (dictionary-ensure-buffer)
(dictionary-do-search word dictionary)
(dictionary-store-state 'dictionary-do-search (list word dictionary))))
@@ -485,13 +493,20 @@ This function knows about the special meaning of quotes (\")"
'dictionary-button-face
'dictionary-search nil
"Mouse-2 to look up a new word")
-
(insert " ")
+
(link-insert-link "[Matching words]"
'dictionary-button-face
'dictionary-match-words nil
"Mouse-2 to find matches for a pattern")
+ (insert " ")
+
+ (link-insert-link "[Quit]" 'dictionary-button-face
+ 'dictionary-close nil
+ "Mouse-2 to close this window")
+
(insert "\n ")
+
(link-insert-link "[Select Default Dictionary]"
'dictionary-button-face
'dictionary-select-dictionary nil
@@ -540,6 +555,7 @@ This function knows about the special meaning of quotes (\")"
"Insert the definition for the current word"
(let ((start (point)))
(insert reply)
+ (insert "\n\n")
(let ((regexp "\\({+\\)\\([^ '\"][^}]*\\)\\(}+\\)"))
(goto-char start)
(while (< (point) (point-max))
@@ -726,12 +742,14 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(dictionary-ensure-buffer)
(dictionary-store-positions)
(dictionary-do-matching word dictionary-default-dictionary
- dictionary-default-strategy)
+ dictionary-default-strategy
+ 'dictionary-display-match-result)
(dictionary-store-state 'dictionary-do-matching
(list word dictionary-default-dictionary
- dictionary-default-strategy)))
+ dictionary-default-strategy
+ 'dictionary-display-match-result)))
-(defun dictionary-do-matching (word dictionary strategy)
+(defun dictionary-do-matching (word dictionary strategy function)
"Ask the server about matches to `word' and display it."
(message "Lookup matching words for %s in %s using %s"
@@ -752,7 +770,7 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
word strategy dictionary))
(unless (dictionary-check-reply reply 152)
(error "Unknown server answer: %s" (dictionary-reply reply)))
- (dictionary-display-match-result reply)))
+ (funcall function reply)))
(defun dictionary-display-match-result (reply)
"Display the results from the current matches."
@@ -859,4 +877,52 @@ It presents the word at point as default input and allows editing it."
(setq pattern (read-string "Search pattern: ")))
(dictionary-new-matching pattern))
+;;;###autoload
+(defun dictionary-mouse-popup-matching-words (event)
+ "Display entries matching the word at the cursor"
+ (interactive "@e")
+ (let ((word (save-excursion
+ (mouse-set-point event)
+ (current-word))))
+ (dictionary-popup-matching-words word)))
+
+;;;###autoload
+(defun dictionary-popup-matching-words (&optional word)
+ "Display entries matching the word at the point"
+ (interactive)
+ ;; this is important, otherwise the utf-8 is too late
+ ;; (save-window-excursion
+ ;; (dictionary-ensure-buffer))
+ (unless (functionp 'popup-menu)
+ (error "Sorry, popup menus are not available in this emacs version"))
+ (dictionary-do-matching (or word (current-word))
+ dictionary-default-dictionary
+ "exact"
+ 'dictionary-process-popup-replies))
+
+(defun dictionary-process-popup-replies (reply)
+ (let ((number (nth 1 (dictionary-reply-list reply)))
+ (list (dictionary-simple-split-string (dictionary-read-answer) "\n+")))
+
+ (let ((result (mapcar (lambda (item)
+ (let* ((list (dictionary-split-string item))
+ (dictionary (car list))
+ (word (cadr list)))
+ (if (equal word "")
+ [ "-" nil nil]
+ (vector (concat "[" dictionary "] " word)
+ `(dictionary-new-search
+ '(,word . ,dictionary))
+ t ))))
+
+ list)))
+ (let ((menu (make-sparse-keymap 'dictionary-popup)))
+
+ (easy-menu-define dictionary-mode-map-menu dictionary-mode-map
+ "Menu used for displaying dictionary popup"
+ (cons "Matching words"
+ `(,@result)))
+ (popup-menu dictionary-mode-map-menu)))))
+
(provide 'dictionary)
+