Function: semanticdb-current-database-list

semanticdb-current-database-list is a byte-compiled function defined in db.el.gz.

Signature

(semanticdb-current-database-list &optional DIR)

Documentation

Return a list of databases associated with the current buffer.

If optional argument DIR is non-nil, then use DIR as the starting directory. If this buffer has a database, but doesn't have a project associated with it, return nil. First, it checks semanticdb-project-root-functions, and if that has no results, it checks semanticdb-project-roots. If that fails, it returns the results of function semanticdb-current-database(var)/semanticdb-current-database(fun). Always append semanticdb-project-system-databases if semanticdb-search-system is non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/db.el.gz
(defun semanticdb-current-database-list (&optional dir)
  "Return a list of databases associated with the current buffer.
If optional argument DIR is non-nil, then use DIR as the starting directory.
If this buffer has a database, but doesn't have a project associated
with it, return nil.
First, it checks `semanticdb-project-root-functions', and if that
has no results, it checks `semanticdb-project-roots'.  If that fails,
it returns the results of function `semanticdb-current-database'.
Always append `semanticdb-project-system-databases' if
`semanticdb-search-system' is non-nil."
  (let ((root nil)			; found root directory
	(dbs nil)			; collected databases
	(roots semanticdb-project-roots) ;all user roots
	(dir (file-truename (or dir default-directory)))
	)
    ;; Find the root based on project functions.
    (setq root (run-hook-with-args-until-success
		'semanticdb-project-root-functions
		dir))
    (if root
	(setq root (file-truename root))
      ;; Else, Find roots based on strings
      (while roots
	(let ((r (file-truename (car roots))))
	  (if (string-match (concat "^" (regexp-quote r)) dir)
	      (setq root r)))
	(setq roots (cdr roots))))

    ;; If no roots are found, use this directory.
    (unless root (setq root dir))

    ;; Find databases based on the root directory.
    (when root
      ;; The rootlist allows the root functions to possibly
      ;; return several roots which are in different areas but
      ;; all apart of the same system.
      (let ((regexp (concat "^" (regexp-quote root)))
	    (adb semanticdb-database-list) ; all databases
	    )
	(while adb
	  ;; I don't like this part, but close enough.
	  (if (and (slot-boundp (car adb) 'reference-directory)
		   (string-match regexp (oref (car adb) reference-directory)))
	      (setq dbs (cons (car adb) dbs)))
	  (setq adb (cdr adb))))
      )
    ;; Add in system databases
    (when semanticdb-search-system-databases
      (setq dbs (nconc dbs semanticdb-project-system-databases)))
    ;; Return
    dbs))