forked from fgeller/emacs-init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-cedet.el
53 lines (45 loc) · 2.03 KB
/
init-cedet.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(load-file "~/.emacs.d/addons/cedet/cedet-devel-load.el")
(setq semanticdb-default-save-directory "~/.emacs.d/semanticdb")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Semantic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(semantic-mode 1)
(defvar fg/project-root-file-patterns
'(".project\\'" ".xcodeproj\\'" ".sln\\'" "\\`Project.ede\\'"
"\\`.git\\'" "\\`.bzr\\'" "\\`_darcs\\'" "\\`.hg\\'"))
(defun fg/semanticdb-guess-project-root (dirname)
(catch 'root
(let ((dir dirname)
(prev-dir nil)
(pattern (mapconcat 'identity
'(".project\\'" ".xcodeproj\\'" ".sln\\'" "\\`Project.ede\\'"
"\\`.git\\'" "\\`.bzr\\'" "\\`_darcs\\'" "\\`.hg\\'")
"\\|")))
(while (not (equal dir prev-dir))
(when (directory-files dir nil pattern t)
(throw 'root dir))
(setq prev-dir dir
dir (file-name-directory (directory-file-name dir)))))))
(add-to-list 'semanticdb-project-root-functions 'fg/semanticdb-guess-project-root)
;; based on `projman-semanticdb-analyze' at http://www.emacswiki.org/emacs/projman.el
(defun fg/semanticdb-analyze-project (pattern)
(interactive "s")
(let* (
(dir (expand-file-name (if buffer-file-name
(file-name-directory buffer-file-name)
default-directory)))
(recentf-exclude (list ".*")) ; don't want scanned files in recentf list
(find-command (format "find . -type f -name \"%s\"" pattern))
(files (split-string (shell-command-to-string find-command) "[\r\n]+" t))
(file))
(message "Visiting files...")
(while files
(setq file (car files)
files (cdr files))
(unless (find-buffer-visiting file)
(message "Visiting %s" file)
(let ((buf (find-file-noselect file))
(tags))
(setq tags (semantic-fetch-tags))
(kill-buffer buf)))))
(semanticdb-save-all-db)
(message "Finished analyzing files."))
(provide 'init-cedet)