annotate lisp/energize/energize-visit-use.el @ 149:538048ae2ab8 r20-3b1

Import from CVS: tag r20-3b1
author cvs
date Mon, 13 Aug 2007 09:36:16 +0200
parents 376386a54a3c
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 ;;; Copyright © 1992-1993 by Lucid, Inc. All Rights Reserved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Load this file and ^X-\ (back-slash) gets bound to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; command that visit all the places where a language element is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; It can be started from the Le-Browser buffer of that language element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; or from a toplevel from defining the element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; The visit happens as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; - the 1st ^X-\ jumps to the beginning of the definition of the 1sr user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; - then search-forward inside the first user for the name of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; language element that was in the le-browser buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; - the 2rd one searches again etc.. until no more match is found inside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the body of the 1 user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; - after the last match is seen the next user of the LE is visited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; the same way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; If you want to start revisiting while a previous visit is not terminated do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; ^U-^X-\ in another (or the same) le-browser buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; If you position the point on a User in the LE Browser buffer before doing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; ^X-\, that use will become the next one shown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; energize-next-use-previous, ^U-1-^X-\, backs up one use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; It's quite crude and the UI could be improved in different ways.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; What about:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; - Allow for stacking of visits so that you can recursively
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; visit another LE while one is being visited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; - Highlight all the occurences of the LE-name inside the body of the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; - Deal with *alternatives*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (defvar energize-next-use-show-le-browser t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 "*If t energize-next-use-command will show both the next use and the le-browser buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defvar energize-next-use-search-by-file nil ;; default is off cause on is slow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "*If t energize-next-use-command will show all uses in a file before going to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 the next file")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defvar energize-next-use-command-name ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defvar energize-next-use-label ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar energize-next-use-name ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvar energize-next-use-from-mark ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defvar energize-next-use-source-start-mark ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar energize-next-use-source-end-mark ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defvar energize-next-use-source-current-mark ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar energize-next-use-current-file ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defvar energize-next-use-file-began-mark ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvar energize-next-use-from-extent-cache ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defvar energize-next-use-history ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defvar energize-next-use-history-pointer ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defvar energize-next-use-marker-heap ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; remember markers we allocate so we can clean them up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defun energize-next-use-make-a-marker ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (let ((m (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (setq energize-next-use-marker-heap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (cons m energize-next-use-marker-heap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defun energize-next-use-copy-a-marker (mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (let ((m (copy-marker mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (setq energize-next-use-marker-heap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (cons m energize-next-use-marker-heap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defun energize-next-use-cleanup-markers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (while energize-next-use-marker-heap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (set-marker (car energize-next-use-marker-heap) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (setq energize-next-use-marker-heap (cdr energize-next-use-marker-heap))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defun extent-after (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (let ((extent (next-extent (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (while (and extent (< (extent-start-position extent) pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (setq extent (next-extent extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defun energize-next-use-start-pos ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (if (search-forward energize-next-use-label () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ())))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; see if we are in the LE Browser buffer of the object we are looking at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; uses of. If so, capture the position as a possible place to find the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; next user, rather than take the first or next in sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defun energize-next-use-start-pos-offset ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; energize-next-use-from-mark is NULL iff this is called from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; energize-next-use-init - in that case assume that if we are in a LEB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; it is the one we will be using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (if (if (and energize-next-use-from-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (marker-buffer energize-next-use-from-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (eq (current-buffer) (marker-buffer energize-next-use-from-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (eq major-mode 'energize-browser-mode))
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 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun energize-next-use-get-name (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (let ((colon (- (length name) 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (while (and (> colon 0) (not (eq (aref name colon) ?:)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (setq colon (- colon 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (if (= (aref name colon) ?:)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (substring name (+ colon 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; cache the extents (and later the results of following them to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; source buffer) to avoid calling the server too many times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; returns nil if the extent does not have a "source" menu option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; returns the cache entry otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defun energize-next-use-valid-from-extent-p (buff extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (let ((cache-entry (assoc extent energize-next-use-from-extent-cache)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (if (not cache-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if (energize-list-menu buff extent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 energize-next-use-command-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (setq energize-next-use-from-extent-cache
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (cons (setq cache-entry (list extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 energize-next-use-from-extent-cache))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 cache-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; decide what use to look at next. current is nil if called from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; energize-next-use-next, else it is the presumed first extent for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; energize-next-use-from-mark passed from energize-next-use-init
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; wanted-pos is the position of the cursor in the LE Browser of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; object being looked for, or nil if the cursor is not in that buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; if wanted-pos is non-nil it means we will consider restarting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; search at the user indicated by that position. Otherwise, we just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; return current. If this is nil too, it means just continue searching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; as before. If not, it means continue initializing as before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; returns an extent to be used to set energize-next-use-from-mark or nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun energize-next-use-adjust-for-start-offset (current wanted-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; assumes we're in the LE browser buffer (we may not have been when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; the value of wanted-pos was determined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (if wanted-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (let ((end-pos (energize-next-use-end-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; ok will be set to the first extent found that is actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; a user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (ok nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (try (or current (extent-after (energize-next-use-start-pos)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; loop will exit if an actual user extent is found that follows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; the wanted-pos - if we go out of bounds, try is set to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; else it is the desired extent on exit from the loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (while (and try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (or (< (extent-start-position try) end-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (setq try nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; try is a valid user extent if this menu exists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (energize-next-use-valid-from-extent-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (current-buffer) try)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; but it might be before wanted-pos,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (or (> (extent-end-position try) wanted-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; in which case remember it as ok unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; ok was already set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (and (setq ok (or ok try)) nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (setq try (next-extent try)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; return try or if we were called from init, return ok
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; else return nil to mean continue searching in current sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (or try (and current ok)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defun energize-next-use-set-marks (extent buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (not energize-next-use-from-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (setq energize-next-use-from-mark (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (set-marker energize-next-use-from-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (extent-start-position extent) buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defun energize-next-use-init (command label)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; start-offset is the position of point if it is in the LEB buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (let ((start-offset (energize-next-use-start-pos-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if (not (eq major-mode 'energize-browser-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (if (energize-list-menu (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (energize-extent-at (point)) ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "browse_le")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (energize-execute-command "browse_le"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (energize-extent-at (point)) () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "command undefined unless in a LE buffer or at a LE definition form")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (setq energize-next-use-command-name command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (setq energize-next-use-label label)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (setq energize-next-use-current-file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (setq energize-next-use-from-extent-cache nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (setq energize-next-use-history nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (setq energize-next-use-history-pointer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (let* ((pos (energize-next-use-start-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (extent (and pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; start at the beginning, unless start-pos says
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; to start further along
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (energize-next-use-adjust-for-start-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (extent-after pos) start-offset))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if (null extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (error "no uses")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (energize-next-use-set-marks extent (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (setq energize-next-use-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (let ((s (energize-next-use-get-name (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if (let ((l (length s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (while (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (and (> l 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (substring s 0 l) nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (setq l (- l 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (> l 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (let (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (setq pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (buffer-substring pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 s))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (energize-next-use-show-both)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun energize-next-use-end-pos ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (search-forward energize-next-use-label)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (re-search-forward "^ *[A-Za-z ]*: " () 'end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; return the source-entry portion of the extent cache, looking it up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; if necessary by doing energize-execute-command "source" on the extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; source-entry portion is list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; a) point marker after executing the "source" command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; b) a flag saying we've actually visited this use, not just looked it up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; c) marker for the window-start after executing the "source" command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defun energize-next-use-from-extent-source-info (from-extent-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (let ((extent (car from-extent-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (source-entry (cdr from-extent-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (if (not source-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (let ((pre-display-buffer-function nil)) ;; hack for multi-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (energize-execute-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 energize-next-use-command-name extent () t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setcdr from-extent-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (setq source-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (list (energize-next-use-copy-a-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (set-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (energize-next-use-make-a-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (window-start))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 source-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defun energize-next-use-from-extent-source-mark (source-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (car source-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun energize-next-use-from-extent-source-start-mark (source-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (car (cdr (cdr source-entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun energize-next-use-from-extent-source-seen-p (source-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (car (cdr source-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defun energize-next-use-from-extent-set-source-seen-p (source-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (setcar (cdr source-entry) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; goto the next user - or if advance is nil try to re-establish the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; extent for the current one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (defun energize-next-use-next-to-extent (advance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (let ((buff (marker-buffer energize-next-use-from-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (from-pos (marker-position energize-next-use-from-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (and buff from-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (let ((result nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (set-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (let ((end-pos (energize-next-use-end-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (extent (or (energize-extent-at from-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (setq advance nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (extent-after from-pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if (and advance energize-next-use-search-by-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (if (not energize-next-use-current-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; if searching by file but dont have a current file,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; set current file to current source buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (setq energize-next-use-current-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (and energize-next-use-source-start-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (marker-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 energize-next-use-source-start-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (if (not energize-next-use-file-began-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (setq energize-next-use-file-began-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (set-marker energize-next-use-file-began-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 from-pos buff))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (setq energize-next-use-current-file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (if advance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq extent (next-extent extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (if energize-next-use-search-by-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (message "Searching for next use in current file...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (message "Searching for next use..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; validate the extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (while extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; if extent is beyond the end of the "used by" zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; set it to nil to terminate loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (or (< (extent-start-position extent) end-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (setq extent nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (let ((from-extent-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (energize-next-use-valid-from-extent-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 buff extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; true if the extent has a "source" menu option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 from-extent-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (not energize-next-use-search-by-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; see if this is extent points to the current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; or a file we haven't looked at yet, if not current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; file is set now
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (let* ((source-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (energize-next-use-from-extent-source-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 from-extent-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (source-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (energize-next-use-from-extent-source-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 source-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (buff (marker-buffer source-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (if energize-next-use-current-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (eq buff energize-next-use-current-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (energize-next-use-from-extent-source-seen-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 source-entry)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq extent (next-extent extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (if extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; we found one we can use - remember it but set extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; to nil to terminate the loop
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 ;; convert the extent to a mark for future reference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (energize-next-use-set-marks extent buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; terminate the loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (setq extent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; saw we succeeded in finding something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (setq result t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; we didn't find anything valid - if we were looking in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; the current file, restart the loop now looking for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;; anything we haven't used yet, to make it the current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;; if we weren't looking in the current file then we really
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;; have failed to find anything left, so return nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if energize-next-use-current-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (setq energize-next-use-current-file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (setq extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; restart loop from were we started looking at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; the current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (let ((pos (marker-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 energize-next-use-file-began-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (and pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (or (energize-extent-at pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (extent-after pos)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (if energize-next-use-search-by-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (message "Searching for next use in current file...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (message "Searching for next use...done"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defun energize-next-use-show-from (&optional mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (setq mark (or mark energize-next-use-from-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if energize-next-use-show-le-browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;; position the browser to the line of the current user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (let ((buff (marker-buffer mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (from-pos (marker-position mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (and buff from-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; don't worry about pre-display-buffer-function here;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; we actually want a new frame to be created when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;; displaying the Browser buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (pop-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (goto-char from-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (set-window-start (selected-window) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (message "next use of %s" energize-next-use-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defun energize-next-use-show-to ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (let* ((buff (marker-buffer energize-next-use-from-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (from-pos (marker-position energize-next-use-from-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (from-extent (and buff from-pos (energize-extent-at from-pos buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (from-extent-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;; get the cache entry for the current user extent in the browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (energize-next-use-valid-from-extent-p buff from-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (source-extent nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 from-extent-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (let* ((source-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (energize-next-use-from-extent-source-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 from-extent-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (source-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (energize-next-use-from-extent-source-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 source-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (source-buffer (marker-buffer source-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (source-pos (marker-position source-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 ;; if we're allowed to split frames, call pop-to-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;; with no pre-display-buffer-function, so that the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ;; frame (the frame of the Browser buffer) is used. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;; we don't split frames, then use the p-d-b-f, so that a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; new frame can be created for this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (pre-display-buffer-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (if energize-split-screens-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 pre-display-buffer-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (if source-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;; position the source window as if we had just executed the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; command "source" on the from-extent in the browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (pop-to-buffer source-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (set-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (marker-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (energize-next-use-from-extent-source-start-mark source-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (goto-char source-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; note that we have actually visited this use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (energize-next-use-from-extent-set-source-seen-p source-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (setq source-extent (energize-extent-at (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (let ((start-pos (extent-start-position source-extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;; convert positions to markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (if (not energize-next-use-source-start-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (setq energize-next-use-source-start-mark (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (if (not energize-next-use-source-end-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (setq energize-next-use-source-end-mark (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (if (not energize-next-use-source-current-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (setq energize-next-use-source-current-mark (make-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (set-marker energize-next-use-source-start-mark start-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (set-marker energize-next-use-source-current-mark start-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (set-marker energize-next-use-source-end-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (extent-end-position source-extent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defun energize-next-use-search-for-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (if (let ((case-fold-search nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (found nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (end-pos (marker-position energize-next-use-source-end-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (if end-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (buffer-syntactic-context-flush-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; case sensitive exact search for token not in comment or string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (concat "[^A-Za-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (regexp-quote energize-next-use-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 "[^A-Za-z0-9_]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 end-pos t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (save-excursion (buffer-syntactic-context))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; allow for the delimiter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;; say this if search can't find the thing that is being used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (defun energize-next-use-not-lexically-apparent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (message "next use of %s is here, but not lexically apparent"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 energize-next-use-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;; called when visiting a new users, not a new use within that user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (defun energize-next-use-show-both ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;; reposition the browser to the line showing the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (energize-next-use-show-from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;; position the source to the user definition form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (energize-next-use-show-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;; instead of stopping at the beginning of the user form,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ;; go immediately to the first use found if it is lexically apparent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 energize-next-use-source-start-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (let ((buff (marker-buffer energize-next-use-source-start-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (current-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (marker-position energize-next-use-source-current-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (end-pos (marker-position energize-next-use-source-end-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (if (and buff current-pos end-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (set-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (and (< current-pos end-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (goto-char current-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (energize-next-use-search-for-name)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;; an apparent use is there, so proceed as if going to the next use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; within the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (energize-next-use-next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; no use is apparent, so print a message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (energize-next-use-not-lexically-apparent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; record the history entry for a non-apparent use - it is distinguished
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; by having no point position from which to make a region to highlight
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (setq energize-next-use-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (cons (list (energize-next-use-copy-a-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 energize-next-use-from-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (energize-next-use-copy-a-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 energize-next-use-source-current-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (set-marker (energize-next-use-make-a-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (window-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 energize-next-use-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (setq energize-next-use-history-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 energize-next-use-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;; show the next use within the current user - if no more are found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; go to the next user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (defun energize-next-use-next ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; new-start will get set to an extent for a user at which to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;; reposition the visit, iff the cursor is in the LEB buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;; of the usee at a valid position in the list of users.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (let ((new-start (energize-next-use-adjust-for-start-offset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 nil (energize-next-use-start-pos-offset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (buff (marker-buffer energize-next-use-source-start-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (current-pos (marker-position energize-next-use-source-current-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (end-pos (marker-position energize-next-use-source-end-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (if (and buff (not (eq buff (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (set-buffer buff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; new-start means we are repositioning due to the point being in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; user list in the browser. In this case we will act as if we are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; at the end of the old user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (if new-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (energize-next-use-set-marks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 new-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (marker-buffer energize-next-use-from-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (cond ((and buff current-pos end-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (not new-start) ;; don't stay in current user if repositioning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (< current-pos end-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (goto-char current-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (energize-next-use-search-for-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; the 'still in the same user' case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (set-marker energize-next-use-source-current-mark (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;; redisplay the browser in case it got covered up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (energize-next-use-show-from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; We know that we're not changing files, so there won't be any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;; need to create a new frame; it would be nice if we reselected
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;; the appropriate frame instead of just using the current frame,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; but that's more work, and this will very rarely do the wrong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ;; thing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (let ((pre-display-buffer-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (if energize-split-screens-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 pre-display-buffer-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;; display the source buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (pop-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; had to do this because window-start overrides point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; in terms of deciding what part of the window to show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ;; this seems like a possible bug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (set-window-buffer (selected-window) buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (push-mark (point) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (backward-char (length energize-next-use-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (if zmacs-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (zmacs-activate-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; record the visit in the history - this entry has a point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;; marker, distinguishing it from a non-lexically apparent one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (setq energize-next-use-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (cons (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (energize-next-use-copy-a-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 energize-next-use-from-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (energize-next-use-copy-a-marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 energize-next-use-source-current-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (set-marker (energize-next-use-make-a-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (set-marker (energize-next-use-make-a-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 energize-next-use-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (setq energize-next-use-history-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 energize-next-use-history)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ((or new-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (energize-next-use-next-to-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (and buff current-pos end-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;; the 'moved to a new user or repositioned to one' case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (energize-next-use-show-both))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; no more users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (energize-next-use-terminate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (error "no more")))))
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 energize-next-use-terminate ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (setq energize-next-use-command-name ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (setq energize-next-use-label ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (setq energize-next-use-name ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (if energize-next-use-from-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (set-marker energize-next-use-from-mark nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (if energize-next-use-source-start-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (set-marker energize-next-use-source-start-mark nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (if energize-next-use-source-current-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (set-marker energize-next-use-source-current-mark nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (if energize-next-use-source-end-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (set-marker energize-next-use-source-end-mark nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (if energize-next-use-file-began-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (set-marker energize-next-use-file-began-mark nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (energize-next-use-cleanup-markers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; get next use from history list if we have regressed or are regressing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;; if history-pointer == history then we are in the present
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; to go back set history-pointer to cdr history-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; to go forward set history-pointer to the last cell on history prior to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;; the current value of history-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; a history entry is just redisplay info for the browser and source buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (defun energize-next-use-from-history (backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (if backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (setq energize-next-use-history-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (cdr energize-next-use-history-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (let ((temp energize-next-use-history-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (setq energize-next-use-history-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 energize-next-use-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (while (not (eq (cdr energize-next-use-history-pointer) temp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq energize-next-use-history-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (cdr energize-next-use-history-pointer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (let* ((history-entry (car energize-next-use-history-pointer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (from-mark (car history-entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (source-mark (car (cdr history-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (source-start-mark (car (cdr (cdr history-entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (source-point-mark (car (cdr (cdr (cdr history-entry))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (energize-next-use-show-from from-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (if (and (marker-position source-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (marker-position source-start-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (pop-to-buffer (marker-buffer source-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (set-window-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (selected-window) (marker-position source-start-mark) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (goto-char source-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (if (and source-point-mark (marker-position source-point-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (push-mark (point) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (goto-char source-point-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (if zmacs-regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (zmacs-activate-region)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (energize-next-use-not-lexically-apparent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (defun energize-next-use-go (label command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (if (and energize-next-use-from-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (marker-position energize-next-use-from-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (if (eq energize-next-use-history-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 energize-next-use-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; normal case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (energize-next-use-next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;; in the depths of history but going forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (energize-next-use-from-history nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; beginning of time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (energize-next-use-init label command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (defun energize-next-use-previous ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (if (cdr energize-next-use-history-pointer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; going back in time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (energize-next-use-from-history t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; trying to go beyond the pale
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (error "no prior use")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (defun energize-next-use-command (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 "Show the next place where the current language element is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 The current language element is the one that point is on for source buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 or the element displayed in a language element browser buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 Repeated calls to this functions visit all the callers in sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 With prefix arg = 1, back up to the last use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 With prefix arg > 1, start a visit from scratch on the current language
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 If the point is on a particular user in the language element browser, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 search will be (re)started in that user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 The variable energize-next-use-show-le-browser controls if this command should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 display both the language element browser buffer and the next user or just the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 next user of the current language element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 The variable energize-next-use-search-by-file controls whether all uses within
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 a given file should be shown in sequence. If the value is nil, the uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 are shown in the order in which they appear in the LE Browser. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 value is non-nil, the all uses in a given file are shown before proceeding to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 the next use in another file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (if (eq arg 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (energize-next-use-previous)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (energize-next-use-terminate))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (energize-next-use-go "source" "Used By:")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (define-key global-map '[(control x) \\] 'energize-next-use-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (defun energize-next-use-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 "Start visiting the uses of a language element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 If executed in a LE Browser buffer visit the uses of the language element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 in the buffer. In a source buffer visit the uses of the language element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 at (point)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (energize-next-use-command 4))