Commits

Anonymous committed b4ae031

- automatic match added when word definition not found

Comments (0)

Files changed (5)

+2002-03-20  Torsten Hilbrich <dictionary@myrkr.in-berlin.de>
+	
+	* dictionary.el (dictionary-do-search): if the word is not found,
+	  lookup similiar words using the match function 
+	  BTW: I had to resolve a conflict here
+
 2002-03-25  Steve Youngs  <youngs@xemacs.org>
 
 	* Makefile (VERSION): 1.08 released.
 # Boston, MA 02111-1307, USA.
 
 VERSION = 1.08
-AUTHOR_VERSION = 1.7
+AUTHOR_VERSION = 1.8
 MAINTAINER = Torsten Hilbrich <dictionary@myrkr.in-berlin.de>
 PACKAGE = dictionary
 PKG_TYPE = regular

Makefile.upstream

 
 EMACS=emacs
 
-VERSION=1.7
+VERSION=1.8
 PACKAGE=dictionary
 TYPE=comm
 XEMACS-PACKAGE=$(PACKAGE)-$(VERSION)-pkg.tar.gz
+dictionary (1.8-1) unstable; urgency=low
+
+  * added search for similiar words when the searched word is not found.
+
+ -- Torsten Hilbrich <dictionary@myrkr.in-berlin.de>  Wed, 20 Mar 2002 21:27:54 +0100
+
 dictionary (1.7.4-1) unstable; urgency=low
 
   * dictionary.el (dictionary-do-matching): removed quotes around
   (message nil)
   (let ((reply (dictionary-read-reply-and-split)))
     (if (dictionary-check-reply reply 552)
-	(error "Word \"%s\" in dictionary \"%s\" not found"
-	       word dictionary)
+	(progn
+	  (beep)
+	  (insert "Word not found, maybe you look for one of these words\n\n")
+	  (dictionary-do-matching word
+				  dictionary
+				  "."
+				  'dictionary-display-only-match-result)
+	  (dictionary-post-buffer))
       (if (dictionary-check-reply reply 550)
 	  (error "Dictionary \"%s\" is unknown, please select an existing one."
 		 dictionary)
 (defun dictionary-display-match-result (reply)
   "Display the results from the current matches."
   (dictionary-pre-buffer)
+  (dictionary-display-only-match-result reply)
+  (dictionary-post-buffer))
+
+(defun dictionary-display-only-match-result (reply)
+  "Display the results from the current matches without the headers."
+
+  (let ((number (nth 1 (dictionary-reply-list reply)))
+	(list (dictionary-simple-split-string (dictionary-read-answer) "\n+")))
+    (insert number " matching word" (if (equal number "1") "" "s")
+	    " found\n\n")
+    (let ((result nil))
+      (mapcar (lambda (item)
+		(let* ((list (dictionary-split-string item))
+		       (dictionary (car list))
+		       (word (cadr list))
+		       (hash (assoc dictionary result)))
+		  (if dictionary
+		      (if hash
+			  (setcdr hash (cons word (cdr hash)))
+		    (setq result (cons 
+				  (cons dictionary (list word)) 
+				  result))))))
+	      list)
+      (dictionary-display-match-lines (reverse result)))))
+
+(defun dictionary-display-match-result (reply)
+  "Display the results from the current matches."
+  (dictionary-pre-buffer)
 
   (let ((number (nth 1 (dictionary-reply-list reply)))
 	(list (dictionary-simple-split-string (dictionary-read-answer) "\n+")))