I did a slight trick to initialize the semanticdb-project-roots
variable, and decided to share the function with you people.
This is a modded version of
I'm kinda surprised this isn't part of emacs, but anyway, here it is
and I hope this is useful for someone.
And of course is this GPL ;)
(defun my-add-subdirs-to-list (my-directory my-list)
"Adds all immediate subdirectories of `my-directory' to `my-list'.
More precisely, this uses only the subdirectories whose names start
with letters or digits; it excludes any subdirectory named `RCS' or
`CVS', and any subdirectory that contains a file named `.nosearch'."
;; There is still some crud left from
(pending (list my-directory))
(let* ((this-dir (car pending))
(contents (directory-files this-dir))
(canonicalized (and (eq system-type 'windows-nt)
;; The Windows version doesn't report meaningful inode
;; numbers, so use the canonicalized absolute file name of the
;; directory instead.
(setq attrs (or canonicalized
(nthcdr 10 (file-attributes this-dir))))
(unless (member attrs subdirs-inode-list)
(cons attrs subdirs-inode-list))
;; The lower-case variants of RCS and CVS are for DOS/Windows.
(unless (member (car contents) '("." ".." "RCS" "CVS" "rcs" "cvs"))
(when (and (string-match "\\`[[:alnum:]]" (car contents))
;; Avoid doing a `stat' when it isn't necessary
;; because that can cause trouble when an NFS server
;; is down.
(not (string-match "\\.elc?\\'" (car contents)))
(file-directory-p (car contents)))
(let ((expanded (expand-file-name (car contents))))
(unless (file-exists-p (expand-file-name ".nosearch"
(setq dirs (nconc dirs (list expanded)))))))
(setq contents (cdr contents)))))
(add-to-list my-list (cdr (nreverse dirs)))))
This line is left blank intentionally.