annotate lisp/hyperbole/hmouse-tag.el @ 147:e186c2b7192d xemacs-20-2

Added tag r20-2p1 for changeset 2af401a6ecca
author cvs
date Mon, 13 Aug 2007 09:34:48 +0200
parents 4be1180a9e89
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: hmouse-tag.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Smart Key support of programming language tags location.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: c, hypermedia, mouse, oop, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 24-Aug-91
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
12 ;; LAST-MOD: 17-Feb-97 at 15:31:50 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
17 (require 'hpath)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
18 (require 'hbut)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
19
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (if (cond ((or (featurep 'etags) (featurep 'tags))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ((or hyperb:lemacs-p hyperb:emacs19-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Force use of .elc file here since otherwise the bin/etags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; executable might be found in a user's load-path by the load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (or (load "etags.elc" t nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (load "tags-fix" t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ((load "tags" t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (provide 'tags))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar smart-asm-include-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "*Ordered list of directories to search for assembly language include files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 Each directory must end with a directory separator.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defconst smart-asm-include-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 "[ \t*#|;]*\\(include\\|lib\\)[ \t]+\\([^ \t\n\^M]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 "Regexp to match to assembly language include file lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 Include keyword matched is grouping 1. File name is grouping 2 but may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 missing its suffix, so add \".ins\" or \".inc\" if need be.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 Examples include:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 INCLUDE GLOBALS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 should jump to file \"globals.ins\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 lib conditionals_equ.inc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 should include \"conditionals_equ.inc\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defvar smart-c-cpp-include-dirs '("/usr/include/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "*Ordered list of include directories by default searched by C/C++ preprocessor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Each directory must end with a directory separator. See also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 'smart-c-include-dirs'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defvar smart-c-include-dirs nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 "*Ordered list of directories to search for C/C++ include files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Each directory must end with a directory separator. Directories normally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 searched by the C/C++ pre-processor should be set instead in
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
59 `smart-c-cpp-include-dirs'.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvar smart-c-use-lib-man nil
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
62 "When non-nil makes `smart-c' and `smart-c++' display man pages for recognized lib symbols.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
63 When nil, `smart-c' and `smart-c++' look up only symbols defined in an etags
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 TAGS file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 Create the file ~/.CLIBS-LIST and populate it with the full pathnames (one per
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 line) of all of the C/C++ libraries whose symbols you want to match against.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Your MANPATH environment variable must include paths for the man pages of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 these libraries also.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 Your smart-clib-sym executable script must output a 1 if a symbol is from a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 C/C++ library listed in ~/.CLIBS-LIST or 0 if not! Otherwise, don't set this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 variable to t.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defconst smart-c-include-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "[ \t/*]*#[ \t]*\\(include\\|import\\)[ \t]+\\([\"<]\\)\\([^\">]+\\)[\">]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 "Regexp to match to C, C++, or Objective-C include file lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 Include keyword matched is grouping 1. Type of include, user-specified via
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
79 double quote, or system-related starting with `<' is given by grouping 2.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 File name is grouping 3.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
82 (defvar smart-java-package-dirs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
83 (and (fboundp 'getenv) (getenv "JAVA_HOME")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
84 (list (expand-file-name "src/" (file-name-as-directory (getenv "JAVA_HOME")))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
85 "*Ordered list of directories to search for imported Java packages.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
86 Each directory must end with a directory separator.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
87
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
88 (defconst smart-java-package-regexp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
89 "[ \t/*]*\\(package\\|import\\)[ \t]+\\([^; \t\n\r\f]+\\)"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
90 "Regexp to match to Java `package' and `import' lines.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
91 Keyword matched is grouping 1. Referent is grouping 2.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
92
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defvar smart-emacs-tags-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "*Full path name of etags file for GNU Emacs source.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun smart-asm (&optional identifier next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "Jumps to the definition of optional assembly IDENTIFIER or the one at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 Optional second arg NEXT means jump to next matching assembly tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 It assumes that its caller has already checked that the key was pressed in an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 appropriate buffer and has moved the cursor to the selected buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 If:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (1) on an include statement, the include file is displayed;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
109 Look for include file in directory list `smart-asm-include-dirs'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (2) on an identifier, the identifier definition is displayed,
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
111 assuming the identifier is found within an `etags' generated tag file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 in the current directory or any of its ancestor directories."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (if identifier nil (smart-asm-include-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (let ((tag (or identifier (smart-asm-at-tag-p))))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
118 ;; Set free variable tags-file-name so that next `find-tag' command uses
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; whatever tags file is set here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq tags-file-name (smart-tags-file buffer-file-name))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
121 (message "Looking for `%s' in `%s'..." tag tags-file-name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (progn
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
124 (smart-tags-display tag next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
125 (message "Found definition for `%s'." tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
126 (error (message "`%s' not found in `%s'." tag tags-file-name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (beep))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defun smart-asm-at-tag-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "Return assembly tag name that point is within, else nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (let* ((identifier-chars "_.$a-zA-Z0-9")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (identifier (concat "[_.$a-zA-Z][" identifier-chars "]*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (skip-chars-backward identifier-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (if (looking-at identifier)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
137 (smart-flash-tag
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
138 (buffer-substring (point) (match-end 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
139 (point) (match-end 0))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
140
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
141 (defun smart-c (&optional identifier next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
142 "Jumps to the definition of optional C IDENTIFIER or the one at point.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
143 Optional second arg NEXT means jump to next matching C tag.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
144
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
145 It assumes that its caller has already checked that the key was pressed in an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
146 appropriate buffer and has moved the cursor to the selected buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
147
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
148 If:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
149 (1) on a `#include' statement, the include file is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
150 Look for include file in directory lists `smart-c-cpp-include-dirs'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
151 and `smart-c-include-dirs'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
152 (2) on a C identifier, the identifier definition is displayed,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
153 assuming the identifier is found within an `etags' generated tag file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
154 in the current directory or any of its ancestor directories.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
155 (3) if `smart-c-use-lib-man' is non-nil, the C identifier is
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
156 recognized as a library symbol, and a man page is found for the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
157 identifier, then the man page is displayed."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
158
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
159 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
160 (or
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
161 (if identifier nil (smart-c-include-file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
162 (let ((tag (or identifier (smart-c-at-tag-p))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
163 ;; Set free variable tags-file-name so that next `find-tag' command uses
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
164 ;; whatever tags file is set here.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
165 (setq tags-file-name (smart-tags-file buffer-file-name))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
166 (message "Looking for `%s' in `%s'..." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
167 (condition-case ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
168 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
169 (smart-tags-display tag next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
170 (message "Found definition for `%s'." tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
171 (error
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
172 (if (not smart-c-use-lib-man)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
173 (progn (message "`%s' not found in `%s'." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
174 (beep))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
175 (message "Checking if `%s' is a C library function..." tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
176 (if (smart-library-symbol tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
177 (progn (message "Displaying C library man page for `%s'." tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
178 (manual-entry tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
179 (message "`%s' not found in `%s' or C libraries."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
180 tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
181 (beep))))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
182
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
183 ;;;###autoload
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
184 (defun smart-c-at-tag-p ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
185 "Return C tag name that point is within, else nil."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
186 (let* ((identifier-chars "_a-zA-Z0-9")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
187 (identifier (concat "[_a-zA-Z][" identifier-chars "]*")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
188 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
189 (skip-chars-backward identifier-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
190 (if (looking-at identifier)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
191 (smart-flash-tag
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
192 (buffer-substring (point) (match-end 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
193 (point) (match-end 0))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
194
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
195 ;;;###autoload
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
196 (defun smart-c++ (&optional identifier next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
197 "Jumps to the definition of optional C++ IDENTIFIER or the one at point.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
198 Optional second arg NEXT means jump to next matching C++ tag.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
199
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
200 It assumes that its caller has already checked that the key was pressed in an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
201 appropriate buffer and has moved the cursor to the selected buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
202
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
203 If:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
204 (1) on a `#include' statement, the include file is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
205 Look for include file in directory lists `smart-c-cpp-include-dirs'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
206 and `smart-c-include-dirs'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
207 (2) on a C++ identifier, the identifier definition is displayed,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
208 assuming the identifier is found within an `etags' generated tag file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
209 in the current directory or any of its ancestor directories.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
210 (3) if `smart-c-use-lib-man' is non-nil, the C++ identifier is
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
211 recognized as a library symbol, and a man page is found for the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
212 identifier, then the man page is displayed."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
213
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
214 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
215 (if (fboundp 'c++-to-definition)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
216 ;; Only fboundp if OO-Browser has been loaded.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
217 (smart-c++-oo-browser)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
218 (or
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
219 (if identifier nil (smart-c-include-file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
220 (let ((tag (or identifier (smart-c++-at-tag-p))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
221 ;; Set free variable tags-file-name so that next `find-tag' command uses
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
222 ;; whatever tags file is set here.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
223 (setq tags-file-name (smart-tags-file buffer-file-name))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
224 (message "Looking for `%s' in `%s'..." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
225 (condition-case ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
226 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
227 (smart-tags-display tag next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
228 (message "Found definition for `%s'." tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
229 (error
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
230 (if (not smart-c-use-lib-man)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
231 (progn (message "`%s' not found in `%s'." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
232 (beep))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
233 (message "Checking if `%s' is a C++ library function..." tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
234 (if (smart-library-symbol tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
235 (progn (message "Displaying C++ library man page for `%s'." tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
236 (manual-entry tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
237 (message "`%s' not found in `%s' or C++ libraries."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
238 tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
239 (beep)))))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
240
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
241 ;;; The following should be called only if the OO-Browser is available.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
242 (defun smart-c++-oo-browser (&optional junk)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
243 "Jumps to the definition of selected C++ construct via OO-Browser support.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
244 Optional JUNK is ignored. Does nothing if the OO-Browser is not available.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
245
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
246 It assumes that its caller has already checked that the key was pressed in an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
247 appropriate buffer and has moved the cursor to the selected buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
248
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
249 If key is pressed:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
250 (1) on a `#include' statement, the include file is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
251 Look for include file in directory lists `smart-c-cpp-include-dirs'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
252 and `smart-c-include-dirs'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
253 (2) within a method declaration, its definition is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
254 (3) on a class name, the class definition is shown.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
255
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
256 (2) and (3) require that an OO-Browser Environment has been loaded with
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
257 the {M-x br-env-load RET} command."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
258
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
259 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
260 (c++-to-definition t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
261
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
262 (defun smart-c++-at-tag-p ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
263 "Return C++ tag name that point is within, else nil."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
264 (let* ((identifier-chars "_:~<>a-zA-Z0-9")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
265 (identifier (concat "\\([_~:<a-zA-Z][" identifier-chars "]*"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
266 "[ \t]*[^]) \t:;.,?~{}][^[( \t:;.,~^!|?{}]?[=*]?\\)[ \t\n]*(")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
267 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
268 (skip-chars-backward identifier-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
269 (if (looking-at identifier)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
270 (smart-flash-tag
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
271 (buffer-substring (match-beginning 1) (match-end 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
272 (match-beginning 1) (match-end 1))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
273
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
274 (defun smart-emacs-lisp-mode-p ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
275 "Return t if in a mode which uses Emacs Lisp symbols."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
276 (or (memq major-mode '(emacs-lisp-mode lisp-interaction-mode debugger-mode))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
277 ;; Emacs Lisp symbols appear in Help buffers frequently.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
278 (string-match "Help\\*$" (buffer-name))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
279
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
280 (defun smart-fortran (&optional identifier next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
281 "Jumps to the definition of optional Fortran IDENTIFIER or the one at point.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
282 Optional second arg NEXT means jump to next matching Fortran tag.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
283
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
284 It assumes that its caller has already checked that the key was pressed in an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
285 appropriate buffer and has moved the cursor to the selected buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
286
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
287 If on a Fortran identifier, the identifier definition is displayed,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
288 assuming the identifier is found within an `etags' generated tag file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
289 in the current directory or any of its ancestor directories."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
290 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
291 (let ((tag (or identifier (smart-fortran-at-tag-p))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
292 ;; Set free variable tags-file-name so that next `find-tag' command uses
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
293 ;; whatever tags file is set here.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
294 (setq tags-file-name (smart-tags-file buffer-file-name))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
295 (message "Looking for `%s' in `%s'..." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
296 (condition-case ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
297 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
298 (smart-tags-display tag next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
299 (message "Found definition for `%s'." tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
300 (error
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
301 (message "`%s' not found in `%s'." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
302 (beep)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
303
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
304 ;;;###autoload
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
305 (defun smart-fortran-at-tag-p ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
306 "Return Fortran tag name that point is within, else nil."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
307 (let* ((identifier-chars "_a-zA-Z0-9")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
308 (identifier (concat "[_a-zA-Z][" identifier-chars "]*")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
309 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
310 (skip-chars-backward identifier-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
311 (if (looking-at identifier)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
312 (smart-flash-tag
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
313 (buffer-substring (point) (match-end 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
314 (point) (match-end 0))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
315
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
316 ;;;###autoload
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
317 (defun smart-java (&optional identifier next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
318 "Jumps to the definition of optional Java IDENTIFIER or the one at point.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
319 Optional second arg NEXT means jump to next matching Java tag.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
320
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
321 It assumes that its caller has already checked that the key was pressed in an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
322 appropriate buffer and has moved the cursor to the selected buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
323
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
324 If:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
325 (1) within a commented @see cross-reference, the referent is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
326 (2) on a `package' or `import' statement, the referent is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
327 Look for referent files in the directory list `smart-java-package-dirs'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
328 (3) on an Java identifier, the identifier definition is displayed,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
329 assuming the identifier is found within an `etags' generated tag file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
330 in the current directory or any of its ancestor directories."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
331
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
332 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
333 (if (fboundp 'java-to-definition)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
334 ;; Only fboundp if OO-Browser has been loaded.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
335 (smart-java-oo-browser)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
336 (or
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
337 (if identifier nil (or (smart-java-cross-reference) (smart-java-packages)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
338 (let ((tag (or identifier (smart-java-at-tag-p))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
339 ;; Set free variable tags-file-name so that next `find-tag' command uses
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
340 ;; whatever tags file is set here.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
341 (setq tags-file-name (smart-tags-file buffer-file-name))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
342 (message "Looking for `%s' in `%s'..." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
343 (condition-case ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
344 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
345 (smart-tags-display tag next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
346 (message "Found definition for `%s'." tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
347 (error (progn (message "`%s' not found in `%s'." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
348 (beep))))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
349
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
350 ;;; The following should be called only if the OO-Browser is available.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
351 (defun smart-java-oo-browser (&optional junk)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
352 "Jumps to the definition of selected Java construct via OO-Browser support.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
353 Optional JUNK is ignored. Does nothing if the OO-Browser is not available.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
354
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
355 It assumes that its caller has already checked that the key was pressed in an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
356 appropriate buffer and has moved the cursor to the selected buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
357
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
358 If key is pressed:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
359 (1) within a commented @see cross-reference, the referent is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
360 (2) on a `package' or `import' statement, the referent is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
361 Look for referent files in the directory list `smart-java-package-dirs'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
362 (3) within a method declaration, its definition is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
363 (4) on a class name, the class definition is shown."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
364
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
365 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
366 (or (smart-java-cross-reference)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
367 (smart-java-packages)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
368 (java-to-definition t)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
369
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
370 ;;;###autoload
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
371 (defun smart-java-at-tag-p ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
372 "Return Java tag name that point is within, else nil."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
373 (let* ((identifier-chars "_$.a-zA-Z0-9")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
374 (identifier
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
375 (concat "[_$a-zA-Z][" identifier-chars "]*")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
376 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
377 (skip-chars-backward identifier-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
378 (if (looking-at identifier)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
379 (smart-flash-tag
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
380 (buffer-substring (point) (match-end 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
381 (point) (match-end 0))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
382
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
383 (defun smart-lisp (&optional next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
384 "Jumps to the definition of any selected Lisp construct.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
385 If on an Emacs Lisp require, load, or autoload clause and `find-library'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
386 from load-library package by Hallvard Furuseth (hallvard@ifi.uio.no) has
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
387 been loaded, jumps to library source, if possible.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
388
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
389 Otherwise, the construct must be found within an `etags' generated tag file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
390 in the current directory or any of its ancestor directories in order for its
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
391 definition to be located.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
392
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
393 Optional NEXT means jump to next matching Lisp tag. When matching to an Emacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
394 Lisp tag using `wtags' (Bob Weiner's personal modifications to `etags'),
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
395 there is no next tag, so display documentation for current tag instead.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
396
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
397 This command assumes that its caller has already checked that the key was
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
398 pressed in an appropriate buffer and has moved the cursor to the selected
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
399 buffer."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
400
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
401 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
402 ;; Handle `require', `load', and `autoload' clauses in Emacs Lisp.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
403 (or (and (fboundp 'find-library)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
404 (smart-emacs-lisp-mode-p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
405 (let ((req)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
406 (opoint (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
407 (setq req (and (search-backward "\(" nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
408 (looking-at (concat
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
409 "(\\(require\\|load\\|autoload\\)"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
410 "[ \t]+.*['\"]"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
411 "\\([^][() \t\n\^M`'\"]+\\)"))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
412 (goto-char opoint)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
413 (if req (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
414 (setq req (buffer-substring (match-beginning 2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
415 (match-end 2)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
416 (hpath:display-buffer (current-buffer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
417 (find-library req)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
418 t))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
419 (let ((tag (smart-lisp-at-tag-p)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
420 ;; Set free variable tags-file-name so that next `find-tag' command
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
421 ;; uses whatever tags file is set here.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
422 (setq tags-file-name (smart-tags-file default-directory))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
423 ;; This part only works properly for Emacs Lisp, so is conditionalized.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
424 (if (and next (smart-emacs-lisp-mode-p) (featurep 'wtags))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
425 (progn (setq tag (intern tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
426 (cond ((fboundp tag) (describe-function tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
427 ((boundp tag) (describe-variable tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
428 (t (error "(smart-lisp): Unbound symbol: %s" tag))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
429 (condition-case ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
430 (smart-tags-display tag next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
431 (error (if (equal tags-file-name smart-emacs-tags-file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
432 (progn (message "`%s' not found in `%s'."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
433 tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
434 (beep))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
435 (setq tags-file-name smart-emacs-tags-file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
436 (smart-tags-display tag next))))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
437
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
438 (defun smart-lisp-at-tag-p ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
439 "Returns Lisp tag name that point is within, else nil.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
440 Returns nil when point is within a Lisp `def' keyword."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
441 (let* ((identifier-chars "-_*:+%$#!<>a-zA-Z0-9")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
442 (identifier (concat "[-<*a-zA-Z][" identifier-chars "]*"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
443 (opoint (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
444 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
445 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
446 (if (and (looking-at "\\(;*[ \t]*\\)?(def[^- \n\t]+")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
447 (< opoint (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
448 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
449 (goto-char opoint)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
450 (skip-chars-backward identifier-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
451 (if (looking-at identifier)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
452 (smart-flash-tag
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
453 (buffer-substring (point) (match-end 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
454 (point) (match-end 0)))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
455
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
456 ;;;###autoload
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
457 (defun smart-lisp-mode-p ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
458 "Return t if in a mode which uses Lisp symbols."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
459 (or (smart-emacs-lisp-mode-p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
460 (memq major-mode '(lisp-mode scheme-mode))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
461
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
462 ;;;###autoload
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
463 (defun smart-objc (&optional identifier next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
464 "Jumps to the definition of optional Objective-C IDENTIFIER or the one at point.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
465 Optional second arg NEXT means jump to next matching Objective-C tag.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
466
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
467 It assumes that its caller has already checked that the key was pressed in an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
468 appropriate buffer and has moved the cursor to the selected buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
469
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
470 If:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
471 (1) on a `#include' statement, the include file is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
472 Look for include file in directory lists `smart-c-cpp-include-dirs'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
473 and `smart-c-include-dirs'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
474 (2) on an Objective-C identifier, the identifier definition is displayed,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
475 assuming the identifier is found within an `etags' generated tag file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
476 in the current directory or any of its ancestor directories.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
477 (3) if `smart-c-use-lib-man' is non-nil, the Objective-C identifier is
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
478 recognized as a library symbol, and a man page is found for the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
479 identifier, then the man page is displayed."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
480
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
481 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
482
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
483 (if (fboundp 'objc-to-definition)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
484 ;; Only fboundp if OO-Browser has been loaded.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
485 (smart-objc-oo-browser)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
486 (or
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
487 (if identifier nil (smart-c-include-file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
488 (let ((tag (or identifier (smart-objc-at-tag-p))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
489 ;; Set free variable tags-file-name so that next `find-tag' command uses
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
490 ;; whatever tags file is set here.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
491 (setq tags-file-name (smart-tags-file buffer-file-name))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
492 (message "Looking for `%s' in `%s'..." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
493 (condition-case ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
494 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
495 (smart-tags-display tag next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
496 (message "Found definition for `%s'." tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
497 (error
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
498 (if (not smart-c-use-lib-man)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
499 (progn (message "`%s' not found in `%s'." tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
500 (beep))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
501 (message
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
502 "Checking if `%s' is an Objective-C library function..." tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
503 (if (smart-library-symbol tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
504 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
505 (message
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
506 "Displaying Objective-C library man page for `%s'." tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
507 (manual-entry tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
508 (message "`%s' not found in `%s' or Objective-C libraries."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
509 tag tags-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
510 (beep)))))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
511
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
512 ;;; The following should be called only if the OO-Browser is available.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
513 (defun smart-objc-oo-browser (&optional junk)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
514 "Jumps to the definition of selected Objective-C construct via OO-Browser support.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
515 Optional JUNK is ignored. Does nothing if the OO-Browser is not available.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
516
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
517 It assumes that its caller has already checked that the key was pressed in an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
518 appropriate buffer and has moved the cursor to the selected buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
519
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
520 If key is pressed:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
521 (1) on a `#include' statement, the include file is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
522 Look for include file in directory lists `smart-c-cpp-include-dirs'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
523 and `smart-c-include-dirs'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
524 (2) within a method declaration, its definition is displayed;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
525 (3) on a class name, the class definition is shown.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
526
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
527 (2) and (3) require that an OO-Browser Environment has been loaded with
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
528 the {M-x br-env-load RET} command."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
529
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
530 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
531 (objc-to-definition t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
532
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
533 (defun smart-objc-at-tag-p ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
534 "Return Objective-C tag name that point is within, else nil."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
535 (let* ((identifier-chars "_a-zA-Z0-9")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
536 (identifier
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
537 (concat "\\([-+][ \t]*\\)?\\([_a-zA-Z][" identifier-chars "]*\\)")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
538 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
539 (skip-chars-backward identifier-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
540 (if (looking-at identifier)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
541 (smart-flash-tag
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
542 (buffer-substring (match-beginning 2) (match-end 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
543 (match-beginning 2) (match-end 2))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
544
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
545 ;;; ************************************************************************
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
546 ;;; Private functions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
547 ;;; ************************************************************************
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (defun smart-asm-include-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 "If point is on an include file line, tries to display file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 Returns non-nil iff on an include file line, even if file is not found.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
552 Look for include file in `smart-asm-include-dirs' and add suffix \".ins\" or
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 \".inc\" to filename if it lacks a suffix."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;; Some assemblers utilize the C preprocessor, so try that first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (cond ((smart-c-include-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ((progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (looking-at smart-asm-include-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (let ((file (buffer-substring (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (dir-list smart-asm-include-dirs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (setq dir-list (cons (file-name-directory buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 dir-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (if (string-match "\\." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (setq file (regexp-quote file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (setq file (concat (regexp-quote file) "\\.in[sc]$")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (while dir-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (setq dir-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (if (setq path (car (directory-files
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
571 (car dir-list) t file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (cdr dir-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;; If path exists, display file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (if path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (if (and (file-readable-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (progn
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
580 (hpath:find path)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (cond ((featurep 'asm-mode) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ((load "asm-mode" nil 'nomessage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (provide 'asm-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (t
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
585 (beep)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
586 (message
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
587 "(smart-asm-include-file): asm-mode undefined.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
588 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
589 ))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (beep)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
592 (message "(smart-asm-include-file): `%s' unreadable." path))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (beep)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
594 (message "(smart-asm-include-file): `%s' not found." file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; not on an include file line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (t (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (defun smart-c-include-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 "If point is on an include file line, tries to display file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 Returns non-nil iff on an include file line, even if file is not found.
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
604 Look for include file in `smart-c-cpp-include-dirs' and in directory list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
605 `smart-c-include-dirs'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (if (looking-at smart-c-include-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (let ((incl-type (string-to-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (buffer-substring (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (1+ (match-beginning 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (file (buffer-substring (match-beginning 3) (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (dir-list smart-c-include-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (setq dir-list (if (= incl-type ?<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (append dir-list smart-c-cpp-include-dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (cons (file-name-directory buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 dir-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (while dir-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (setq path (expand-file-name file (car dir-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 dir-list (if (setq found (file-exists-p path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (cdr dir-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; If found, display file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (if found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (if (and (file-readable-p path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (progn
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
632 (hpath:find path)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (cond ((or (featurep 'cc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (featurep 'c-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ((or (load "cc-mode" 'missing-ok 'nomessage)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (load "c-mode" 'missing-ok 'nomessage))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (provide 'c-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 "(smart-c-include-file): c-mode undefined.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (beep)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
647 (message "(smart-c-include-file): `%s' unreadable." path))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (beep)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
649 (message "(smart-c-include-file): `%s' not found." file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (goto-char opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
654 (defun smart-flash-tag (tag start end)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
655 "Tries to flash TAG at START to END in buffer, to indicate that it is serving as a hyperlink button.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
656 Returns TAG."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
657 ;; Button flashing code might not yet have been loaded if the whole
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
658 ;; Hyperbole system has not been started.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
659 (if (fboundp 'hui:but-flash)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
660 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
661 (ibut:label-set tag start end)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
662 (hui:but-flash)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
663 tag)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
665 (defun smart-java-cross-reference ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
666 "If within a Java @see comment, displays the associated definition for editing and returns non-nil, else nil.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
667 Non-nil is returned even if the @see referent cannot be found.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
669 Does nothing if the `oo-browser' command is undefined, since it requires that
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
670 package for class and feature lookups."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
671 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
672 ;; Valid forms of @see cross-references are:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
673 ;; * @see #getComponent - current class attribute
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
674 ;; * @see #waitForAll() - current class method, no arguments
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
675 ;; * @see #checkID(int, boolean) - current class method, with arguments
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
676 ;; * @see java.awt.ColorModel#getRGBdefault - library class method
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
677 ;; * @see Component#paintAll - class method
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
678 ;; * @see java.awt.GridBagLayout - library class
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
679 ;; * @see Container - class
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
680 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
681 ;; For simplicity sake, this code ignores the library path given with any
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
682 ;; class in favor of the OO-Browser's lookup tables. It also ignores any
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
683 ;; parameters associated with a method, and thus cannot distinguish between
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
684 ;; methods with the same name within a single class, which we believe to be
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
685 ;; fairly bad form anyway.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
686 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
687 (let ((opoint (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
688 (if (and (eq major-mode 'java-mode) buffer-file-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
689 (fboundp 'br-env-load)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
690 (or (looking-at "@see[ \t]+")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
691 (and (re-search-backward "[@\n\r\f]" nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
692 (looking-at "@see[ \t]+"))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
693 (let ((class) (feature))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
694 ;; Ignore any library path preceding a classname (grouping 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
695 (cond
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
696 ((looking-at
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
697 "@see[ \t]+\\(#\\)?\\([^][(){} \t\n\r\f#]+[.]\\)?\\([^][(){} \t\n\r\f#.]+\\)[][(){} \t\n\r\f]")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
698 (if (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
699 (setq class nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
700 feature (buffer-substring (match-beginning 3)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
701 (match-end 3)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
702 (setq class (buffer-substring (match-beginning 3) (match-end 3))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
703 feature nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
704 ((looking-at
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
705 "@see[ \t]+\\([^][(){} \t\n\r\f#]+[.]\\)?\\([^][(){} \t\n\r\f#.]+\\)#\\([^][(){} \t\n\r\f#.]+\\)")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
706 (setq class (buffer-substring (match-beginning 2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
707 (match-end 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
708 feature (buffer-substring (match-beginning 3)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
709 (match-end 3)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
710 ;; Return to original point.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
711 (goto-char opoint)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
712 ;; Lookup class / feature.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
713 (cond
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
714 ((and (null class) (null feature))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
715 ;; Invalid or unrecognized @see format, so ignore.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
716 (message "(smart-java-cross-reference): Invalid @see cross-reference format.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
717 (beep)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
718 t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
719 ;; Ensure that a Java OO-Browser environment has been loaded.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
720 (t (if (or (and (boundp 'br-lang-prefix)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
721 (equal br-lang-prefix "java-")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
722 (boundp 'br-env-file) (stringp br-env-file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
723 (null br-env-spec))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
724 ;; Load an existing Environment based on current
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
725 ;; buffer or prompt to build one. This also
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
726 ;; loads the "br-java.el" library in which the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
727 ;; `java-class-def-regexp' variable used below
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
728 ;; is defined.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
729 (and (br-env-load
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
730 (smart-tags-file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
731 buffer-file-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
732 (if (boundp 'br-env-default-file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
733 br-env-default-file "OOBR")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
734 (equal br-lang-prefix "java-")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
735 (cond ((null feature)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
736 (br-edit nil class))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
737 (t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
738 (if (null class)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
739 (if (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
740 (or (re-search-backward java-class-def-regexp nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
741 (re-search-forward java-class-def-regexp nil t)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
742 (setq class (buffer-substring
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
743 (match-beginning java-class-def-name-grpn)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
744 (match-end java-class-def-name-grpn)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
745 (error "(smart-java-cross-reference): This @see must be in a class definition.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
746 (br-edit-feature class feature t)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
747 (error "(smart-java-cross-reference): The OO-Browser failed to load a Java environment.")))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
748 ;; Return to original point.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
749 (goto-char opoint)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
750 nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
752 (defun smart-java-library-path (library-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
753 "Search up directory tree from current directory for a match to LIBRARY-NAME."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
754 (let ((path default-directory)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
755 (library-path)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
756 (library-regexp (if (string-match "\\.\\|'//" library-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
757 (regexp-quote
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
758 (concat (file-name-as-directory "")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
759 (substring library-name 0 (match-beginning 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
760 (file-name-as-directory "")))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
761 (start 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
762 ;; Return rightmost match to first part of library-name.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
763 (if library-regexp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
764 (while (string-match library-regexp path start)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
765 (setq start (1+ (match-beginning 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
766 library-path (substring path 0 (match-beginning 0)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
767 library-path))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
769 (defun smart-java-packages ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
770 "If point is on a `package' or `import' line, this tries to display the associated referent.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
771 Returns non-nil iff on such a line, even if the referent is not found.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
772 Look for packages in `smart-java-package-dirs'."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
773 (let ((opoint (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
774 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
775 (if (looking-at smart-java-package-regexp)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
776 (let ((keyword-type (buffer-substring
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
777 (match-beginning 1) (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
778 (referent (buffer-substring (match-beginning 2) (match-end 2)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
779 (found)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
780 (subpath)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
781 dir-list path subfile)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
782 (goto-char opoint)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
783 (if (string-equal keyword-type "package")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
784 (let ((library-path (smart-java-library-path referent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
785 (if library-path
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
786 (hpath:find (expand-file-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
787 (hypb:replace-match-string
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
788 "\\." referent (file-name-as-directory "") t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
789 library-path))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
790 ;; Show the current directory, which should contain this package.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
791 (hpath:find default-directory)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
792 ;; This is an `import' statement. If it includes a *, show the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
793 ;; associated library directory, otherwise, show the specific
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
794 ;; package.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
795 (if (string-match "\\.\\*" referent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
796 (setq subfile (substring referent 0 (match-beginning 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
797 subfile (hypb:replace-match-string
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
798 "\\." subfile (file-name-as-directory "") t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
799 (setq subpath (hypb:replace-match-string
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
800 "\\." referent (file-name-as-directory "") t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
801 subfile (concat subpath ".java")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
802 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
803 ;; Try to find the path containing referent.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
804 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
805 ;; Search up the current directory tree for a possible matching
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
806 ;; directory below which the referent library might live and add
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
807 ;; this to smart-java-package-dirs for searching.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
808 (let ((library-path (smart-java-library-path referent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
809 (if library-path
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
810 (setq dir-list (cons library-path smart-java-package-dirs))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
812 (while dir-list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
813 (setq path (expand-file-name subfile (car dir-list))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
814 dir-list (if (setq found (file-exists-p path))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
815 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
816 (cdr dir-list))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
817 (if (and (not found) subpath hyperb:microcruft-os-p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
818 ;; Try .jav suffix.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
819 (progn (setq subfile (concat subpath ".jav")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
820 dir-list smart-java-package-dirs)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
821 (while dir-list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
822 (setq path (expand-file-name subfile (car dir-list))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
823 dir-list (if (setq found (file-exists-p path))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
824 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
825 (cdr dir-list))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
826 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
827 ;; If found, display file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
828 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
829 (if found
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
830 (if (file-readable-p path)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
831 (hpath:find path)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
832 (beep)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
833 (message "(smart-java-packages): `%s' unreadable." path))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
834 (beep)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
835 (message "(smart-java-packages): `%s' not found." referent))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
836 path))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
837 (goto-char opoint)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
838 nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (defun smart-library-symbol (tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 "Return non-nil if TAG is a library symbol listed in cache of such symbols.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 See the \"${hyperb:dir}/smart-clib-sym\" script for more information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (let ((buf (get-buffer-create "*junk*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (call-process (expand-file-name "smart-clib-sym" hyperb:dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 nil buf nil tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (setq found (string-equal (buffer-substring 1 2) "1"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (kill-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 found)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
856 (defun smart-tags-display (tag next)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
857 (if next (setq tag nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
858 (let ((func (or (if (fboundp 'find-tag-internal) 'find-tag-internal)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
859 (if (fboundp 'find-tag-noselect) 'find-tag-noselect)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
860 ;; For XEmacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
861 (tags-always-exact t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
862 ;; For Emacs 19
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
863 (find-tag-tag-order (if (boundp 'find-tag-tag-order)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
864 find-tag-tag-order)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
865 (if find-tag-tag-order
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
866 (if next nil (setq find-tag-tag-order '(tag-exact-match-p)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
867 ;; For InfoDock (XEmacs may also take this branch), force exact match.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
868 (if (stringp tag) (setq tag (list tag))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
869 (if (and func (funcall func tag))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
870 (hpath:display-buffer (current-buffer)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
871 ;; Signals an error if tag is not found which is caught by many callers
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
872 ;; of this function.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
873 (find-tag tag)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
874
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (defun smart-tags-file-path (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 "Expand relative FILE name by looking it up in the nearest tags file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 Return FILE unchanged if it exists relative to the current directory or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 cannot be expanded via a tags file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (or (cond ((or (file-exists-p file) (file-name-absolute-p file)) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (t (let ((tags-file (smart-tags-file default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (file-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (concat "\^L\n\\(.*/\\)?" (regexp-quote file) ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (if tags-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (set-buffer (find-file-noselect tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (if (re-search-forward file-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (buffer-substring (1- (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (point))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ;;;###autoload
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
896 (defun smart-tags-file (curr-filename &optional name-of-tags-file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
897 "Return appropriate tags file name for CURR-FILENAME or `tags-file-name'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
898 Optional NAME-OF-TAGS-FILE is the literal filename for which to look."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (let ((path curr-filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (while (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (stringp path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (setq path (file-name-directory path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (setq path (directory-file-name path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 ;; Not at root directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (not (string-match ":?/\\'" path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 ;; No tags file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (not (file-exists-p
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
909 (setq tags-file (expand-file-name (or name-of-tags-file "TAGS") path)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (setq tags-file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (if (and (not tags-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (stringp curr-filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (smart-emacs-lisp-mode-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (let ((path (file-name-directory curr-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (delq nil (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (lambda (p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (and p (equal (file-name-as-directory p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 load-path))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (setq tags-file smart-emacs-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (or tags-file tags-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (call-interactively 'visit-tags-table))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (provide 'hmouse-tag)