Anonymous avatar Anonymous committed c1fba2f

(eudc-expand-inline): Bug fix for multi-word queries
on multiple servers
(toplevel): removed definition of `split-string' for FSF Emacs

Comments (0)

Files changed (1)

 (defconst eudc-xemacs-p (string-match "XEmacs" emacs-version))
 (defconst eudc-emacs-p (not eudc-xemacs-p))
 (defconst eudc-xemacs-mule-p (and eudc-xemacs-p
-				(featurep 'mule)))
+				  (featurep 'mule)))
 (defconst eudc-emacs-mule-p (and eudc-emacs-p
-				  (featurep 'mule)))
+				 (featurep 'mule)))
 
 (defvar eudc-form-widget-list nil)
 (defvar eudc-mode-map nil)
 ;; attribute name
 (defvar eudc-protocol-has-default-query-attributes nil)
 
-
-;;; FSF Gnu Emacs does not provide that one
-(if (not (fboundp 'split-string))
-    (defun split-string (string pattern)
-      "Return a list of substrings of STRING which are separated by PATTERN."
-      (let (parts (start 0))
-	(while (string-match pattern string start)
-	  (setq parts (cons (substring string start (match-beginning 0)) parts)
-		start (match-end 0)))
-	(nreverse (cons (substring string start) parts))
-	)))
-
 (defun eudc-cadr (obj)
   (car (cdr obj)))
 
 					'move)
 		    (goto-char (match-end 0)))
 		(point)))
-	 (words (buffer-substring beg end))
+	 (query-words (split-string (buffer-substring beg end)"[ \t]+"))
+	 words
 	 query
 	 query-alist
-	 (query-format eudc-inline-query-format)
+	 query-format
 	 response
 	 response-string
 	 response-strings
 	 key val cell
 	 (eudc-former-server eudc-server)
 	 (eudc-former-protocol eudc-protocol)
-	 servers
-	 (eudc-inline-query-format (or eudc-inline-query-format
-				       (if (null eudc-protocol-has-default-query-attributes)
-					   '(name)))))
+	 servers)
 
+    ;; Prepare the list of servers to query
     (setq servers (copy-sequence eudc-server-hotlist))
     (setq servers
 	  (cond 
     (if eudc-max-servers-to-query
 	(setq servers (subseq servers 0 (min eudc-max-servers-to-query
 					     (length servers)))))
-	    
-    ;; Prepare the query
-    (setq words (split-string words "[ \t]+"))
-    (if (cdr words)
-      (while (and words query-format)
-	(setq query-alist (cons (cons (car query-format) (car words)) query-alist))
-	(setq words (cdr words)
-	      query-format (cdr query-format)))
 
-      ;; If the same attribute appears more than once, merge
-      ;; the corresponding values
-      (setq query-alist (nreverse query-alist))
-      (while query-alist
-	(setq key (eudc-caar query-alist)
-	      val (eudc-cdar query-alist)
-	      cell (assq key query))
-	(if cell
-	    (setcdr cell (concat val " " (cdr cell)))
-	  (setq query (cons (car query-alist) query)))
-	(setq query-alist (cdr query-alist))))
-
+    ;; Loop on the servers
     (condition-case signal
 	(progn 
 	  (eudc-set-server (caar servers) (cdar servers) t)
 	  (setq servers (cdr servers))
-	  (if (and (null (cdr words))
-		   eudc-protocol-has-default-query-attributes)
-	      (setq query (car words))
-	    (setq query (list (cons 'name (car words)))))
+
+	  (setq query-format (or eudc-inline-query-format
+				 (if (null eudc-protocol-has-default-query-attributes)
+				     '(name))))    
+	  ;; Prepare the query
+	  (setq words query-words)
+	  (if (cdr words)
+	      (progn
+		(while (and words query-format)
+		  (setq query-alist (cons (cons (car query-format) (car words)) 
+					  query-alist))
+		  (setq words (cdr words)
+			query-format (cdr query-format)))
+		;; If the same attribute appears more than once, merge
+		;; the corresponding values
+		(setq query-alist (nreverse query-alist))
+		(while query-alist
+		  (setq key (eudc-caar query-alist)
+			val (eudc-cdar query-alist)
+			cell (assq key query))
+		  (if cell
+		      (setcdr cell (concat val " " (cdr cell)))
+		    (setq query (cons (car query-alist) query)))
+		  (setq query-alist (cdr query-alist))))
+
+	    (if eudc-protocol-has-default-query-attributes
+		(setq query (car words))
+	      (setq query (list (cons 'name (car words))))))
+
 	  (setq response (eudc-query query (eudc-translate-attribute-list 
 					    (cdr eudc-inline-expansion-format))))
 	  (while (and (null response)
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.