       (goto-char 0)
       (while  (re-search-forward regexp nil t)
 	(setq candidate (match-string-no-properties 1))
-	(unless (member candidate candidates)
-	  (when (and doc candidate)
-	    (put (intern candidate) :document (match-string-no-properties 0)))
-	  (push candidate candidates)
+	(unless (or (member candidate candidates) (and already-matched (listp already-matched) (member candidate already-matched)))
+	  (push (cons candidate (match-string-no-properties 0)) candidates)
 	  ))
       ;; Search forward
       (nreverse candidates))))
+
+(defun ojs-find-candidates-from-regexp-in-buffers (regexp )
+  (let (candidates)
+    (dolist (buffer (buffer-list))
+      (when (derived-mode-p (buffer-local-value 'major-mode buffer))
+	(with-current-buffer buffer
+	  (let ((found (ojs-find-candidates-from-regexp regexp candidates)))
+	    (setq candidates (append candidates found))))))
+    candidates))
 
 ;;;;; configuration of the hook
 


(defun ojs-functions-ac-candidates ()
  (or *ojs-functions-candidates-cache*
      (setq *ojs-functions-candidates-cache* (ojs-find-candidates-from-regexp *ojs-functions-regexp* t))
      ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; find methods defined in the current file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; (:require-patch "")
;;;; HISTORY :
;;;; $Log$
;;;; Revision 3.5  2014/11/04 12:46:44  troche
;;;; * get functions methods and vars from all ojs buffers
;;;;
;;;; Revision 3.4  2014/10/31 16:10:14  troche
;;;; * match all items
;;;;
