# Using cscope+emacs on the freebsd kernel



## Pegasus711 (Apr 15, 2010)

[ ctd. from http://forums.freebsd.org/showthread.php?t=12329 - Mod. ]

Hello there fellows,
I am trying to integrate emacs with cscope. I have been using from quite some time but lately I have been facing issues with it.

Heres what I did so you know if I made any mistakes in creating the database.

Like, now I have created an 'inverted index' on the FreeBSD kernel source and I have integrated cscope with emacs. 

The way I did the former task was that I first created a 'cscope.files' file in a directory like so:
	
	



```
find /usr/src/sys/ -name "*.[chxsS]" -print > /home/aijazbaig1/cscope.files
```
Then I chdir'd to the directory containing the 'cscope.files' file and then ran
	
	



```
cscope -b -q -k
```
 so it created three files cscope.out cscope.in.out cscope.po.out. 

Now assuming everything is fine, I open emacs and then I search for the global definiton of say mbuff and it gives me a list of possible answers. Then when I run a search again _'in the same buffer'_ I get a message which reads that it cannot open cscope.out. Now this is really confusing me. I don't know why it cannot open that file a second time (or may be there is something else which I do not know of )

Please do let me know if you need some more diagnostic information.

Update:
****************************************************************************
Here are the links from where I got my info:

About integrating using cscope with emacs:
http://www.linux.com/archive/feature/114237

About using cscope on large projects:
http://cscope.sourceforge.net/large_projects.html

And some tips from here and there.

Plus here is my .emacs file:

```
(global-font-lock-mode t)              ; always highlight source code
(blink-cursor-mode -1)                 ; make cursor not blink
(setq-default indent-tabs-mode nil)    ; use 8 spaces instead of 1 tab
(setq require-final-newline t)         ; make sure all files end in \n
(setq case-fold-search t)              ; search is case-insensitive
;(if window-system
 ; (setq mouse-wheel-mode t))           ; enable mouse wheel in graphical mode
(setq c-basic-offset 4)                ; make indent size 4 spaces in C
(global-set-key [(meta g)] 'goto-line) ; bind M-g to the goto-line command
(show-paren-mode t)
(transient-mark-mode t)
(set-background-color "gray22")
(set-foreground-color "green yellow")
(setq inhibit-startup-message t)
(fset 'yes-or-no-p 'y-or-n-p)
(setq insert-default-directory t)
(setq inhibit-splash-screen t) ;; no splash screen
(progn
  (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))  ;; no toolbar
  ;;(menu-bar-mode -1) ;;no menubar
  (scroll-bar-mode -1) ;; no scroll bar
)
(progn (cd "/home/aijazbaig1/cscopedbase/") (normal-top-level-add-subdirs-to-load-path))
(load-file "/home/aijazbaig1/cscopedbase/xcscope.el")
(require 'xcscope)
(setq cscope-do-not-update-database t)
(setq cscope-set-initial-directory "/usr/src/sys/")

; retitle emacs window
 (defun frame-retitle (title)
   (modify-frame-parameters 
     nil 
     (list
       (cons
          'name
          title
       )
     )
   )
 )
  
 ;; set a beautiful title bar
 (setq frame-title-format
       '("%S: " (buffer-file-name "%f"
                                  (dired-directory dired-directory "%b"))))
```

Pls do let me know if theres something I could change.


----------

