   ;; initialize kernel completion
   (ojs-kernel-ac-init)
 
+  ;; classes completion
+  (ojs-classes-ac-init)
+
   ;; dictionary cache
   (setq *ac-dictionary-candidates-cache* (ac-file-dictionary (concat *opx2-network-folder-work-path* "devenv/el/dict/opx2-js-mode")))
   


(ac-define-source "ojs-classes"
    '((candidates . ojs-classes-ac-candidates)
;      (document . ojs-classes-ac-document)
;      (action . ojs-classes-ac-action)
      (symbol . "c ")
      (requires . -1)))

(defun ojs-classes-ac-action ()
  (message (cdr (assoc candidate *ojs-classes-candidates-cache*))))

(defun ojs-classes-ac-document (docstr)
  docstr)

(defvar *ojs-classes-candidates-cache* nil)

;;(defvar *ojs-classes-regexp* "^[ \t]*var[ \t]+\\(\\w+\\)[ \t]+\\<=\\>[ \t]*\\(.*\\))")
;;(defvar *ojs-classes-regexp* "^[ \t]*var[ \t]+\\(\\w+\\)[ \t]*=.*")
;;(defvar *ojs-classes-regexp* "^[^//].*\\.\\(_\\w+\\)[ \t]*[.,;)!=]*")
(defvar *ojs-classes-regexp* "\\([oO][pP][xX]\\w+\\)")

;; on reset le cache ds qu'on sauve
(ac-clear-variable-after-save '*ojs-classes-candidates-cache*)

;; reset du cache toutes les minutes
;;ac-clear-variable-every-minute '*ojs-functions-candidates-cache*)

(defun ojs-classes-ac-candidates ()
  (or *ojs-classes-candidates-cache*
      (setq *ojs-classes-candidates-cache* (ojs-find-candidates-from-regexp-in-buffers *ojs-classes-regexp*))
      ))

;;; generic ojs dictionary 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(add-hook 'opx2-js-mode-hook 'opx2-js-setup-auto-complete-mode)
(add-hook 'js-evaluator-mode-hook 'opx2-js-setup-auto-complete-mode)
