annotate lisp/ilisp/ilisp-src.el @ 0:376386a54a3c r19-14

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