Imported Upstream version 15.8a
[platform/upstream/cscope.git] / src / emacs.e
1 / ========================================================================= /
2 / Copyright (c) 1998-2000, The Santa Cruz Operation /
3 / All rights reserved./
4 / /
5 / Redistribution and use in source and binary forms, with or without/
6 / modification, are permitted provided that the following conditions are met:/
7 //
8 / *Redistributions of source code must retain the above copyright notice,/
9 / this list of conditions and the following disclaimer./
10 //
11 / *Redistributions in binary form must reproduce the above copyright notice,/
12 / this list of conditions and the following disclaimer in the documentation/
13 / and/or other materials provided with the distribution./
14 //
15 / *Neither name of The Santa Cruz Operation nor the names of its contributors/
16 / may be used to endorse or promote products derived from this software/
17 / without specific prior written permission. /
18 //
19 / THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS/
20 / IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,/
21 / THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR/
22 / PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE/
23 / LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR/
24 / CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF/
25 / SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS/
26 / INTERRUPTION)/
27 / HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT/
28 / LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY/
29 / OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH/
30 / DAMAGE. /
31 / ========================================================================= /
32
33 / $Id: emacs.e,v 1.1 2000/04/27 16:33:47 petr Exp $ /
34
35
36 / emacs menu for cscope /
37 ((X) cscope (find current word [MACRO])
38         (extern symbol-character)
39
40         / if this character is not part of a symbol /
41         (cond ((not symbol-character)
42                 
43                 / if the previous character is not part of a symbol, go to
44                   the next word /
45                 back
46                 (cond ((not symbol-character) forward-word back-word))
47         ))
48         / get the current symbol (leave cursor at beginning of symbol) /
49         (while symbol-character forward)        / go past last symbol character /
50         mark                                    / mark this point /
51         back                                    / back to last symbol character /
52         (while (cond (symbol-character (return back)))) / back fails at BOF /
53         (cond ((not symbol-character) forward))         / forward if not at BOF /
54         pickup-region                           / get the symbol /
55         (local-string symbol)
56         symbol=
57
58         / if arg > 0 then display the menu /
59         (cond ((> arg 0) (display-menu
60                 (format symbol "5  Find functions calling %l()")
61                 (format symbol "4  Find functions called by %l()")
62                 (format symbol "3  Find global definition of %l")
63                 (format symbol "2  Find symbol %l")
64                 "1  Call cscope"
65                 5)
66         ))
67         / get the selection /
68         (local selection)
69         (selection= (read-character "Selection?"))
70
71         / if the selection is in range /
72         (cond ((&& (>= selection '1') (<= selection '5'))
73         
74                 / if the selection requests finding the symbol /
75                 (local-string findsymbol)
76                 (findsymbol= "")
77                 (cond ((>= selection '2')
78                         (findsymbol= (format (char-to-string (- selection 2)) symbol "-%l '%l'"))))
79                 
80                 / if arg > 1 or < 0 then don't update the cross-reference database /
81                 (local-string doption)
82                 (doption= "")
83                 (cond ((|| (> arg 1) (< arg 0)) (doption= "-d")))
84                 
85                 / call cscope with usilent mode off /
86                 (local oldmode)                         / save old usilent mode /
87                 (oldmode= (set-mode "usilent" 0))       / turn off usilent mode /
88                 (run-command (format doption findsymbol "cscope %l %l"))
89                 (set-mode "usilent" oldmode)            / restore usilent mode /
90         ))
91 )
92 / see if the current character is part of a symbol /
93 (symbol-character ()
94         (local c)
95         (c= current-character)
96         (return (cond   ((&& (>= c 'a') (<= c 'z')))
97                         ((&& (>= c 'A') (<= c 'Z')))
98                         ((&& (>= c '0') (<= c '9')))
99                         ((== c '_'))
100                 )
101         )
102 )