 				    ;; return nil when we have a scan error
 				    (scan-error nil))
 				  ;; try to find a lonely }, search only until the next start of function
-				  (re-search-forward "^}$" (save-excursion (re-search-forward *ojs-function-start-regexp* nil t)
-									   (line-beginning-position))
-						     t))))
+				  (re-search-forward "^}$" (save-excursion (or (when (re-search-forward *ojs-function-start-regexp* nil t)
+										 (line-beginning-position))
+									       (point-max)))
+						     t)
+				  )))
 	    (when (and function-end
 		       (>= function-end start-point))
 	      (cons function-start function-end))))))))


(defvar *ojs-kernel-functions-present* t)

(defun list-ojs-kernel-functions ()
  (cond (*ojs-kernel-functions-cache*
	 *ojs-kernel-functions-cache*)
	(*ojs-kernel-functions-present*
	 (progn (setq *ojs-kernel-functions-present* (when (fi::lep-open-connection-p) (fi:eval-in-lisp "(if (fboundp 'jvs::list-all-js-functions) t nil)")))
		(when *ojs-kernel-functions-present*
		  (setq *ojs-kernel-functions-cache* (format "\\(%s\\)" (js--regexp-opt-symbol (when (fi::lep-open-connection-p) (fi:eval-in-lisp "(jvs::list-all-js-functions)"))))))
		*ojs-kernel-functions-cache*))
	(t
	 nil)))

(defun search-kernel-functions (end)
  (when (list-ojs-kernel-functions)
    (let ((search-pattern (list-ojs-kernel-functions)))
      (re-search-forward search-pattern end t))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; highlight locally defined vars

;;;; (:require-patch "")
;;;; HISTORY :
;;;; $Log$
;;;; Revision 3.9  2015/12/15 13:39:48  troche
;;;; * limit size of regexps in kernel functions
;;;;
;;;; Revision 3.8  2015/12/14 15:33:23  troche
;;;; * debug
;;;;
