annotate lisp/ilisp/ilisp-src.el @ 35:279432d5c479

Added tag r19-15b100 for changeset d620409f5eb8
author cvs
date Mon, 13 Aug 2007 08:53:21 +0200
parents b82b59fe008d
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 ;;; -*- Mode: Emacs-Lisp -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; ilisp-src.el --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; This file is part of ILISP.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
6 ;;; Version: 5.8
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; 1993, 1994 Ivan Vasquez
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
10 ;;; 1994, 1995, 1996 Marco Antoniotti and Rick Busdiecker
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
11 ;;; 1996 Marco Antoniotti and Rick Campbell
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; Other authors' names for which this Copyright notice also holds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; may appear later in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
16 ;;; Send mail to 'ilisp-request@naggum.no' to be included in the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
17 ;;; ILISP mailing list. 'ilisp@naggum.no' is the general ILISP
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; mailing list were bugs and improvements are discussed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; ILISP is freely redistributable under the terms found in the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; COPYING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; See ilisp.el for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;%Source file operations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (if (not (boundp 'tags-file-name)) (defvar tags-file-name nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (defvar lisp-last-definition nil "Last definition (name type) looked for.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (defvar lisp-last-file nil "Last used source file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defvar lisp-first-point nil "First point found in last source file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar lisp-last-point nil "Last point in last source file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (defvar lisp-last-locator nil "Last source locator used.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defvar lisp-search nil "Set to T when searching for definitions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar lisp-using-tags nil "Set to T when using tags.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;;%%lisp-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defvar lisp-edit-files t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "If T, then buffers in one of lisp-source-modes will be searched by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 edit-definitions-lisp if the source cannot be found through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 inferior LISP. It can also be a list of files to edit definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 from set up by \(\\[lisp-directory]). If it is set to nil, then no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 additional files will be searched.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defun lisp-extensions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "Return a regexp for matching the extensions of files that enter one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 of lisp-source-modes according to auto-mode-alist."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (let ((entries auto-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (extensions nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (while entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (let ((entry (car entries)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (if (memq (cdr entry) lisp-source-modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (concat "\\|" (car entry) extensions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setq entries (cdr entries)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (substring extensions 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defun lisp-directory (directory add)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "Edit the files in DIRECTORY that have an auto-mode alist entry in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 lisp-source-modes. With a positive prefix, add the files on to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 already existing files. With a negative prefix, clear the list. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 either case set tags-file-name to nil so that tags are not used."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (list (if (not (eq current-prefix-arg '-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (read-file-name "Lisp Directory: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (setq tags-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (if (eq add '-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (progn (setq lisp-edit-files t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (message "No current lisp directory"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (if add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (message "Added %s as a lisp directory" directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (message "%s is the lisp directory" directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq directory (expand-file-name directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (file-directory-p directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (setq lisp-edit-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (directory-files directory t (lisp-extensions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (if add (if (eq lisp-edit-files t) nil lisp-edit-files))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (error "%s is not a directory" directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;;%%Utilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defun fix-source-filenames ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 "Apply the ilisp-source-directory-fixup-alist to the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (which will be *Edit-Definitions*) to change any pre-compiled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 source-file locations to point to local source file locations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 See ilisp-source-directory-fixup-alist."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (let ((alist (ilisp-value 'ilisp-source-directory-fixup-alist t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (if alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (setq cons (car alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (if (re-search-forward (car cons) (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (replace-match (cdr cons)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (setq alist (cdr alist)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defun lisp-setup-edit-definitions (message edit-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "Set up *Edit-Definitions* with MESSAGE. If EDIT-FILES is T, insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 all buffer filenames that are in one of lisp-source-modes into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 current buffer. If it is a list of files set up by lisp-directory,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 insert those in the buffer. If it is a string put that in the buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setq lisp-using-tags nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 lisp-search (not (stringp edit-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (set-buffer (get-buffer-create "*Edit-Definitions*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (insert message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (if edit-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (if (eq edit-files t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (let ((buffers (buffer-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (let ((buffer (car buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (and (memq major-mode lisp-source-modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (buffer-file-name buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (progn (insert ?\") (insert (buffer-file-name buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (insert "\"\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (setq buffers (cdr buffers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (if (stringp edit-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (progn (insert edit-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; Remove garbage collection messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (replace-regexp "^;[^\n]*\n" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (fix-source-filenames))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let ((files edit-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (while files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (insert ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (insert (car files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (insert "\"\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (setq files (cdr files))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (forward-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "Use \\[lisp-directory] to define source files."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defun lisp-locate-definition (locator definition file point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 &optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 back pop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 "Use LOCATOR to find the next DEFINITION (symbol . type) in FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 starting at POINT, optionally BACKWARDS and POP to buffer. Return T
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 if successful."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (not (file-exists-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (message "File %s doesn't exist!" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (let* ((symbol (car definition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (type (cdr definition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (first (not (eq lisp-last-file file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (lisp-find-file file pop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (if first (setq lisp-first-point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (if back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (if first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (goto-char point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (if (not first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (progn (forward-line 1) (beginning-of-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (if (eq type 't)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (message "Search %s for %s" file symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (message "Searching %s for %s %s" file type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq name (lisp-buffer-symbol symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (if (funcall locator symbol type first back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (setq lisp-last-file file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 lisp-last-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (if (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (recenter 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (if name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (message "Found %s %s definition" type name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (message "Found %s"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (if first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (goto-char lisp-first-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (goto-char point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (defun lisp-next-file (back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 "Return the next filename in *Edit-Definitions*, or nil if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (let ((file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (set-buffer (get-buffer-create "*Edit-Definitions*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (if back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (progn (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (if (looking-at "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (setq file nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (skip-chars-forward "^\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (progn (bury-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (setq result nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (let* ((start (progn (forward-char 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (skip-chars-forward "^\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (setq file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (prog1 (buffer-substring start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (end-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (bury-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (if (not (eq file 't)) file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defun lisp-next-definition (back pop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "Go to the next definition from *Edit-Definitions* going BACK with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 prefix and POPPING. Return 'first if found first time, 'none if no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 definition ever, T if another definition is found, and nil if no more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 definitions are found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (let ((done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (result nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (lisp-locate-definition ;Same file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 lisp-last-locator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 lisp-last-definition lisp-last-file lisp-last-point back))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (let ((file (lisp-next-file back)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (if (lisp-locate-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 lisp-last-locator lisp-last-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 file 1 back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (prog1 pop (setq pop nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (setq result 'first)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq result (if (not lisp-search) 'none)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (set-buffer (window-buffer (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;;%%Next-definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defun next-definition-lisp (back &optional pop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "Edit the next definition from *Edit-Definitions* going BACK with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 prefix and optionally POPPING or call tags-loop-continue if using tags."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if lisp-using-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (tags-loop-continue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (let* ((result (lisp-next-definition back pop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (symbol (car lisp-last-definition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (type (cdr lisp-last-definition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (name (if (not (eq type 't)) (lisp-buffer-symbol symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (cond ((or (eq result 'first) (eq result 't))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (if name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (message "Found %s %s definition" type name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (message "Found %s" symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ((eq result 'none)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (error "Can't find %s %s definition" type name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (if name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (error "No more %s %s definitions" type name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (message "Done")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;;;%%Edit-definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (defun edit-definitions-lisp (symbol type &optional stay search locator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 "Find the source files for the TYPE definitions of SYMBOL. If STAY,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 use the same window. If SEARCH, do not look for symbol in inferior
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 LISP. The definition will be searched for through the inferior LISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 and if not found it will be searched for in the current tags file and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 if not found in the files in lisp-edit-files set up by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 \(\\[lisp-directory]) or the buffers in one of lisp-source-modes if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 lisp-edit-files is T. If lisp-edit-files is nil, no search will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 done if not found through the inferior LISP. TYPES are from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ilisp-source-types which is an alist of symbol strings or list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 strings. With a negative prefix, look for the current symbol as the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 first type in ilisp-source-types."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (let* ((types (ilisp-value 'ilisp-source-types t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (default (if types (car (car types))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (function (lisp-function-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (symbol (lisp-buffer-symbol function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (list function default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (list (ilisp-read-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (format "Edit Definition [%s]: " symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (if types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (ilisp-completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (format "Type [%s]: " default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 types default))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (let* ((name (lisp-buffer-symbol symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (symbol-name (lisp-symbol-name symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (command (ilisp-value 'ilisp-find-source-command t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (source
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (if (and command (not search) (comint-check-proc ilisp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (format command symbol-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (lisp-symbol-package symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (concat "Finding " type " " name " definitions")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 'source )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 "nil"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (result (and source (lisp-last-line source)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (source-ok (not (or (ilisp-value 'comint-errorp t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (null result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (string-match "nil" (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (tagged nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (if (and tags-file-name (not source-ok))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (progn (setq lisp-using-tags t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (if (string-match "Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (find-tag symbol-name stay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (find-tag symbol-name nil stay))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (setq tagged t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if (not tagged)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (setq lisp-last-definition (cons symbol type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 lisp-last-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 lisp-last-locator (or locator (ilisp-value 'ilisp-locator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (lisp-setup-edit-definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (format "%s %s definitions:" type name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if source-ok (cdr result) lisp-edit-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (next-definition-lisp nil t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;;;%%Searching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (defun lisp-locate-search (pattern type first back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 "Find PATTERN in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (search-backward pattern nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (search-forward pattern nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun lisp-locate-regexp (regexp type first back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Find REGEXP in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (if back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (re-search-backward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (re-search-forward regexp nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defvar lisp-last-pattern nil "Last search regexp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defun search-lisp (pattern regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 "Search for PATTERN through the files in lisp-edit-files if it is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 list and the current buffers in one of lisp-source-modes otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 If lisp-edit-files is nil, no search will be done. If called with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 prefix, search for regexp. If there is a tags file, call tags-search instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (list (read-string (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 "Search for regexp: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "Search for: ") lisp-last-pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (if tags-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (progn (setq lisp-using-tags t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (tags-search (if regexp pattern (regexp-quote pattern))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (setq lisp-last-pattern pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 lisp-last-definition (cons pattern t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 lisp-last-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 lisp-last-locator (if regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 'lisp-locate-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 'lisp-locate-search))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (lisp-setup-edit-definitions (format "Searching for %s:" pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 lisp-edit-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (next-definition-lisp nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;;;%%Replacing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defvar lisp-last-replace nil "Last replace regexp.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun replace-lisp (old new regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "Query replace OLD by NEW through the files in lisp-edit-files if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 is a list and the current buffers in one of lisp-source-modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 otherwise. If lisp-edit-files is nil, no search will be done. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 called with a prefix, replace regexps. If there is a tags file, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 call tags-query-replace instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (let ((old (read-string (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "Replace regexp: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "Replace: ") lisp-last-pattern)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (list old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (read-string (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (format "Replace regexp %s by: " old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (format "Replace %s by: " old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 lisp-last-replace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 current-prefix-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (if tags-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (progn (setq lisp-using-tags t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (tags-query-replace (if regexp old (regexp-quote old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq lisp-last-pattern old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 lisp-last-replace new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (lisp-setup-edit-definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (format "Replacing %s by %s:\n\n" old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 lisp-edit-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (let (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (while (setq file (lisp-next-file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (lisp-find-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (let ((point (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (if (if regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (re-search-forward old nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (search-forward old nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (if regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (query-replace-regexp old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (query-replace old new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (goto-char point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ;;;%%Edit-callers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (defvar lisp-callers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 "T if we found callers through inferior LISP.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (defun who-calls-lisp (function &optional no-show)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 "Put the functions that call FUNCTION into the buffer *All-Callers*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 and show it unless NO-SHOW is T. Return T if successful."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (let* ((function (lisp-defun-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (symbol (lisp-buffer-symbol function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (list function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (list (ilisp-read-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (format "Who Calls [%s]: " symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 t t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (let* ((name (lisp-buffer-symbol function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (command (ilisp-value 'ilisp-callers-command t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (callers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (ilisp-send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (format command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (lisp-symbol-name function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (lisp-symbol-package function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (concat "Finding callers of " name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 'callers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (last-line (lisp-last-line callers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (set-buffer (get-buffer-create "*All-Callers*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (insert (format "All callers of function %s:\n\n" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (if (and command (not (ilisp-value 'comint-errorp t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (if (string-match "nil" (car last-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (error "%s has no callers" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (insert (cdr last-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ;; Remove garbage collection messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (replace-regexp "^;[^\n]*\n" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (forward-line 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (if (not no-show)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (if (ilisp-temp-buffer-show-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (funcall (ilisp-temp-buffer-show-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (get-buffer "*All-Callers*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (view-buffer "*All-Callers*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (insert "Using the current source files to find callers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (defun next-caller-lisp (back &optional pop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 "Edit the next caller from *All-Callers*. With prefix, edit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 the previous caller. If it can't get caller information from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 inferior LISP, this will search using the current source files. See
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 lisp-directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (if (not lisp-callers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (next-definition-lisp back pop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (set-buffer (get-buffer-create "*All-Callers*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (if back (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (skip-chars-forward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (bury-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (error "No more callers"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (let* ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (caller-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (skip-chars-forward "^ \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (buffer-substring start (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (bury-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (edit-definitions-lisp (lisp-string-to-symbol caller-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (car (car (ilisp-value 'ilisp-source-types)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (not pop))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (defun edit-callers-lisp (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 "Edit the callers of FUNCTION. With a minus prefix use the symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 at the start of the current defun."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (let* ((function (lisp-defun-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (if (lisp-minus-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (list function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (list (ilisp-read-symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (format "Edit callers of [%s]: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (lisp-buffer-symbol function))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (if (save-excursion (setq lisp-callers (who-calls-lisp function t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (setq lisp-last-locator (ilisp-value 'ilisp-calls-locator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (next-caller-lisp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (edit-definitions-lisp function "calls" nil t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (ilisp-value 'ilisp-calls-locator))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;;;%Locators
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defun lisp-re (back format &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 "Search BACK if T using FORMAT applied to ARGS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (let ((regexp (apply 'format format args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (if back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (re-search-backward regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (re-search-forward regexp nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (defun lisp-locate-ilisp (symbol type first back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 "Find SYMBOL's TYPE definition in the current file and return T if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 successful. A definition is of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 \(def<whitespace>(?name<whitespace>."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (lisp-re back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 "^[ \t\n]*(def[^ \t\n]*[ \t\n]+(?%s[ \t\n(]+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (regexp-quote (lisp-symbol-name symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (defun lisp-locate-calls (symbol type first back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 "Locate calls to SYMBOL."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (lisp-re back "\\(#'\\|(\\|'\\)%s\\([ \t\n]+\\|)\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (regexp-quote (lisp-buffer-symbol symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ;;;%%Common LISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (defvar ilisp-cl-source-locater-patterns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 '((setf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 "^\\(.\\)?[ \t\n]*(def[^ \t\n]*\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)(setf\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[ \t\n]*\\(.\\)?[ \t\n]*)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 "^\\(.\\)?[ \t\n]*(defun\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[ \t\n(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 "^\\(.\\)?[ \t\n]*(defmacro\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[ \t\n(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 "^\\(.\\)?[ \t\n]*(def\\(\\(var\\)\\|\\(parameter\\)\\|constant\\)\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[ \t\n(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 "^\\(.\\)?[ \t\n]*(defstruct\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)(?[ \t\n]*\\(.\\)?[ \t\n]*%s[ \t\n(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 "^\\(.\\)?[ \t\n]*(deftype\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[ \t\n(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 "^\\(.\\)?[ \t\n]*(defclass\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[ \t\n(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun ilisp-locate-clisp-defn (name type back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (let ((pattern (car (cdr (assoc (intern type) ilisp-cl-source-locater-patterns)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (if pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (lisp-re back pattern name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (defun ilisp-locate-clos-method (name type back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (if (string-match "(\\([^(]*\\)\\(([^)]*)\\)" type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (let* ((quals (substring type (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (read (substring type (match-beginning 2) (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (class-re nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (position 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (while (setq position (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 "\\([ \t\n]+.[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\|[ \t\n]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 quals position))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (setq quals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (concat (substring quals 0 position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 "\\([ \t\n]+.[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\|[ \t\n]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (substring quals (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (while class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (setq class-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 class-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "[ \t\n]*\\(.\\)?[ \t\n]*([ \t\n]*\\(.\\)?[ \t\n]*[^ \t\n]*\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[ \t\n]*\\(.\\)?[ \t\n]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (car class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 class (cdr class)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (lisp-re back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 "^\\(.\\)?[ \t\n]*(def[^ \t\n]*\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[^ \t\n]*([^ \t\n]*%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 name quals class-re))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (defun lisp-locate-clisp (symbol type first back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 "Try to find SYMBOL's TYPE definition in the current buffer and return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 T if sucessful. FIRST is T if this is the first time in a file. BACK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 is T to go backwards."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (let* ((name (regexp-quote (lisp-symbol-name symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; Automatically generated defstruct accessors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (if (string-match "-" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (let ((struct (substring name 0 (1- (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 "^\\(.\\)?[ \t\n]*(def[^ \t\n]*\\([ \t\n]+\\(.\\)?\\|\\|[ \t\n]*.[ \t\n]+\\)(?%s[ \t\n)]\\|:conc-name\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 struct struct))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;; Defclass accessors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 "\\(:accessor\\|:writer\\|:reader\\)\\([ \t\n]+\\(.\\)?+[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)%s[ \t\n)]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (if (equal type "any")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (lisp-re
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 "^\\(.\\)?[ \t\n]*(def[^ \t\n]*\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)\\((setf\\([ \t\n]+\\(.\\)?[ \t\n]*\\|[ \t\n]*.[ \t\n]+\\)\\|(?[ \t\n]*\\(.\\)?[ \t\n]*\\)%s[ \t\n)]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (if prefix (concat "\\|" prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 name name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;; (qualifiers* (type1 type2 ...))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (ilisp-locate-clos-method name type back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (ilisp-locate-clisp-defn name type back)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; Standard def form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (if first (lisp-locate-ilisp symbol type first back))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;; Automatically generated defstruct accessors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (if (and first prefix) (lisp-re back prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; Defclass accessors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (lisp-re back class name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; Give up!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 )))