Anonymous avatar Anonymous committed 3ab07c1

- added support for binding tooltip function to any mouse event (requested by Samir Saidani)
- fixed search function to no longer output matching words when using tooltips

Comments (0)

Files changed (1)

   (dictionary-pre-buffer)
   (dictionary-do-search word dictionary function))
 
-(defun dictionary-do-search (word dictionary function)
+(defun dictionary-do-search (word dictionary function &optional nomatching)
   "The workhorse for doing the search"
 
   (message "Searching for %s in %s" word dictionary)
   (let ((reply (dictionary-read-reply-and-split)))
     (if (dictionary-check-reply reply 552)
 	(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))
+	  (unless nomatching
+	    (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)
   (interactive)
   (unwind-protect
       (let ((dictionary (or dictionary dictionary-default-dictionary)))
-	(dictionary-do-search word dictionary 'dictionary-read-definition))
+	(dictionary-do-search word dictionary 'dictionary-read-definition t))
     nil))
   
 (defun dictionary-read-definition (reply)
 
 (defun dictionary-display-tooltip (event)
   "Search the current word in the `dictionary-tooltip-dictionary'."
+  (interactive "e")
   (if dictionary-tooltip-dictionary
       (let ((word (save-window-excursion
 		    (save-excursion
 		      (mouse-set-point event)
 		      (current-word)))))
 	(let ((definition 
-		(dictionary-decode-charset 
-		 (dictionary-definition word 
-					dictionary-tooltip-dictionary)
-		 dictionary-tooltip-dictionary)))
+		(dictionary-definition word dictionary-tooltip-dictionary)))
 	  (if definition 
-	      (tooltip-show definition))
+	      (tooltip-show 
+	       (dictionary-decode-charset definition 
+					  dictionary-tooltip-dictionary)))
 	  t))
     nil))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.