xref: /openbsd-src/usr.bin/vi/docs/internals/cscope.NOTES (revision 45f2ab881194a80ddc05ca14d80589687551be82)
1*45f2ab88SderaadtCscope Notes:
2*45f2ab88Sderaadt
3*45f2ab88SderaadtThe nvi tags structure has been reworked to handle the notion of multiple
4*45f2ab88Sderaadtlocations per tag.  This supports cscope, which returns multiple locations
5*45f2ab88Sderaadtper query.  It will hopefully support ctags programs that create databases
6*45f2ab88Sderaadtwith multiple locations per tag as well.
7*45f2ab88Sderaadt
8*45f2ab88SderaadtThere is now a list of "tag queues" chained from each screen.  Each tag
9*45f2ab88Sderaadtqueue has one or more "tag locations".
10*45f2ab88Sderaadt
11*45f2ab88Sderaadt   +----+    +----+	+----+     +----+
12*45f2ab88Sderaadt   | EP | -> | Q1 | <-- | T1 | <-- | T2 |
13*45f2ab88Sderaadt   +----+    +----+ --> +----+ --> +----+
14*45f2ab88Sderaadt  	     |
15*45f2ab88Sderaadt  	     +----+     +----+
16*45f2ab88Sderaadt  	     | Q2 | <-- | T1 |
17*45f2ab88Sderaadt  	     +----+ --> +----+
18*45f2ab88Sderaadt  	     |
19*45f2ab88Sderaadt  	     +----+	+----+
20*45f2ab88Sderaadt  	     | Q3 | <-- | T1 |
21*45f2ab88Sderaadt  	     +----+ --> +----+
22*45f2ab88Sderaadt
23*45f2ab88SderaadtIn the above diagram, each "Q" is a "tag queue", and each "T" is a
24*45f2ab88Sderaadttag location.  Generally, the commands:
25*45f2ab88Sderaadt
26*45f2ab88Sderaadt	:tag			create a new Q
27*45f2ab88Sderaadt	^[			create a new Q
28*45f2ab88Sderaadt	:cscope find		create a new Q
29*45f2ab88Sderaadt	:tagnext		move to the next T
30*45f2ab88Sderaadt	:tagprev		move to the previous T
31*45f2ab88Sderaadt	:tagpop			discard one or more Q's
32*45f2ab88Sderaadt	^T			discard the most recent Q
33*45f2ab88Sderaadt	:tagtop			discard all Q's
34*45f2ab88Sderaadt
35*45f2ab88SderaadtMore specifically:
36*45f2ab88Sderaadt
37*45f2ab88Sderaadt:cs[cope] a[dd] cscope-dir
38*45f2ab88Sderaadt
39*45f2ab88Sderaadt	Attach to the cscope database in cscope-dir.
40*45f2ab88Sderaadt
41*45f2ab88Sderaadt:cs[cope] f[ind] c|d|e|f|g|i|s|t buffer|pattern
42*45f2ab88Sderaadt
43*45f2ab88Sderaadt	Query all attached cscopes for the pattern.  The pattern is a
44*45f2ab88Sderaadt	regular expression.  If the pattern is a double-quote character
45*45f2ab88Sderaadt	followed by a valid buffer name (e.g., "t), then the contents
46*45f2ab88Sderaadt	of the named buffer are used as the pattern.
47*45f2ab88Sderaadt
48*45f2ab88Sderaadt	c: find callers of name
49*45f2ab88Sderaadt	d: find all function calls made from name
50*45f2ab88Sderaadt	e: find pattern
51*45f2ab88Sderaadt	f: find files with name as substring
52*45f2ab88Sderaadt	g: find definition of name
53*45f2ab88Sderaadt	i: find files #including name
54*45f2ab88Sderaadt	s: find all uses of name
55*45f2ab88Sderaadt	t: find assignments to name
56*45f2ab88Sderaadt
57*45f2ab88Sderaadt	The find command pushes the current location onto the tags stack,
58*45f2ab88Sderaadt	and switches to the first location resulting from the query, if
59*45f2ab88Sderaadt	the query returned at least one result.
60*45f2ab88Sderaadt
61*45f2ab88Sderaadt:cs[cope] h[elp] [command]
62*45f2ab88Sderaadt
63*45f2ab88Sderaadt	List the cscope commands, or usage help on one command.
64*45f2ab88Sderaadt
65*45f2ab88Sderaadt:display c[onnections]
66*45f2ab88Sderaadt
67*45f2ab88Sderaadt	Display the list of cscope connections
68*45f2ab88Sderaadt
69*45f2ab88Sderaadt:display t[ags]
70*45f2ab88Sderaadt
71*45f2ab88Sderaadt	The tags display has been enhanced to display multiple tag
72*45f2ab88Sderaadt	locations per tag query.
73*45f2ab88Sderaadt
74*45f2ab88Sderaadt:cs[cope] k[ill] #
75*45f2ab88Sderaadt
76*45f2ab88Sderaadt	Kill cscope connection number #.
77*45f2ab88Sderaadt
78*45f2ab88Sderaadt:cs[cope] r[eset]
79*45f2ab88Sderaadt	Kill all attached cscopes.  Useful if one got hung but you don't
80*45f2ab88Sderaadt	know which one.
81*45f2ab88Sderaadt
82*45f2ab88Sderaadt:tagn[ext][!]
83*45f2ab88Sderaadt
84*45f2ab88Sderaadt	Move to the next tag resulting from a query.
85*45f2ab88Sderaadt
86*45f2ab88Sderaadt:tagpr[ev][!]
87*45f2ab88Sderaadt
88*45f2ab88Sderaadt	Return to the previous tag resulting from a query.
89*45f2ab88Sderaadt
90*45f2ab88Sderaadt:tagp[op], ^T
91*45f2ab88Sderaadt
92*45f2ab88Sderaadt	Return to the previous tag group (no change).
93*45f2ab88Sderaadt
94*45f2ab88Sderaadt:tagt[op]
95*45f2ab88Sderaadt
96*45f2ab88Sderaadt	Discard all tag groups (no change).
97*45f2ab88Sderaadt
98*45f2ab88SderaadtSuggested maps:
99*45f2ab88Sderaadt
100*45f2ab88Sderaadt	" ^N: move to the next tag
101*45f2ab88Sderaadt	map ^N :tagnext^M
102*45f2ab88Sderaadt	" ^P: move to the previous tag
103*45f2ab88Sderaadt	map ^P :tagprev^M
104*45f2ab88Sderaadt
105*45f2ab88Sderaadt	" Tab+letter performs a C-Scope query on the current word.
106*45f2ab88Sderaadt	" C-Scope 12.9 has a text-string query (type t).
107*45f2ab88Sderaadt	" C-Scope 13.3 replaces it with an assignment query; hence a==t.
108*45f2ab88Sderaadt	map <tab>a "tye:csc find t"t
109*45f2ab88Sderaadt	map <tab>c "tye:csc find c"t
110*45f2ab88Sderaadt	map <tab>d "tye:csc find d"t
111*45f2ab88Sderaadt	map <tab>e "tye:csc find e"t
112*45f2ab88Sderaadt	map <tab>f "tye:csc find f"t
113*45f2ab88Sderaadt	map <tab>g "tye:csc find g"t
114*45f2ab88Sderaadt	map <tab>i "tye:csc find i"t
115*45f2ab88Sderaadt	map <tab>s "tye:csc find s"t
116*45f2ab88Sderaadt	map <tab>t "tye:csc find t"t
117*45f2ab88Sderaadt
118*45f2ab88SderaadtTo start nvi with an initial set of cscope directories, use the environment
119*45f2ab88Sderaadtvariable CSCOPE_DIRS.  This variable should contain a <blank>-separated
120*45f2ab88Sderaadtlist of directories containing cscope databases.  (This MAY be changed to
121*45f2ab88Sderaadtbe an edit option, I haven't really decided, yet.)
122*45f2ab88Sderaadt
123*45f2ab88SderaadtEach cscope directory must contain a file named "cscope.out" which is the
124*45f2ab88Sderaadtmain cscope database, or nvi will not attempt to connect to a cscope to
125*45f2ab88Sderaadthandle requests for that database.
126*45f2ab88Sderaadt
127*45f2ab88SderaadtThe file "cscope.tpath" may contain a colon-separated directory search
128*45f2ab88Sderaadtpath which will be used to find the files reported by cscope.  If this
129*45f2ab88Sderaadtcscope.tpath does not exist, then the paths are assumed to be relative to
130*45f2ab88Sderaadtthe cscope directory itself.  This is an extension to the standard cscope,
131*45f2ab88Sderaadtbut seems important enough to keep.
132*45f2ab88Sderaadt
133*45f2ab88Sderaadt=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
134*45f2ab88SderaadtCscope Availability:
135*45f2ab88Sderaadt
136*45f2ab88SderaadtUNIXWare System V Release 4.0 variants such as Sun Solaris 2.x
137*45f2ab88Sderaadt(/opt/SUNWspro/bin) have version 11.5, and UNIXWare System V
138*45f2ab88SderaadtRelease 4.1 has version 12.10 with an option for much faster
139*45f2ab88Sderaadtsearching.
140*45f2ab88Sderaadt
141*45f2ab88SderaadtYou can buy version 13.3 source with an unrestricted license
142*45f2ab88Sderaadtfor $400 from AT&T Software Solutions by calling +1-800-462-8146.
143