Mercurial > emacs
annotate lisp/ediff-mult.el @ 26078:1dfff19134ab
(picture-killed-rectangle): Use defvar, not defconst.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 18 Oct 1999 21:20:22 +0000 |
parents | c222c6df8c5a |
children | 4f315ca65976 |
rev | line source |
---|---|
13607
71a4a349d998
Renamed from ediff-meta.el. Changed provide.
Richard M. Stallman <rms@gnu.org>
parents:
13216
diff
changeset
|
1 ;;; ediff-mult.el --- support for multi-file/multi-buffer processing in Ediff |
14169 | 2 |
18054 | 3 ;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. |
13130 | 4 |
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
13130 | 23 |
14169 | 24 ;;; Commentary: |
25 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
26 ;; Users are encouraged to add functionality to this file. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
27 ;; The present file contains all the infrastructure needed for that. |
13130 | 28 ;; |
29 ;; Generally, to to implement a new multisession capability within Ediff, | |
30 ;; you need to tell it | |
31 ;; | |
32 ;; 1. How to display the session group buffer. | |
33 ;; This function must indicate which Ediff sessions are active (+) and | |
34 ;; which are finished (-). | |
35 ;; See ediff-redraw-directory-group-buffer for an example. | |
36 ;; In all likelihood, ediff-redraw-directory-group-buffer can be used | |
37 ;; directly or after a small modification. | |
38 ;; 2. What action to take when the user clicks button 2 or types v,e, or | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
39 ;; RET. See ediff-filegroup-action. |
13130 | 40 ;; 3. Provide a list of pairs or triples of file names (or buffers, |
41 ;; depending on the particular Ediff operation you want to invoke) | |
42 ;; in the following format: | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
43 ;; (descriptor (obj1 obj2 obj3) (...) ...) |
13130 | 44 ;; Actually, the format of this list is pretty much up to the |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
45 ;; developer. The only thing is that it must be a list of lists, |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
46 ;; and the first list must describe the meta session, and subsequent |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
47 ;; elements must describe individual sessions. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
48 ;; This descriptor must be a list of two, three, or four elements (nil |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
49 ;; or string). The function ediff-redraw-registry-buffer displays the |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
50 ;; second through last of these in the registry buffer. |
13130 | 51 ;; Also, keep in mind that the function ediff-prepare-meta-buffer |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
52 ;; (which see) prepends the session group buffer to the descriptor and |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
53 ;; nil in front of each subsequent list (i.e., the above list |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
54 ;; will become |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
55 ;; ((meta-buf descriptor) (nil obj1 obj2 obj3) (nil ...) ...) |
13130 | 56 ;; Ediff expects that your function (in 2 above) will arrange to |
57 ;; replace this prepended nil (via setcar) with the actual ediff | |
58 ;; control buffer associated with an appropriate Ediff session. | |
59 ;; This is arranged through internal startup hooks that can be passed | |
60 ;; to any of Ediff major entries (such as ediff-files, epatch, etc.). | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
61 ;; See how this is done in ediff-filegroup-action. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
62 ;; |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
63 ;; Session descriptions are of the form (obj1 obj2 obj3), which |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
64 ;; describe objects relevant to the session. Usually they are names of |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
65 ;; files, but sometimes they may be other things. For instance, obj3 is |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
66 ;; nil for jobs that involve only two files. For patch jobs, obj2 and |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
67 ;; obj3 are markers that specify the patch corresponding to the file |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
68 ;; (whose name is obj1). |
13130 | 69 ;; 4. Write a function that makes a call to ediff-prepare-meta-buffer |
70 ;; passing all this info. | |
71 ;; You may be able to use ediff-directories-internal as a template. | |
72 ;; 5. If you intend to add several related pieces of functionality, | |
73 ;; you may want to keep the function in 4 as an internal version | |
74 ;; and then write several top-level interactive functions that call it | |
75 ;; with different parameters. | |
76 ;; See how ediff-directories, ediff-merge-directories, and | |
77 ;; ediff-merge-directories-with-ancestor all use | |
78 ;; ediff-directories-internal. | |
79 ;; | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
80 ;; A useful addition here could be session groups selected by patterns |
13130 | 81 ;; (which are different in each directory). For instance, one may want to |
82 ;; compare files of the form abc{something}.c to files old{something}.d | |
83 ;; which may be in the same or different directories. Or, one may want to | |
84 ;; compare all files of the form {something} to files of the form {something}~. | |
85 ;; | |
13216
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13130
diff
changeset
|
86 ;; Implementing this requires writing an collating function, which should pair |
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13130
diff
changeset
|
87 ;; up appropriate files. It will also require a generalization of the functions |
13130 | 88 ;; that do the layout of the meta- and differences buffers and of |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
89 ;; ediff-filegroup-action. |
13130 | 90 |
14169 | 91 ;;; Code: |
92 | |
18054 | 93 (provide 'ediff-mult) |
94 | |
95 (defgroup ediff-mult nil | |
19241 | 96 "Multi-file and multi-buffer processing in Ediff" |
18054 | 97 :prefix "ediff-" |
98 :group 'ediff) | |
99 | |
100 | |
101 ;; compiler pacifier | |
102 (eval-when-compile | |
103 (let ((load-path (cons (expand-file-name ".") load-path))) | |
104 (or (featurep 'ediff-init) | |
105 (load "ediff-init.el" nil nil 'nosuffix)) | |
106 (or (featurep 'ediff-util) | |
107 (load "ediff-util.el" nil nil 'nosuffix)) | |
108 )) | |
109 ;; end pacifier | |
110 | |
13130 | 111 (require 'ediff-init) |
18054 | 112 (require 'ediff-util) |
13130 | 113 |
114 ;; meta-buffer | |
115 (ediff-defvar-local ediff-meta-buffer nil "") | |
116 (ediff-defvar-local ediff-parent-meta-buffer nil "") | |
117 ;; the registry buffer | |
118 (defvar ediff-registry-buffer nil) | |
119 | |
120 (defconst ediff-meta-buffer-message "This is an Ediff Session Group Panel: %s | |
121 | |
122 Useful commands: | |
20206 | 123 button2, v, or RET over session record: start that Ediff session |
124 M:\tin sessions invoked from here, brings back this group panel | |
125 R:\tdisplay the registry of active Ediff sessions | |
126 h:\tmark session for hiding (toggle) | |
127 x:\thide marked sessions; with prefix arg: unhide | |
128 m:\tmark session for a non-hiding operation (toggle) | |
22286 | 129 uh/um:\tunmark all sessions marked for hiding/operation |
20206 | 130 n,SPC:\tnext session |
131 p,DEL:\tprevious session | |
132 E:\tbrowse Ediff on-line manual | |
133 T:\ttoggle truncation of long file names | |
134 q:\tquit this session group | |
13130 | 135 ") |
136 | |
137 (ediff-defvar-local ediff-meta-buffer-map nil | |
138 "The keymap for the meta buffer.") | |
139 (defvar ediff-dir-diffs-buffer-map (make-sparse-keymap) | |
140 "The keymap to be installed in the buffer showing differences between | |
141 directories.") | |
142 | |
143 ;; Variable specifying the action to take when the use invokes ediff in the | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
144 ;; meta buffer. This is usually ediff-registry-action or ediff-filegroup-action |
13130 | 145 (ediff-defvar-local ediff-meta-action-function nil "") |
146 ;; Tells ediff-update-meta-buffer how to redraw it | |
147 (ediff-defvar-local ediff-meta-redraw-function nil "") | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
148 ;; Tells ediff-filegroup-action and similar procedures how to invoke Ediff for |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
149 ;; the sessions in a given session group |
13130 | 150 (ediff-defvar-local ediff-session-action-function nil "") |
151 | |
152 (ediff-defvar-local ediff-metajob-name nil "") | |
153 | |
154 ;; buffer used to collect custom diffs from individual sessions in the group | |
155 (ediff-defvar-local ediff-meta-diff-buffer nil "") | |
156 | |
157 ;; history var to use for filtering groups | |
158 (defvar ediff-filtering-regexp-history nil "") | |
159 | |
19774 | 160 ;; This has the form ((meta-buf regexp dir1 dir2 dir3 merge-auto-store-dir) |
161 ;; (ctl-buf session-status (file1 . eq-status) (file2 . eq-status) (file3 | |
162 ;; . eq-status)) (ctl-buf session-status (file1 . eq-status) (file2 | |
163 ;; . eq-status)) ...) | |
164 ;; If ctl-buf is nil, the file-pair hasn't processed yet. If it is | |
13130 | 165 ;; killed-buffer object, the file pair has been processed. If it is a live |
19774 | 166 ;; buffer, this means ediff is still working on the pair. |
167 ;; Eq-status of a file is t if the file equals some other file in the same | |
168 ;; group. | |
13130 | 169 (ediff-defvar-local ediff-meta-list nil "") |
170 | |
20206 | 171 (ediff-defvar-local ediff-meta-session-number nil "") |
172 | |
13130 | 173 |
174 ;; the difference list between directories in a directory session group | |
175 (ediff-defvar-local ediff-dir-difference-list nil "") | |
176 (ediff-defvar-local ediff-dir-diffs-buffer nil "") | |
177 | |
178 ;; The registry of Ediff sessions. A list of control buffers. | |
179 (defvar ediff-session-registry nil) | |
180 | |
20206 | 181 (defcustom ediff-meta-truncate-filenames t |
182 "*If non-nil, truncate long file names in the session group buffers. | |
183 This can be toggled with `ediff-toggle-filename-truncation'." | |
184 :type 'hook | |
185 :group 'ediff-mult) | |
18054 | 186 (defcustom ediff-registry-setup-hook nil |
187 "*Hooks run just after the registry control panel is set up." | |
188 :type 'hook | |
189 :group 'ediff-mult) | |
190 (defcustom ediff-session-group-setup-hook nil | |
13130 | 191 "*Hooks run just after a meta-buffer controlling a session group, such as |
18054 | 192 ediff-directories, is run." |
193 :type 'hook | |
194 :group 'ediff-mult) | |
195 (defcustom ediff-quit-session-group-hook nil | |
196 "*Hooks run just before exiting a session group." | |
197 :type 'hook | |
198 :group 'ediff-mult) | |
199 (defcustom ediff-show-registry-hook nil | |
200 "*Hooks run just after the registry buffer is shown." | |
201 :type 'hook | |
202 :group 'ediff-mult) | |
203 (defcustom ediff-show-session-group-hook nil | |
204 "*Hooks run just after a session group buffer is shown." | |
205 :type 'hook | |
206 :group 'ediff-mult) | |
207 (defcustom ediff-meta-buffer-keymap-setup-hook nil | |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
208 "*Hooks run just after setting up the ediff-meta-buffer-map. |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
209 This keymap controls key bindings in the meta buffer and is a local variable. |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
210 This means that you can set different bindings for different kinds of meta |
18054 | 211 buffers." |
212 :type 'hook | |
213 :group 'ediff-mult) | |
13130 | 214 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
215 ;; buffer holding the multi-file patch. local to the meta buffer |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
216 (ediff-defvar-local ediff-meta-patchbufer nil "") |
13130 | 217 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
218 ;;; API for ediff-meta-list |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
219 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
220 ;; group buffer/regexp |
19774 | 221 (defsubst ediff-get-group-buffer (meta-list) |
13130 | 222 (nth 0 (car meta-list))) |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
223 |
19774 | 224 (defsubst ediff-get-group-regexp (meta-list) |
13130 | 225 (nth 1 (car meta-list))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
226 ;; group objects |
19774 | 227 (defsubst ediff-get-group-objA (meta-list) |
13130 | 228 (nth 2 (car meta-list))) |
19774 | 229 (defsubst ediff-get-group-objB (meta-list) |
13130 | 230 (nth 3 (car meta-list))) |
19774 | 231 (defsubst ediff-get-group-objC (meta-list) |
13130 | 232 (nth 4 (car meta-list))) |
19774 | 233 (defsubst ediff-get-group-merge-autostore-dir (meta-list) |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
234 (nth 5 (car meta-list))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
235 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
236 ;; session buffer |
19774 | 237 (defsubst ediff-get-session-buffer (elt) |
13130 | 238 (nth 0 elt)) |
19774 | 239 (defsubst ediff-get-session-status (elt) |
13130 | 240 (nth 1 elt)) |
19774 | 241 (defsubst ediff-set-session-status (session-info new-status) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
242 (setcar (cdr session-info) new-status)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
243 ;; session objects |
19774 | 244 (defsubst ediff-get-session-objA (elt) |
13130 | 245 (nth 2 elt)) |
19774 | 246 (defsubst ediff-get-session-objB (elt) |
13130 | 247 (nth 3 elt)) |
19774 | 248 (defsubst ediff-get-session-objC (elt) |
13130 | 249 (nth 4 elt)) |
19774 | 250 (defsubst ediff-get-session-objA-name (elt) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
251 (car (nth 2 elt))) |
19774 | 252 (defsubst ediff-get-session-objB-name (elt) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
253 (car (nth 3 elt))) |
19774 | 254 (defsubst ediff-get-session-objC-name (elt) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
255 (car (nth 4 elt))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
256 ;; equality indicators |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
257 (defsubst ediff-get-file-eqstatus (elt) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
258 (nth 1 elt)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
259 (defsubst ediff-set-file-eqstatus (elt value) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
260 (setcar (cdr elt) value)) |
13130 | 261 |
20206 | 262 ;; The activity marker is either or + (active session, i.e., ediff is currently |
263 ;; run in it), or - (finished session, i.e., we've ran ediff in it and then | |
264 ;; exited). Return nil, if session is neither active nor finished | |
265 (defun ediff-get-session-activity-marker (session) | |
266 (let ((session-buf (ediff-get-session-buffer session))) | |
267 (cond ((null session-buf) nil) ; virgin session | |
268 ((ediff-buffer-live-p session-buf) ?+) ;active session | |
269 (t ?-)))) | |
270 | |
19774 | 271 ;; checks if the session is a meta session |
272 (defun ediff-meta-session-p (session-info) | |
273 (and (stringp (ediff-get-session-objA-name session-info)) | |
274 (file-directory-p (ediff-get-session-objA-name session-info)) | |
275 (stringp (ediff-get-session-objB-name session-info)) | |
276 (file-directory-p (ediff-get-session-objB-name session-info)) | |
277 (if (stringp (ediff-get-session-objC-name session-info)) | |
278 (file-directory-p (ediff-get-session-objC-name session-info)) t))) | |
279 | |
13130 | 280 ;; set up the keymap in the meta buffer |
281 (defun ediff-setup-meta-map() | |
282 (setq ediff-meta-buffer-map (make-sparse-keymap)) | |
283 (suppress-keymap ediff-meta-buffer-map) | |
284 (define-key ediff-meta-buffer-map "q" 'ediff-quit-meta-buffer) | |
20206 | 285 (define-key ediff-meta-buffer-map "T" 'ediff-toggle-filename-truncation) |
13130 | 286 (define-key ediff-meta-buffer-map "R" 'ediff-show-registry) |
287 (define-key ediff-meta-buffer-map "E" 'ediff-documentation) | |
288 (define-key ediff-meta-buffer-map "v" ediff-meta-action-function) | |
289 (define-key ediff-meta-buffer-map "\C-m" ediff-meta-action-function) | |
290 (define-key ediff-meta-buffer-map " " 'ediff-next-meta-item) | |
20206 | 291 (define-key ediff-meta-buffer-map "n" 'ediff-next-meta-item) |
13130 | 292 (define-key ediff-meta-buffer-map "\C-?" 'ediff-previous-meta-item) |
20206 | 293 (define-key ediff-meta-buffer-map "p" 'ediff-previous-meta-item) |
13130 | 294 (define-key ediff-meta-buffer-map [delete] 'ediff-previous-meta-item) |
295 (define-key ediff-meta-buffer-map [backspace] 'ediff-previous-meta-item) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
296 (or (ediff-one-filegroup-metajob) |
22286 | 297 (progn |
298 (define-key ediff-meta-buffer-map "=" nil) | |
299 (define-key ediff-meta-buffer-map "==" 'ediff-meta-mark-equal-files) | |
300 (define-key ediff-meta-buffer-map "=m" 'ediff-meta-mark-equal-files) | |
301 (define-key ediff-meta-buffer-map "=h" 'ediff-meta-mark-equal-files))) | |
13130 | 302 (if ediff-no-emacs-help-in-control-buffer |
303 (define-key ediff-meta-buffer-map "\C-h" 'ediff-previous-meta-item)) | |
304 (if ediff-emacs-p | |
305 (define-key ediff-meta-buffer-map [mouse-2] ediff-meta-action-function) | |
306 (define-key ediff-meta-buffer-map [button2] ediff-meta-action-function)) | |
307 | |
16766
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
308 (use-local-map ediff-meta-buffer-map) |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
309 ;; modify ediff-meta-buffer-map here |
beb94a5271e2
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
16248
diff
changeset
|
310 (run-hooks 'ediff-meta-buffer-keymap-setup-hook)) |
13130 | 311 |
312 (defun ediff-meta-mode () | |
313 "This mode controls all operations on Ediff session groups. | |
314 It is entered through one of the following commands: | |
315 `ediff-directories' | |
316 `edirs' | |
317 `ediff-directories3' | |
318 `edirs3' | |
319 `ediff-merge-directories' | |
320 `edirs-merge' | |
321 `ediff-merge-directories-with-ancestor' | |
322 `edirs-merge-with-ancestor' | |
323 `ediff-directory-revisions' | |
324 `edir-revisions' | |
325 `ediff-merge-directory-revisions' | |
326 `edir-merge-revisions' | |
327 `ediff-merge-directory-revisions-with-ancestor' | |
328 `edir-merge-revisions-with-ancestor' | |
329 | |
330 Commands: | |
331 \\{ediff-meta-buffer-map}" | |
332 (kill-all-local-variables) | |
333 (setq major-mode 'ediff-meta-mode) | |
334 (setq mode-name "MetaEdiff")) | |
335 | |
336 | |
337 ;; the keymap for the buffer showing directory differences | |
338 (suppress-keymap ediff-dir-diffs-buffer-map) | |
339 (define-key ediff-dir-diffs-buffer-map "q" 'ediff-bury-dir-diffs-buffer) | |
340 (define-key ediff-dir-diffs-buffer-map " " 'next-line) | |
20206 | 341 (define-key ediff-dir-diffs-buffer-map "n" 'next-line) |
13130 | 342 (define-key ediff-dir-diffs-buffer-map "\C-?" 'previous-line) |
20206 | 343 (define-key ediff-dir-diffs-buffer-map "p" 'previous-line) |
13130 | 344 (define-key ediff-dir-diffs-buffer-map [delete] 'previous-line) |
345 (define-key ediff-dir-diffs-buffer-map [backspace] 'previous-line) | |
346 | |
347 (defun ediff-next-meta-item (count) | |
348 "Move to the next item in Ediff registry or session group buffer. | |
349 Moves in circular fashion. With numeric prefix arg, skip this many items." | |
350 (interactive "p") | |
351 (or count (setq count 1)) | |
20206 | 352 (let (overl) |
353 (while (< 0 count) | |
354 (setq count (1- count)) | |
355 (ediff-next-meta-item1) | |
356 (setq overl (ediff-get-meta-overlay-at-pos (point))) | |
357 ;; skip invisible ones | |
358 (while (and overl (ediff-overlay-get overl 'invisible)) | |
359 (ediff-next-meta-item1) | |
360 (setq overl (ediff-get-meta-overlay-at-pos (point))))))) | |
13130 | 361 |
362 ;; Move to the next meta item | |
363 (defun ediff-next-meta-item1 () | |
364 (let (pos) | |
365 (setq pos (ediff-next-meta-overlay-start (point))) | |
366 (if pos (goto-char pos)) | |
367 (if (eq ediff-metajob-name 'ediff-registry) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
368 (if (and (ediff-get-meta-info (current-buffer) pos 'noerror) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
369 (search-forward "*Ediff" nil t)) |
13130 | 370 (skip-chars-backward "a-zA-Z*")) |
371 (if (> (skip-chars-forward "-+?H* \t0-9") 0) | |
372 (backward-char 1))))) | |
373 | |
374 | |
375 (defun ediff-previous-meta-item (count) | |
376 "Move to the previous item in Ediff registry or session group buffer. | |
377 Moves in circular fashion. With numeric prefix arg, skip this many items." | |
378 (interactive "p") | |
379 (or count (setq count 1)) | |
20206 | 380 (let (overl) |
381 (while (< 0 count) | |
382 (setq count (1- count)) | |
383 (ediff-previous-meta-item1) | |
384 (setq overl (ediff-get-meta-overlay-at-pos (point))) | |
385 ;; skip invisible ones | |
386 (while (and overl (ediff-overlay-get overl 'invisible)) | |
387 (ediff-previous-meta-item1) | |
388 (setq overl (ediff-get-meta-overlay-at-pos (point))))))) | |
13130 | 389 |
390 (defun ediff-previous-meta-item1 () | |
391 (let (pos) | |
392 (setq pos (ediff-previous-meta-overlay-start (point))) | |
393 ;;; ;; skip deleted | |
394 ;;; (while (ediff-get-session-status | |
395 ;;; (ediff-get-meta-info (current-buffer) pos 'noerror)) | |
396 ;;; (setq pos (ediff-previous-meta-overlay-start pos))) | |
397 | |
398 (if pos (goto-char pos)) | |
399 (if (eq ediff-metajob-name 'ediff-registry) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
400 (if (and (ediff-get-meta-info (current-buffer) pos 'noerror) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
401 (search-forward "*Ediff" nil t)) |
13130 | 402 (skip-chars-backward "a-zA-Z*")) |
403 (if (> (skip-chars-forward "-+?H* \t0-9") 0) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
404 (backward-char 1))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
405 )) |
13130 | 406 |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
407 (defsubst ediff-add-slash-if-directory (dir file) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
408 (if (file-directory-p (concat dir file)) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
409 (file-name-as-directory file) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
410 file)) |
13130 | 411 |
20206 | 412 (defun ediff-toggle-filename-truncation () |
413 "Toggle truncation of long file names in session group buffers. | |
414 Set `ediff-meta-truncate-filenames' variable if you want to change the default | |
415 behavior." | |
416 (interactive) | |
417 (setq ediff-meta-truncate-filenames (not ediff-meta-truncate-filenames)) | |
418 (ediff-update-meta-buffer (current-buffer) 'must-redraw)) | |
419 | |
13130 | 420 |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
421 ;; DIR1, DIR2, DIR3 are directories. DIR3 can be nil. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
422 ;; OUTPUT-DIR is a directory for auto-storing the results of merge jobs. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
423 ;; Can be nil. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
424 ;; REGEXP is a regexp used to filter out files in the directories. |
13130 | 425 ;; If a file is a directory in dir1 but not dir2 (or vice versa), it is not |
426 ;; included in the intersection. However, a regular file that is a dir in dir3 | |
427 ;; is included, since dir3 files are supposed to be ancestors for merging. | |
428 ;; Returns a list of the form: | |
429 ;; ((dir1 dir2 dir3) (f1 f2 f3) (f1 f2 f3) ...) | |
430 ;; dir3, f3 can be nil if intersecting only 2 directories. | |
431 ;; If COMPARISON-FUNC is given, use it. Otherwise, use string= | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
432 ;; DIFF-VAR contains the name of the variable in which to return the |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
433 ;; difference list (which represents the differences among the contents of |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
434 ;; directories). The diff list is of the form: |
13130 | 435 ;; ((dir1 dir2 dir3) (file . num) (file . num)...) |
436 ;; where num encodes the set of dirs where the file is found: | |
437 ;; 2 - only dir1; 3 - only dir2; 5 - only dir3; 6 - dir1&2; 10 - dir1&3; etc. | |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
438 (defun ediff-intersect-directories (jobname |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
439 diff-var regexp dir1 dir2 |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
440 &optional |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
441 dir3 merge-autostore-dir comparison-func) |
13130 | 442 (setq comparison-func (or comparison-func 'string=)) |
443 (let (lis1 lis2 lis3 common auxdir1 auxdir2 auxdir3 difflist) | |
444 | |
445 (setq auxdir1 (file-name-as-directory dir1) | |
446 lis1 (directory-files auxdir1 nil regexp) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
447 lis1 (delete "." lis1) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
448 lis1 (delete ".." lis1) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
449 lis1 (mapcar |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
450 (function |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
451 (lambda (elt) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
452 (ediff-add-slash-if-directory auxdir1 elt))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
453 lis1) |
13130 | 454 auxdir2 (file-name-as-directory dir2) |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
455 lis2 (mapcar |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
456 (function |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
457 (lambda (elt) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
458 (ediff-add-slash-if-directory auxdir2 elt))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
459 (directory-files auxdir2 nil regexp))) |
13130 | 460 |
461 (if (stringp dir3) | |
462 (setq auxdir3 (file-name-as-directory dir3) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
463 lis3 (mapcar |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
464 (function |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
465 (lambda (elt) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
466 (ediff-add-slash-if-directory auxdir3 elt))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
467 (directory-files auxdir3 nil regexp)))) |
13130 | 468 |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
469 (if (stringp merge-autostore-dir) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
470 (setq merge-autostore-dir |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
471 (file-name-as-directory merge-autostore-dir))) |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
472 (setq common (ediff-intersection lis1 lis2 comparison-func)) |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
473 |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
474 ;; In merge with ancestor jobs, we don't intersect with lis3. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
475 ;; If there is no ancestor, we'll offer to merge without the ancestor. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
476 ;; So, we intersect with lis3 only when we are doing 3-way file comparison |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
477 (if (and lis3 (ediff-comparison-metajob3 jobname)) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
478 (setq common (ediff-intersection common lis3 comparison-func))) |
13130 | 479 |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
480 ;; copying is needed because sort sorts via side effects |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
481 (setq common (sort (ediff-copy-list common) 'string-lessp)) |
13130 | 482 |
483 ;; compute difference list | |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
484 (setq difflist (ediff-set-difference |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
485 (ediff-union (ediff-union lis1 lis2 comparison-func) |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
486 lis3 |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
487 comparison-func) |
13130 | 488 common |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
489 comparison-func) |
13130 | 490 difflist (delete "." difflist) |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
491 ;; copying is needed because sort sorts via side effects |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
492 difflist (sort (ediff-copy-list (delete ".." difflist)) |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
493 'string-lessp)) |
13130 | 494 |
495 (setq difflist (mapcar (function (lambda (elt) (cons elt 1))) difflist)) | |
496 | |
497 ;; check for files belonging to lis1/2/3 | |
498 (mapcar (function (lambda (elt) | |
499 (if (member (car elt) lis1) | |
500 (setcdr elt (* (cdr elt) 2))) | |
501 (if (member (car elt) lis2) | |
502 (setcdr elt (* (cdr elt) 3))) | |
503 (if (member (car elt) lis3) | |
504 (setcdr elt (* (cdr elt) 5))) | |
505 )) | |
506 difflist) | |
507 (setq difflist (cons (list regexp auxdir1 auxdir2 auxdir3) difflist)) | |
508 | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
509 ;; return the difference list back to the calling function |
13130 | 510 (set diff-var difflist) |
511 | |
512 ;; return result | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
513 (cons (list regexp auxdir1 auxdir2 auxdir3 merge-autostore-dir) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
514 (mapcar |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
515 (function |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
516 (lambda (elt) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
517 (list (concat auxdir1 elt) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
518 (concat auxdir2 elt) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
519 (if lis3 |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
520 (progn |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
521 ;; The following is done because: |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
522 ;; In merging with ancestor, we don't intersect |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
523 ;; with lis3. So, it is possible that elt is a |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
524 ;; file in auxdir1/2 but a directory in auxdir3 |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
525 ;; Or elt may not exist in auxdir3 at all. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
526 ;; In the first case, we add a slash at the end. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
527 ;; In the second case, we insert nil. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
528 (setq elt (ediff-add-slash-if-directory auxdir3 elt)) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
529 (if (file-exists-p (concat auxdir3 elt)) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
530 (concat auxdir3 elt))))))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
531 common)) |
13130 | 532 )) |
533 | |
20206 | 534 ;; find directory files that are under revision. Include subdirectories, since |
535 ;; we may visit them recursively. DIR1 is the directory to inspect. | |
536 ;; MERGE-AUTOSTORE-DIR is the directory where to auto-store the results of | |
537 ;; merges. Can be nil. | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
538 (defun ediff-get-directory-files-under-revision (jobname |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
539 regexp dir1 |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
540 &optional merge-autostore-dir) |
13130 | 541 (let (lis1 elt common auxdir1) |
542 (setq auxdir1 (file-name-as-directory dir1) | |
543 lis1 (directory-files auxdir1 nil regexp)) | |
544 | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
545 (if (stringp merge-autostore-dir) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
546 (setq merge-autostore-dir |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
547 (file-name-as-directory merge-autostore-dir))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
548 |
13130 | 549 (while lis1 |
550 (setq elt (car lis1) | |
551 lis1 (cdr lis1)) | |
552 ;; take files under revision control | |
553 (cond ((file-directory-p (concat auxdir1 elt)) | |
20206 | 554 (setq common |
555 (cons (ediff-add-slash-if-directory auxdir1 elt) common))) | |
13130 | 556 ((file-exists-p (concat auxdir1 elt ",v")) |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
557 (setq common (cons elt common))) |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
558 ((file-exists-p (concat auxdir1 "RCS/" elt ",v")) |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
559 (setq common (cons elt common))) |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
560 ) ; cond |
13130 | 561 ) ; while |
562 | |
20206 | 563 (setq common (delete "./" common) |
564 common (delete "../" common) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
565 common (delete "RCS" common)) |
13130 | 566 |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
567 ;; copying is needed because sort sorts via side effects |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
568 (setq common (sort (ediff-copy-list common) 'string-lessp)) |
13130 | 569 |
570 ;; return result | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
571 (cons (list regexp auxdir1 nil nil merge-autostore-dir) |
13130 | 572 (mapcar (function (lambda (elt) |
573 (list (concat auxdir1 elt) | |
574 nil nil))) | |
575 common)) | |
576 )) | |
577 | |
578 | |
579 ;; If file groups selected by patterns will ever be implemented, this | |
580 ;; comparison function might become useful. | |
581 ;;;; uses external variables PAT1 PAT2 to compare str1/2 | |
582 ;;;; patterns must be of the form ???*???? where ??? are strings of chars | |
583 ;;;; containing no *. | |
584 ;;(defun ediff-pattern= (str1 str2) | |
585 ;; (let (pos11 pos12 pos21 pos22 len1 len2) | |
586 ;; (setq pos11 0 | |
587 ;; len (length epat1) | |
588 ;; pos12 len) | |
589 ;; (while (and (< pos11 len) (not (= (aref epat1 pos11) ?*))) | |
590 ;; (setq pos11 (1+ pos11))) | |
591 ;; (while (and (> pos12 0) (not (= (aref epat1 (1- pos12)) ?*))) | |
592 ;; (setq pos12 (1- pos12))) | |
593 ;; | |
594 ;; (setq pos21 0 | |
595 ;; len (length epat2) | |
596 ;; pos22 len) | |
597 ;; (while (and (< pos21 len) (not (= (aref epat2 pos21) ?*))) | |
598 ;; (setq pos21 (1+ pos21))) | |
599 ;; (while (and (> pos22 0) (not (= (aref epat2 (1- pos22)) ?*))) | |
600 ;; (setq pos22 (1- pos22))) | |
601 ;; | |
602 ;; (if (and (> (length str1) pos12) (>= pos12 pos11) (> pos11 -1) | |
603 ;; (> (length str2) pos22) (>= pos22 pos21) (> pos21 -1)) | |
604 ;; (string= (substring str1 pos11 pos12) | |
605 ;; (substring str2 pos21 pos22))) | |
606 ;; )) | |
607 | |
608 | |
609 ;; Prepare meta-buffer in accordance with the argument-function and | |
610 ;; redraw-function. Must return the created meta-buffer. | |
611 (defun ediff-prepare-meta-buffer (action-func meta-list | |
612 meta-buffer-name redraw-function | |
613 jobname &optional startup-hooks) | |
614 (let* ((meta-buffer-name | |
615 (ediff-unique-buffer-name meta-buffer-name "*")) | |
616 (meta-buffer (get-buffer-create meta-buffer-name))) | |
19047 | 617 (ediff-with-current-buffer meta-buffer |
13130 | 618 |
619 ;; comes first | |
620 (ediff-meta-mode) | |
621 | |
622 (setq ediff-meta-action-function action-func | |
623 ediff-meta-redraw-function redraw-function | |
624 ediff-metajob-name jobname | |
625 ediff-meta-buffer meta-buffer) | |
626 | |
627 ;; comes after ediff-meta-action-function is set | |
628 (ediff-setup-meta-map) | |
629 | |
630 (if (eq ediff-metajob-name 'ediff-registry) | |
631 (progn | |
632 (setq ediff-registry-buffer meta-buffer | |
633 ediff-meta-list meta-list) | |
634 ;; this func is used only from registry buffer, not from other | |
635 ;; meta-buffs. | |
636 (define-key | |
637 ediff-meta-buffer-map "M" 'ediff-show-meta-buff-from-registry)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
638 ;; Initialize the meta list -- don't do this for registry. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
639 ;; |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
640 ;; We prepend '(nil nil) to all elts of meta-list, except the first. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
641 ;; The first nil will later be replaced by the session buffer. The |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
642 ;; second is reserved for session status. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
643 ;; |
13130 | 644 ;; (car ediff-meta-list) gets cons'ed with the session group buffer. |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
645 ;; Also, session objects A/B/C are turned into lists of the form |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
646 ;; (obj eq-indicator). Eq-indicator is either nil or =. Initialized to |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
647 ;; nil. If later it is discovered that this file is = to some other |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
648 ;; file in the same session, eq-indicator is changed to `='. |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
649 ;; For now, the eq-indicator is used only for 2 and 3-file jobs. |
13130 | 650 (setq ediff-meta-list |
651 (cons (cons meta-buffer (car meta-list)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
652 (mapcar |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
653 (function |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
654 (lambda (elt) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
655 (cons nil |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
656 (cons nil |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
657 ;; convert each obj to (obj nil), |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
658 ;; where nil is the initial value |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
659 ;; for eq-indicator -- see above |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
660 (mapcar |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
661 (function (lambda (obj) (list obj nil))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
662 elt))))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
663 (cdr meta-list))))) |
13130 | 664 |
665 (or (eq meta-buffer ediff-registry-buffer) | |
666 (setq ediff-session-registry | |
667 (cons meta-buffer ediff-session-registry))) | |
668 | |
669 ;; redraw-function uses ediff-meta-list | |
670 (funcall redraw-function ediff-meta-list) | |
671 | |
672 ;; set read-only/non-modified | |
673 (setq buffer-read-only t) | |
674 (set-buffer-modified-p nil) | |
675 | |
676 (run-hooks 'startup-hooks) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
677 |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
678 ;; Arrange to show directory contents differences |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
679 ;; Must be after run startup-hooks, since ediff-dir-difference-list is |
13130 | 680 ;; set inside these hooks |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
681 (if (eq action-func 'ediff-filegroup-action) |
13130 | 682 (progn |
683 ;; put meta buffer in (car ediff-dir-difference-list) | |
684 (setq ediff-dir-difference-list | |
685 (cons (cons meta-buffer (car ediff-dir-difference-list)) | |
686 (cdr ediff-dir-difference-list))) | |
687 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
688 (or (ediff-one-filegroup-metajob jobname) |
13130 | 689 (ediff-draw-dir-diffs ediff-dir-difference-list)) |
22286 | 690 (define-key |
691 ediff-meta-buffer-map "h" 'ediff-mark-for-hiding-at-pos) | |
692 (define-key ediff-meta-buffer-map "x" 'ediff-hide-marked-sessions) | |
693 (define-key | |
694 ediff-meta-buffer-map "m" 'ediff-mark-for-operation-at-pos) | |
695 (define-key ediff-meta-buffer-map "u" nil) | |
13130 | 696 (define-key |
22286 | 697 ediff-meta-buffer-map "um" 'ediff-unmark-all-for-operation) |
698 (define-key | |
699 ediff-meta-buffer-map "uh" 'ediff-unmark-all-for-hiding) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
700 (cond ((ediff-collect-diffs-metajob jobname) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
701 (define-key |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
702 ediff-meta-buffer-map "P" 'ediff-collect-custom-diffs)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
703 ((ediff-patch-metajob jobname) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
704 (define-key |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
705 ediff-meta-buffer-map "P" 'ediff-meta-show-patch))) |
22286 | 706 (define-key ediff-meta-buffer-map "^" 'ediff-up-meta-hierarchy) |
13130 | 707 (define-key ediff-meta-buffer-map "D" 'ediff-show-dir-diffs))) |
708 | |
709 (if (eq ediff-metajob-name 'ediff-registry) | |
710 (run-hooks 'ediff-registry-setup-hook) | |
711 (run-hooks 'ediff-session-group-setup-hook)) | |
712 ) ; eval in meta-buffer | |
713 meta-buffer)) | |
714 | |
20206 | 715 ;; Insert the activity marker for session SESSION in the meta buffer at point |
716 ;; The activity marker is either SPC (untouched session), or + (active session, | |
717 ;; i.e., ediff is currently run in it), or - (finished session, i.e., we've ran | |
718 ;; ediff in it and then exited) | |
719 (defun ediff-insert-session-activity-marker-in-meta-buffer (session) | |
720 (insert | |
721 (cond ((ediff-get-session-activity-marker session)) | |
722 ;; virgin session | |
723 (t " ")))) | |
724 | |
725 ;; Insert session status at point. Status is either ?H (marked for hiding), or | |
726 ;; ?I (hidden or invalid), or ?* (meaning marked for an operation; currently, | |
727 ;; such op can only be checking for equality)), or SPC (meaning neither marked | |
728 ;; nor invalid) | |
729 (defun ediff-insert-session-status-in-meta-buffer (session) | |
730 (insert | |
731 (cond ((ediff-get-session-status session)) ; session has status: ?H, ?I, ?* | |
732 ;; normal session, no marks or hidings | |
733 (t " ")))) | |
734 | |
735 ;; If NEW-MARKER is non-nil, use it to substitute the current activity marker | |
736 ;; in the meta buffer. If nil, use SPC | |
737 (defun ediff-replace-session-activity-marker-in-meta-buffer (point new-marker) | |
738 (let* ((overl (ediff-get-meta-overlay-at-pos point)) | |
739 (session-info (ediff-overlay-get overl 'ediff-meta-info)) | |
740 (activity-marker (ediff-get-session-activity-marker session-info)) | |
741 buffer-read-only) | |
742 (or new-marker activity-marker (setq new-marker ?\ )) | |
743 (goto-char (ediff-overlay-start overl)) | |
744 (if (eq (char-after (point)) new-marker) | |
745 () ; if marker shown in buffer is the same as new-marker, do nothing | |
746 (insert new-marker) | |
747 (delete-char 1) | |
748 (set-buffer-modified-p nil)))) | |
749 | |
750 ;; If NEW-STATUS is non-nil, use it to substitute the current status marker in | |
751 ;; the meta buffer. If nil, use SPC | |
752 (defun ediff-replace-session-status-in-meta-buffer (point new-status) | |
753 (let* ((overl (ediff-get-meta-overlay-at-pos point)) | |
754 (session-info (ediff-overlay-get overl 'ediff-meta-info)) | |
755 (status (ediff-get-session-status session-info)) | |
756 buffer-read-only) | |
757 (setq new-status (or new-status status ?\ )) | |
758 (goto-char (ediff-overlay-start overl)) | |
759 (forward-char 1) ; status is the second char in session record | |
760 (if (eq (char-after (point)) new-status) | |
761 () ; if marker shown in buffer is the same as new-marker, do nothing | |
762 (insert new-status) | |
763 (delete-char 1) | |
764 (set-buffer-modified-p nil)))) | |
765 | |
766 ;; insert all file info in meta buffer for a given session | |
767 (defun ediff-insert-session-info-in-meta-buffer (session-info sessionNum) | |
768 (let ((f1 (ediff-get-session-objA session-info)) | |
769 (f2 (ediff-get-session-objB session-info)) | |
770 (f3 (ediff-get-session-objC session-info)) | |
771 (pt (point)) | |
772 (hidden (eq (ediff-get-session-status session-info) ?I))) | |
773 ;; insert activity marker, i.e., SPC, - or + | |
774 (ediff-insert-session-activity-marker-in-meta-buffer session-info) | |
775 ;; insert session status, i.e., *, H | |
776 (ediff-insert-session-status-in-meta-buffer session-info) | |
777 (insert " Session " (int-to-string sessionNum) ":\n") | |
778 (ediff-meta-insert-file-info1 f1) | |
779 (ediff-meta-insert-file-info1 f2) | |
780 (ediff-meta-insert-file-info1 f3) | |
781 (ediff-set-meta-overlay pt (point) session-info sessionNum hidden))) | |
782 | |
13130 | 783 |
784 ;; this is a setup function for ediff-directories | |
785 ;; must return meta-buffer | |
786 (defun ediff-redraw-directory-group-buffer (meta-list) | |
787 ;; extract directories | |
788 (let ((meta-buf (ediff-get-group-buffer meta-list)) | |
789 (empty t) | |
790 (sessionNum 0) | |
20206 | 791 regexp elt merge-autostore-dir |
13130 | 792 point tmp-list buffer-read-only) |
19047 | 793 (ediff-with-current-buffer meta-buf |
13130 | 794 (setq point (point)) |
795 (erase-buffer) | |
20206 | 796 ;; delete phony overlays that used to represent sessions before the buff |
797 ;; was redrawn | |
798 (if ediff-emacs-p | |
799 (mapcar 'delete-overlay (overlays-in 1 1)) | |
800 (map-extents 'delete-extent)) | |
801 | |
13130 | 802 (insert (format ediff-meta-buffer-message |
803 (ediff-abbrev-jobname ediff-metajob-name))) | |
804 | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
805 (setq regexp (ediff-get-group-regexp meta-list) |
20206 | 806 merge-autostore-dir |
807 (ediff-get-group-merge-autostore-dir meta-list)) | |
13130 | 808 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
809 (cond ((ediff-collect-diffs-metajob) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
810 (insert |
20206 | 811 " P:\tcollect custom diffs of all marked sessions\n")) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
812 ((ediff-patch-metajob) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
813 (insert |
20206 | 814 " P:\tshow patch appropriately for the context (session or group)\n"))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
815 (insert |
22286 | 816 " ^:\tshow parent session group\n") |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
817 (or (ediff-one-filegroup-metajob) |
13130 | 818 (insert |
20206 | 819 " D:\tshow differences among directories\n" |
22286 | 820 " ==:\tfor each session, show which files are identical\n" |
821 " =h:\tlike ==, but also marks those sessions for hiding\n" | |
822 " =m:\tlike ==, but also marks those sessions for operation\n\n")) | |
13130 | 823 |
20206 | 824 (insert "\n") |
13130 | 825 (if (and (stringp regexp) (> (length regexp) 0)) |
18054 | 826 (insert |
20206 | 827 (format "*** Filter-through regular expression: %s\n" regexp))) |
828 (ediff-insert-dirs-in-meta-buffer meta-list) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
829 (if (and ediff-autostore-merges (ediff-merge-metajob) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
830 (stringp merge-autostore-dir)) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
831 (insert (format |
20206 | 832 "\nMerge results are automatically stored in:\n\t%s\n" |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
833 merge-autostore-dir))) |
13130 | 834 (insert "\n |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
835 Size Last modified Name |
20206 | 836 ---------------------------------------------- |
13130 | 837 |
838 ") | |
839 | |
840 ;; discard info on directories and regexp | |
841 (setq meta-list (cdr meta-list) | |
842 tmp-list meta-list) | |
843 (while (and tmp-list empty) | |
844 (if (and (car tmp-list) | |
845 (not (eq (ediff-get-session-status (car tmp-list)) ?I))) | |
846 (setq empty nil)) | |
847 (setq tmp-list (cdr tmp-list))) | |
848 | |
849 (if empty | |
850 (insert | |
851 " ****** ****** This session group has no members\n")) | |
852 | |
853 ;; now organize file names like this: | |
854 ;; use-mark sizeA dateA sizeB dateB filename | |
855 ;; make sure directories are displayed with a trailing slash. | |
856 (while meta-list | |
857 (setq elt (car meta-list) | |
858 meta-list (cdr meta-list) | |
859 sessionNum (1+ sessionNum)) | |
860 (if (eq (ediff-get-session-status elt) ?I) | |
861 () | |
20206 | 862 (ediff-insert-session-info-in-meta-buffer elt sessionNum))) |
13130 | 863 (set-buffer-modified-p nil) |
864 (goto-char point) | |
865 meta-buf))) | |
866 | |
20206 | 867 (defun ediff-update-markers-in-dir-meta-buffer (meta-list) |
868 (let ((meta-buf (ediff-get-group-buffer meta-list)) | |
869 session-info point overl buffer-read-only) | |
870 (ediff-with-current-buffer meta-buf | |
871 (setq point (point)) | |
872 (goto-char (point-min)) | |
873 (ediff-next-meta-item1) | |
874 (while (not (bobp)) | |
875 (setq session-info (ediff-get-meta-info meta-buf (point) 'no-error) | |
876 overl (ediff-get-meta-overlay-at-pos (point))) | |
877 (if session-info | |
878 (progn | |
879 (cond ((eq (ediff-get-session-status session-info) ?I) | |
880 ;; Do hiding | |
881 (if overl (ediff-overlay-put overl 'invisible t))) | |
882 ((and (eq (ediff-get-session-status session-info) ?H) | |
883 overl (ediff-overlay-get overl 'invisible)) | |
884 ;; Do unhiding | |
885 (ediff-overlay-put overl 'invisible nil)) | |
886 (t (ediff-replace-session-activity-marker-in-meta-buffer | |
887 (point) | |
888 (ediff-get-session-activity-marker session-info)) | |
889 (ediff-replace-session-status-in-meta-buffer | |
890 (point) | |
891 (ediff-get-session-status session-info)))))) | |
892 (ediff-next-meta-item1) ; advance to the next item | |
893 ) ; end while | |
894 (set-buffer-modified-p nil) | |
895 (goto-char point)) | |
896 meta-buf)) | |
897 | |
898 (defun ediff-update-session-marker-in-dir-meta-buffer (session-num) | |
899 (let (buffer-meta-overlays session-info overl buffer-read-only) | |
900 (setq overl | |
901 (if ediff-xemacs-p | |
902 (map-extents | |
903 (function | |
904 (lambda (ext maparg) | |
905 (if (and | |
906 (ediff-overlay-get ext 'ediff-meta-info) | |
907 (eq (ediff-overlay-get ext 'ediff-meta-session-number) | |
908 session-num)) | |
909 ext)))) | |
910 ;; Emacs doesn't have map-extents, so try harder | |
911 ;; Splice overlay lists to get all buffer overlays | |
912 (setq buffer-meta-overlays (overlay-lists) | |
913 buffer-meta-overlays (append (car buffer-meta-overlays) | |
914 (cdr buffer-meta-overlays))) | |
915 (car | |
916 (delq nil | |
917 (mapcar | |
918 (function | |
919 (lambda (overl) | |
920 (if (and | |
921 (ediff-overlay-get overl 'ediff-meta-info) | |
922 (eq (ediff-overlay-get | |
923 overl 'ediff-meta-session-number) | |
924 session-num)) | |
925 overl))) | |
926 buffer-meta-overlays))))) | |
927 (or overl | |
928 (error | |
929 "Bug in ediff-update-session-marker-in-dir-meta-buffer: no overlay with given number %S" | |
930 session-num)) | |
931 (setq session-info (ediff-overlay-get overl 'ediff-meta-info)) | |
932 (goto-char (ediff-overlay-start overl)) | |
933 (ediff-replace-session-activity-marker-in-meta-buffer | |
934 (point) | |
935 (ediff-get-session-activity-marker session-info)) | |
936 (ediff-replace-session-status-in-meta-buffer | |
937 (point) | |
938 (ediff-get-session-status session-info))) | |
939 (ediff-next-meta-item1)) | |
940 | |
941 | |
942 | |
13130 | 943 ;; Check if this is a problematic session. |
944 ;; Return nil if not. Otherwise, return symbol representing the problem | |
945 ;; At present, problematic sessions occur only in -with-ancestor comparisons | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
946 ;; when the ancestor is a directory rather than a file, or when there is no |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
947 ;; suitable ancestor file in the ancestor directory |
13130 | 948 (defun ediff-problematic-session-p (session) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
949 (let ((f1 (ediff-get-session-objA-name session)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
950 (f2 (ediff-get-session-objB-name session)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
951 (f3 (ediff-get-session-objC-name session))) |
13130 | 952 (cond ((and (stringp f1) (not (file-directory-p f1)) |
953 (stringp f2) (not (file-directory-p f2)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
954 ;; either invalid file name or a directory |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
955 (or (not (stringp f3)) (file-directory-p f3)) |
13130 | 956 (ediff-ancestor-metajob)) |
957 ;; more may be added later | |
958 'ancestor-is-dir) | |
959 (t nil)))) | |
960 | |
20206 | 961 (defun ediff-meta-insert-file-info1 (fileinfo) |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
962 (let ((fname (car fileinfo)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
963 (feq (ediff-get-file-eqstatus fileinfo)) |
20206 | 964 (max-filename-width (if ediff-meta-truncate-filenames |
965 (- (window-width) 41) | |
966 500)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
967 file-modtime file-size) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
968 (cond ((not (stringp fname)) (setq file-size -2)) ; file doesn't exits |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
969 ((not (ediff-file-remote-p fname)) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
970 (if (file-exists-p fname) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
971 ;; set real size and modtime |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
972 (setq file-size (ediff-file-size fname) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
973 file-modtime (ediff-file-modtime fname)) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
974 (setq file-size -2))) ; file doesn't exist |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
975 ( t (setq file-size -1))) ; remote file |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
976 (if (stringp fname) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
977 (insert |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
978 (format |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
979 "%s %s %-20s %s\n" |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
980 (if feq "=" " ") ; equality indicator |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
981 (format "%10s" (cond ((= file-size -1) "--") |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
982 ((< file-size -1) "--") |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
983 (t file-size))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
984 (cond ((= file-size -1) "*remote file*") |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
985 ((< file-size -1) "*file doesn't exist*") |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
986 (t (ediff-format-date (decode-time file-modtime)))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
987 |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
988 ;; dir names in meta lists have training slashes, so we just |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
989 ;; abbreviate the file name, if file exists |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
990 (if (and (not (stringp fname)) (< file-size -1)) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
991 "-------" ; file doesn't exist |
20206 | 992 (ediff-truncate-string-left |
993 (ediff-abbreviate-file-name fname) | |
994 max-filename-width))))))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
995 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
996 (defconst ediff-months '((1 . "Jan") (2 . "Feb") (3 . "Mar") (4 . "Apr") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
997 (5 . "May") (6 . "Jun") (7 . "Jul") (8 . "Aug") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
998 (9 . "Sep") (10 . "Oct") (11 . "Nov") (12 . "Dec")) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
999 "Months' associative array.") |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1000 |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1001 ;; returns 2char string |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1002 (defsubst ediff-fill-leading-zero (num) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1003 (if (< num 10) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1004 (format "0%d" num) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1005 (number-to-string num))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1006 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1007 ;; TIME is like the output of decode-time |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1008 (defun ediff-format-date (time) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1009 (format "%s %2d %4d %s:%s:%s" |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1010 (cdr (assoc (nth 4 time) ediff-months)) ; month |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1011 (nth 3 time) ; day |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1012 (nth 5 time) ; year |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1013 (ediff-fill-leading-zero (nth 2 time)) ; hour |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1014 (ediff-fill-leading-zero (nth 1 time)) ; min |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1015 (ediff-fill-leading-zero (nth 0 time)) ; sec |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1016 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1017 |
20206 | 1018 ;; Draw the directories |
1019 (defun ediff-insert-dirs-in-meta-buffer (meta-list) | |
1020 (let* ((dir1 (ediff-abbreviate-file-name (ediff-get-group-objA meta-list))) | |
1021 (dir2 (ediff-get-group-objB meta-list)) | |
1022 (dir2 (if (stringp dir2) (ediff-abbreviate-file-name dir2))) | |
1023 (dir3 (ediff-get-group-objC meta-list)) | |
1024 (dir3 (if (stringp dir3) (ediff-abbreviate-file-name dir3)))) | |
1025 (insert "*** Directory A: " dir1 "\n") | |
1026 (if dir2 (insert "*** Directory B: " dir2 "\n")) | |
1027 (if dir3 (insert "*** Directory C: " dir3 "\n")) | |
1028 (insert "\n"))) | |
1029 | |
13130 | 1030 (defun ediff-draw-dir-diffs (diff-list) |
1031 (if (null diff-list) (error "Lost difference info on these directories")) | |
1032 (let* ((buf-name (ediff-unique-buffer-name | |
1033 "*Ediff File Group Differences" "*")) | |
1034 (regexp (ediff-get-group-regexp diff-list)) | |
1035 (dir1 (ediff-abbreviate-file-name (ediff-get-group-objA diff-list))) | |
1036 (dir2 (ediff-abbreviate-file-name (ediff-get-group-objB diff-list))) | |
1037 (dir3 (ediff-get-group-objC diff-list)) | |
1038 (dir3 (if (stringp dir3) (ediff-abbreviate-file-name dir3))) | |
1039 (meta-buf (ediff-get-group-buffer diff-list)) | |
1040 (underline (make-string 26 ?-)) | |
1041 file code | |
1042 buffer-read-only) | |
1043 ;; skip the directory part | |
1044 (setq diff-list (cdr diff-list)) | |
1045 (setq ediff-dir-diffs-buffer (get-buffer-create buf-name)) | |
19047 | 1046 (ediff-with-current-buffer ediff-dir-diffs-buffer |
13130 | 1047 (use-local-map ediff-dir-diffs-buffer-map) |
1048 (erase-buffer) | |
1049 (setq ediff-meta-buffer meta-buf) | |
1050 (insert "\t\t*** Directory Differences ***\n") | |
1051 (insert " | |
1052 Useful commands: | |
1053 `q': hide this buffer | |
20206 | 1054 n,SPC: next line |
1055 p,DEL: previous line\n\n") | |
13130 | 1056 |
1057 (if (and (stringp regexp) (> (length regexp) 0)) | |
18054 | 1058 (insert |
1059 (format "\n*** Filter-through regular expression: %s\n" regexp))) | |
13130 | 1060 (insert "\n") |
1061 (insert (format "\n%-27s%-26s" | |
1062 (ediff-truncate-string-left | |
1063 (ediff-abbreviate-file-name | |
1064 (file-name-as-directory dir1)) | |
1065 25) | |
1066 (ediff-truncate-string-left | |
1067 (ediff-abbreviate-file-name | |
1068 (file-name-as-directory dir2)) | |
1069 25))) | |
1070 (if dir3 | |
1071 (insert (format " %-25s\n" | |
1072 (ediff-truncate-string-left | |
1073 (ediff-abbreviate-file-name | |
1074 (file-name-as-directory dir3)) | |
1075 25))) | |
1076 (insert "\n")) | |
1077 (insert (format "%s%s" underline underline)) | |
1078 (if (stringp dir3) | |
1079 (insert (format "%s\n\n" underline)) | |
1080 (insert "\n\n")) | |
1081 | |
1082 (if (null diff-list) | |
1083 (insert "\n\t*** No differences ***\n")) | |
1084 | |
1085 (while diff-list | |
1086 (setq file (car (car diff-list)) | |
1087 code (cdr (car diff-list)) | |
1088 diff-list (cdr diff-list)) | |
1089 (if (= (mod code 2) 0) ; dir1 | |
1090 (insert (format "%-27s" | |
1091 (ediff-truncate-string-left | |
1092 (ediff-abbreviate-file-name | |
1093 (if (file-directory-p (concat dir1 file)) | |
1094 (file-name-as-directory file) | |
1095 file)) | |
1096 24))) | |
1097 (insert (format "%-27s" "---"))) | |
1098 (if (= (mod code 3) 0) ; dir2 | |
1099 (insert (format "%-26s" | |
1100 (ediff-truncate-string-left | |
1101 (ediff-abbreviate-file-name | |
1102 (if (file-directory-p (concat dir2 file)) | |
1103 (file-name-as-directory file) | |
1104 file)) | |
1105 24))) | |
1106 (insert (format "%-26s" "---"))) | |
1107 (if (stringp dir3) | |
1108 (if (= (mod code 5) 0) ; dir3 | |
1109 (insert (format " %-25s" | |
1110 (ediff-truncate-string-left | |
1111 (ediff-abbreviate-file-name | |
1112 (if (file-directory-p (concat dir3 file)) | |
1113 (file-name-as-directory file) | |
1114 file)) | |
1115 24))) | |
1116 (insert (format " %-25s" "---")))) | |
1117 (insert "\n")) | |
1118 (setq buffer-read-only t) | |
1119 (set-buffer-modified-p nil)) ; eval in diff buffer | |
1120 )) | |
1121 | |
1122 (defun ediff-bury-dir-diffs-buffer () | |
1123 "Bury the directory difference buffer. Display the meta buffer instead." | |
1124 (interactive) | |
1125 (let ((buf ediff-meta-buffer) | |
1126 wind) | |
1127 (bury-buffer) | |
1128 (if (setq wind (ediff-get-visible-buffer-window buf)) | |
1129 (select-window wind) | |
1130 (set-window-buffer (selected-window) buf)))) | |
1131 | |
1132 ;; executes in dir session group buffer | |
1133 ;; show buffer differences | |
1134 (defun ediff-show-dir-diffs () | |
1135 "Display differences among the directories involved in session group." | |
1136 (interactive) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1137 (if (ediff-one-filegroup-metajob) |
13130 | 1138 (error "This command is inapplicable in the present context")) |
1139 (or (ediff-buffer-live-p ediff-dir-diffs-buffer) | |
1140 (ediff-draw-dir-diffs ediff-dir-difference-list)) | |
1141 (let ((buf ediff-dir-diffs-buffer)) | |
1142 (other-window 1) | |
1143 (set-window-buffer (selected-window) buf) | |
1144 (goto-char (point-min)))) | |
1145 | |
1146 (defun ediff-up-meta-hierarchy () | |
1147 "Go to the parent session group buffer." | |
1148 (interactive) | |
1149 (if (ediff-buffer-live-p ediff-parent-meta-buffer) | |
20206 | 1150 (ediff-show-meta-buffer |
1151 ediff-parent-meta-buffer ediff-meta-session-number) | |
13130 | 1152 (error "This session group has no parent"))) |
1153 | |
1154 | |
1155 ;; argument is ignored | |
1156 (defun ediff-redraw-registry-buffer (&optional ignore) | |
19047 | 1157 (ediff-with-current-buffer ediff-registry-buffer |
13130 | 1158 (let ((point (point)) |
1159 elt bufAname bufBname bufCname cur-diff total-diffs pt | |
1160 job-name meta-list registry-list buffer-read-only) | |
1161 (erase-buffer) | |
20206 | 1162 ;; delete phony overlays that used to represent sessions before the buff |
1163 ;; was redrawn | |
1164 (if ediff-emacs-p | |
1165 (mapcar 'delete-overlay (overlays-in 1 1)) | |
1166 (map-extents 'delete-extent)) | |
1167 | |
13130 | 1168 (insert "This is a registry of all active Ediff sessions. |
1169 | |
1170 Useful commands: | |
1171 button2, `v', RET over a session record: switch to that session | |
20206 | 1172 M over a session record: display the associated session group |
1173 R in any Ediff session: display session registry | |
1174 n,SPC: next session | |
1175 p,DEL: previous session | |
1176 E: browse Ediff on-line manual | |
1177 q: bury registry | |
13130 | 1178 |
1179 | |
1180 \t\tActive Ediff Sessions: | |
1181 \t\t---------------------- | |
1182 | |
1183 ") | |
1184 ;; purge registry list from dead buffers | |
1185 (mapcar (function (lambda (elt) | |
1186 (if (not (ediff-buffer-live-p elt)) | |
1187 (setq ediff-session-registry | |
1188 (delq elt ediff-session-registry))))) | |
1189 ediff-session-registry) | |
1190 | |
1191 (if (null ediff-session-registry) | |
1192 (insert " ******* No active Ediff sessions *******\n")) | |
1193 | |
1194 (setq registry-list ediff-session-registry) | |
1195 (while registry-list | |
1196 (setq elt (car registry-list) | |
1197 registry-list (cdr registry-list)) | |
1198 | |
1199 (if (ediff-buffer-live-p elt) | |
19047 | 1200 (if (ediff-with-current-buffer elt |
13130 | 1201 (setq job-name ediff-metajob-name |
1202 meta-list ediff-meta-list) | |
1203 (and ediff-metajob-name | |
1204 (not (eq ediff-metajob-name 'ediff-registry)))) | |
1205 (progn | |
1206 (setq pt (point)) | |
1207 (insert (format " *group*\t%s: %s\n" | |
1208 (buffer-name elt) | |
1209 (ediff-abbrev-jobname job-name))) | |
1210 (insert (format "\t\t %s %s %s\n" | |
1211 (ediff-abbreviate-file-name | |
1212 (ediff-get-group-objA meta-list)) | |
1213 (ediff-abbreviate-file-name | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1214 (if (stringp |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1215 (ediff-get-group-objB meta-list)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1216 (ediff-get-group-objB meta-list) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1217 "")) |
13130 | 1218 (ediff-abbreviate-file-name |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1219 (if (stringp |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1220 (ediff-get-group-objC meta-list)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1221 (ediff-get-group-objC meta-list) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1222 "")))) |
13130 | 1223 (ediff-set-meta-overlay pt (point) elt)) |
1224 (progn | |
19047 | 1225 (ediff-with-current-buffer elt |
13130 | 1226 (setq bufAname (if (ediff-buffer-live-p ediff-buffer-A) |
1227 (buffer-name ediff-buffer-A) | |
1228 "!!!killed buffer!!!") | |
1229 bufBname (if (ediff-buffer-live-p ediff-buffer-B) | |
1230 (buffer-name ediff-buffer-B) | |
1231 "!!!killed buffer!!!") | |
1232 bufCname (cond ((not (ediff-3way-job)) | |
1233 "") | |
1234 ((ediff-buffer-live-p ediff-buffer-C) | |
1235 (buffer-name ediff-buffer-C)) | |
1236 (t "!!!killed buffer!!!"))) | |
1237 (setq total-diffs (format "%-4d" ediff-number-of-differences) | |
1238 cur-diff | |
1239 (cond ((= ediff-current-difference -1) " _") | |
1240 ((= ediff-current-difference | |
1241 ediff-number-of-differences) | |
1242 " $") | |
1243 (t (format | |
1244 "%4d" (1+ ediff-current-difference)))) | |
1245 job-name ediff-job-name)) | |
1246 ;; back in the meta buf | |
1247 (setq pt (point)) | |
1248 (insert cur-diff "/" total-diffs "\t" | |
1249 (buffer-name elt) | |
1250 (format ": %s" (ediff-abbrev-jobname job-name))) | |
1251 (insert | |
1252 "\n\t\t " bufAname " " bufBname " " bufCname "\n") | |
1253 (ediff-set-meta-overlay pt (point) elt)))) | |
1254 ) ; while | |
1255 (set-buffer-modified-p nil) | |
1256 (goto-char point) | |
1257 ))) | |
1258 | |
20206 | 1259 ;; Sets overlay around a meta record with 'ediff-meta-info property PROP |
1260 ;; If optional SESSION-NUMBER, make it a property of the overlay, | |
1261 ;; ediff-meta-session-number | |
1262 (defun ediff-set-meta-overlay (b e prop &optional session-number hidden) | |
13130 | 1263 (let (overl) |
1264 (setq overl (ediff-make-overlay b e)) | |
1265 (if ediff-emacs-p | |
1266 (ediff-overlay-put overl 'mouse-face 'highlight) | |
1267 (ediff-overlay-put overl 'highlight t)) | |
20206 | 1268 (ediff-overlay-put overl 'ediff-meta-info prop) |
1269 (ediff-overlay-put overl 'invisible hidden) | |
1270 (if (numberp session-number) | |
1271 (ediff-overlay-put overl 'ediff-meta-session-number session-number)))) | |
13130 | 1272 |
22286 | 1273 (defun ediff-mark-for-hiding-at-pos (unmark) |
13130 | 1274 "Mark session for hiding. With prefix arg, unmark." |
1275 (interactive "P") | |
1276 (let* ((pos (ediff-event-point last-command-event)) | |
1277 (meta-buf (ediff-event-buffer last-command-event)) | |
1278 ;; ediff-get-meta-info gives error if meta-buf or pos are invalid | |
1279 (info (ediff-get-meta-info meta-buf pos)) | |
20206 | 1280 (session-number (ediff-get-session-number-at-pos pos))) |
22286 | 1281 (ediff-mark-session-for-hiding info unmark) |
1282 (ediff-next-meta-item 1) | |
1283 (save-excursion | |
1284 (ediff-update-meta-buffer meta-buf nil session-number)) | |
13130 | 1285 )) |
1286 | |
22286 | 1287 ;; Returns whether session was marked or unmarked |
1288 (defun ediff-mark-session-for-hiding (info unmark) | |
1289 (let ((session-buf (ediff-get-session-buffer info)) | |
1290 ignore) | |
1291 (cond ((eq unmark 'mark) (setq unmark nil)) | |
1292 ((eq (ediff-get-session-status info) ?H) (setq unmark t)) | |
1293 (unmark ; says unmark, but the marker is different from H | |
1294 (setq ignore t))) | |
1295 (cond (ignore) | |
1296 (unmark (ediff-set-session-status info nil)) | |
1297 ;;; (if (ediff-buffer-live-p session-buf) | |
1298 ;;; (error "Can't hide active session, %s" (buffer-name session-buf))) | |
1299 (t (ediff-set-session-status info ?H)))) | |
1300 unmark) | |
1301 | |
1302 | |
1303 (defun ediff-mark-for-operation-at-pos (unmark) | |
13130 | 1304 "Mark session for a group operation. With prefix arg, unmark." |
1305 (interactive "P") | |
1306 (let* ((pos (ediff-event-point last-command-event)) | |
1307 (meta-buf (ediff-event-buffer last-command-event)) | |
1308 ;; ediff-get-meta-info gives error if meta-buf or pos are invalid | |
20206 | 1309 (info (ediff-get-meta-info meta-buf pos)) |
1310 (session-number (ediff-get-session-number-at-pos pos))) | |
22286 | 1311 (ediff-mark-session-for-operation info unmark) |
1312 (ediff-next-meta-item 1) | |
1313 (save-excursion | |
1314 (ediff-update-meta-buffer meta-buf nil session-number)) | |
13130 | 1315 )) |
1316 | |
22286 | 1317 |
1318 ;; returns whether session was unmarked. | |
1319 ;; remember: this is a toggle op | |
1320 (defun ediff-mark-session-for-operation (info unmark) | |
1321 (let (ignore) | |
1322 (cond ((eq unmark 'mark) (setq unmark nil)) | |
1323 ((eq (ediff-get-session-status info) ?*) (setq unmark t)) | |
1324 (unmark ; says unmark, but the marker is different from * | |
1325 (setq ignore t))) | |
1326 (cond (ignore) | |
1327 (unmark (ediff-set-session-status info nil)) | |
1328 (t (ediff-set-session-status info ?*)))) | |
1329 unmark) | |
1330 | |
1331 | |
13130 | 1332 (defun ediff-hide-marked-sessions (unhide) |
1333 "Hide marked sessions. With prefix arg, unhide." | |
1334 (interactive "P") | |
1335 (let ((grp-buf (ediff-get-group-buffer ediff-meta-list)) | |
1336 (meta-list (cdr ediff-meta-list)) | |
1337 (from (if unhide ?I ?H)) | |
1338 (to (if unhide ?H ?I)) | |
1339 (numMarked 0) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1340 active-sessions-exist session-buf elt) |
13130 | 1341 (while meta-list |
1342 (setq elt (car meta-list) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1343 meta-list (cdr meta-list) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1344 session-buf (ediff-get-session-buffer elt)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1345 |
13130 | 1346 (if (eq (ediff-get-session-status elt) from) |
1347 (progn | |
1348 (setq numMarked (1+ numMarked)) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1349 (if (and (eq to ?I) (buffer-live-p session-buf)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1350 ;; shouldn't hide active sessions |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1351 (setq active-sessions-exist t) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1352 (ediff-set-session-status elt to))))) |
13130 | 1353 (if (> numMarked 0) |
1354 (ediff-update-meta-buffer grp-buf) | |
1355 (beep) | |
1356 (if unhide | |
1357 (message "Nothing to reveal...") | |
1358 (message "Nothing to hide..."))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1359 (if active-sessions-exist |
20206 | 1360 (message "Note: Ediff didn't hide active sessions!")) |
13130 | 1361 )) |
1362 | |
1363 ;; Apply OPERATION to marked sessions. Operation expects one argument of type | |
1364 ;; meta-list member (not the first one), i.e., a regular session description. | |
1365 ;; Returns number of marked sessions on which operation was performed | |
1366 (defun ediff-operate-on-marked-sessions (operation) | |
1367 (let ((grp-buf (ediff-get-group-buffer ediff-meta-list)) | |
1368 (meta-list (cdr ediff-meta-list)) | |
1369 (marksym ?*) | |
1370 (numMarked 0) | |
1371 (sessionNum 0) | |
19774 | 1372 (diff-buffer ediff-meta-diff-buffer) |
1373 session-buf elt) | |
13130 | 1374 (while meta-list |
1375 (setq elt (car meta-list) | |
1376 meta-list (cdr meta-list) | |
1377 sessionNum (1+ sessionNum)) | |
19774 | 1378 (cond ((eq (ediff-get-session-status elt) marksym) |
1379 (save-excursion | |
1380 (setq numMarked (1+ numMarked)) | |
1381 (funcall operation elt sessionNum))) | |
1382 ((and (ediff-meta-session-p elt) | |
1383 (ediff-buffer-live-p | |
1384 (setq session-buf (ediff-get-session-buffer elt)))) | |
1385 (setq numMarked | |
1386 (+ numMarked | |
1387 (ediff-with-current-buffer session-buf | |
1388 ;; pass meta-diff along | |
1389 (setq ediff-meta-diff-buffer diff-buffer) | |
1390 ;; collect diffs in child group | |
1391 (ediff-operate-on-marked-sessions operation))))))) | |
20206 | 1392 (ediff-update-meta-buffer grp-buf 'must-redraw) ; just in case |
13130 | 1393 numMarked |
1394 )) | |
1395 | |
1396 (defun ediff-append-custom-diff (session sessionNum) | |
1397 (or (ediff-collect-diffs-metajob) | |
19774 | 1398 (error "Hmm, I'd hate to do it to you ...")) |
13130 | 1399 (let ((session-buf (ediff-get-session-buffer session)) |
1400 (meta-diff-buff ediff-meta-diff-buffer) | |
1401 (metajob ediff-metajob-name) | |
1402 tmp-buf custom-diff-buf) | |
1403 (if (ediff-buffer-live-p session-buf) | |
19047 | 1404 (ediff-with-current-buffer session-buf |
13130 | 1405 (if (eq ediff-control-buffer session-buf) ; individual session |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1406 (progn |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1407 (ediff-compute-custom-diffs-maybe) |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1408 (setq custom-diff-buf ediff-custom-diff-buffer))))) |
13130 | 1409 |
1410 (or (ediff-buffer-live-p meta-diff-buff) | |
1411 (error "Ediff: something wrong--no multiple diffs buffer")) | |
1412 | |
1413 (cond ((ediff-buffer-live-p custom-diff-buf) | |
1414 (save-excursion | |
1415 (set-buffer meta-diff-buff) | |
1416 (goto-char (point-max)) | |
1417 (insert-buffer custom-diff-buf) | |
1418 (insert "\n"))) | |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1419 ((memq metajob '(ediff-directories |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1420 ediff-merge-directories |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1421 ediff-merge-directories-with-ancestor)) |
13130 | 1422 ;; get diffs by calling shell command on ediff-custom-diff-program |
1423 (save-excursion | |
1424 (set-buffer (setq tmp-buf (get-buffer-create ediff-tmp-buffer))) | |
1425 (erase-buffer) | |
1426 (shell-command | |
1427 (format "%s %s %s %s" | |
1428 ediff-custom-diff-program ediff-custom-diff-options | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1429 (ediff-get-session-objA-name session) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1430 (ediff-get-session-objB-name session)) |
13130 | 1431 t)) |
1432 (save-excursion | |
1433 (set-buffer meta-diff-buff) | |
1434 (goto-char (point-max)) | |
1435 (insert-buffer tmp-buf) | |
1436 (insert "\n"))) | |
1437 (t | |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1438 (error "Can't make context diff for Session %d" sessionNum ))) |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1439 )) |
13130 | 1440 |
1441 (defun ediff-collect-custom-diffs () | |
1442 "Collect custom diffs of marked sessions in buffer `*Ediff Multifile Diffs*'. | |
1443 This operation is defined only for `ediff-directories' and | |
1444 `ediff-directory-revisions', since its intent is to produce | |
1445 multifile patches. For `ediff-directory-revisions', we insist that | |
1446 all marked sessions must be active." | |
1447 (interactive) | |
1448 (or (ediff-buffer-live-p ediff-meta-diff-buffer) | |
1449 (setq ediff-meta-diff-buffer | |
1450 (get-buffer-create | |
1451 (ediff-unique-buffer-name "*Ediff Multifile Diffs" "*")))) | |
19047 | 1452 (ediff-with-current-buffer ediff-meta-diff-buffer |
13130 | 1453 (erase-buffer)) |
1454 (if (> (ediff-operate-on-marked-sessions 'ediff-append-custom-diff) 0) | |
1455 ;; did something | |
1456 (display-buffer ediff-meta-diff-buffer 'not-this-window) | |
1457 (beep) | |
1458 (message "No marked sessions found"))) | |
1459 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1460 (defun ediff-meta-show-patch () |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1461 "Show the multi-file patch associated with this group session." |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1462 (interactive) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1463 (let* ((pos (ediff-event-point last-command-event)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1464 (meta-buf (ediff-event-buffer last-command-event)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1465 (info (ediff-get-meta-info meta-buf pos 'noerror)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1466 (patchbuffer ediff-meta-patchbufer)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1467 (if (ediff-buffer-live-p patchbuffer) |
19047 | 1468 (ediff-with-current-buffer patchbuffer |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1469 (save-restriction |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1470 (if (not info) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1471 (widen) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1472 (narrow-to-region |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1473 (ediff-get-session-objB-name info) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1474 (ediff-get-session-objC-name info))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1475 (set-buffer (get-buffer-create ediff-tmp-buffer)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1476 (erase-buffer) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1477 (insert-buffer patchbuffer) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1478 (display-buffer ediff-tmp-buffer 'not-this-window) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1479 )) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1480 (error "The patch buffer wasn't found")))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1481 |
13130 | 1482 |
1483 ;; This function executes in meta buffer. It knows where event happened. | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1484 (defun ediff-filegroup-action () |
13130 | 1485 "Execute appropriate action for the selected session." |
1486 (interactive) | |
1487 (let* ((pos (ediff-event-point last-command-event)) | |
1488 (meta-buf (ediff-event-buffer last-command-event)) | |
1489 ;; ediff-get-meta-info gives error if meta-buf or pos are invalid | |
1490 (info (ediff-get-meta-info meta-buf pos)) | |
20206 | 1491 (session-buf (ediff-get-session-buffer info)) |
20343 | 1492 (session-number (ediff-get-session-number-at-pos pos meta-buf)) |
20206 | 1493 merge-autostore-dir file1 file2 file3 regexp) |
13130 | 1494 |
20206 | 1495 (setq file1 (ediff-get-session-objA-name info) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1496 file2 (ediff-get-session-objB-name info) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1497 file3 (ediff-get-session-objC-name info)) |
13130 | 1498 |
1499 ;; make sure we don't start on hidden sessions | |
1500 ;; ?H means marked for hiding. ?I means invalid (hidden). | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1501 (if (memq (ediff-get-session-status info) '(?I)) |
13130 | 1502 (progn |
1503 (beep) | |
1504 (if (y-or-n-p "This session is marked as hidden, unmark? ") | |
1505 (progn | |
1506 (ediff-set-session-status info nil) | |
20206 | 1507 (ediff-update-meta-buffer meta-buf nil session-number)) |
13130 | 1508 (error "Aborted")))) |
1509 | |
19047 | 1510 (ediff-with-current-buffer meta-buf |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1511 (setq merge-autostore-dir |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1512 (ediff-get-group-merge-autostore-dir ediff-meta-list)) |
13130 | 1513 (goto-char pos) ; if the user clicked on session--move point there |
1514 ;; First handle sessions involving directories (which are themselves | |
1515 ;; session groups) | |
1516 ;; After that handle individual sessions | |
19774 | 1517 (cond ((ediff-meta-session-p info) |
13130 | 1518 ;; do ediff/ediff-merge on subdirectories |
1519 (if (ediff-buffer-live-p session-buf) | |
1520 (ediff-show-meta-buffer session-buf) | |
1521 (setq regexp (read-string "Filter through regular expression: " | |
1522 nil 'ediff-filtering-regexp-history)) | |
1523 (ediff-directories-internal | |
1524 file1 file2 file3 regexp | |
1525 ediff-session-action-function | |
1526 ediff-metajob-name | |
1527 ;; make it update car info after startup | |
1528 (` (list (lambda () | |
1529 ;; child session group should know its parent | |
1530 (setq ediff-parent-meta-buffer | |
20206 | 1531 (quote (, ediff-meta-buffer)) |
1532 ediff-meta-session-number | |
1533 (, session-number)) | |
13130 | 1534 ;; and parent will know its child |
1535 (setcar (quote (, info)) ediff-meta-buffer))))))) | |
1536 | |
1537 ;; Do ediff-revision on a subdirectory | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1538 ((and (ediff-one-filegroup-metajob) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1539 (ediff-revision-metajob) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1540 (file-directory-p file1)) |
13130 | 1541 (if (ediff-buffer-live-p session-buf) |
1542 (ediff-show-meta-buffer session-buf) | |
1543 (setq regexp (read-string "Filter through regular expression: " | |
1544 nil 'ediff-filtering-regexp-history)) | |
1545 (ediff-directory-revisions-internal | |
1546 file1 regexp | |
1547 ediff-session-action-function ediff-metajob-name | |
1548 ;; make it update car info after startup | |
1549 (` (list (lambda () | |
20206 | 1550 ;; child session group should know its parent and |
1551 ;; its number | |
13130 | 1552 (setq ediff-parent-meta-buffer |
20206 | 1553 (quote (, ediff-meta-buffer)) |
1554 ediff-meta-session-number | |
1555 (, session-number)) | |
13130 | 1556 ;; and parent will know its child |
1557 (setcar (quote (, info)) ediff-meta-buffer))))))) | |
1558 | |
1559 ;; From here on---only individual session handlers | |
1560 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1561 ;; handle an individual session with a live control buffer |
13130 | 1562 ((ediff-buffer-live-p session-buf) |
19047 | 1563 (ediff-with-current-buffer session-buf |
13130 | 1564 (setq ediff-mouse-pixel-position (mouse-pixel-position)) |
1565 (ediff-recenter 'no-rehighlight))) | |
1566 | |
1567 ((ediff-problematic-session-p info) | |
1568 (beep) | |
1569 (if (y-or-n-p | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1570 "This session has no ancestor. Merge without the ancestor? ") |
13130 | 1571 (ediff-merge-files |
1572 file1 file2 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1573 ;; provide startup hooks |
13130 | 1574 (` (list (lambda () |
20206 | 1575 (setq ediff-meta-buffer (, (current-buffer)) |
1576 ediff-meta-session-number | |
1577 (, session-number)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1578 (setq ediff-merge-store-file |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1579 (, (concat |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1580 merge-autostore-dir |
20206 | 1581 "merge_" |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1582 (file-name-nondirectory file1)))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1583 ;; make ediff-startup pass |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1584 ;; ediff-control-buffer back to the meta |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1585 ;; level; see below |
13130 | 1586 (setcar |
1587 (quote (, info)) ediff-control-buffer))))) | |
1588 (error "Aborted"))) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1589 ((ediff-one-filegroup-metajob) ; needs 1 file arg |
13130 | 1590 (funcall ediff-session-action-function |
1591 file1 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1592 ;; provide startup hooks |
13130 | 1593 (` (list (lambda () |
20206 | 1594 (setq ediff-meta-buffer (, (current-buffer)) |
1595 ediff-meta-session-number | |
1596 (, session-number)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1597 (setq ediff-merge-store-file |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1598 (, (concat |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1599 merge-autostore-dir |
20206 | 1600 "merge_" |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1601 (file-name-nondirectory file1)))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1602 ;; make ediff-startup pass |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1603 ;; ediff-control-buffer back to the meta |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1604 ;; level; see below |
13130 | 1605 (setcar |
1606 (quote (, info)) ediff-control-buffer)))))) | |
1607 ((not (ediff-metajob3)) ; need 2 file args | |
1608 (funcall ediff-session-action-function | |
1609 file1 file2 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1610 ;; provide startup hooks |
13130 | 1611 (` (list (lambda () |
20206 | 1612 (setq ediff-meta-buffer (, (current-buffer)) |
1613 ediff-meta-session-number | |
1614 (, session-number)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1615 (setq ediff-merge-store-file |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1616 (, (concat |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1617 merge-autostore-dir |
20206 | 1618 "merge_" |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1619 (file-name-nondirectory file1)))) |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1620 ;; make ediff-startup pass |
13130 | 1621 ;; ediff-control-buffer back to the meta |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1622 ;; level; see below |
13130 | 1623 (setcar |
1624 (quote (, info)) ediff-control-buffer)))))) | |
1625 ((ediff-metajob3) ; need 3 file args | |
1626 (funcall ediff-session-action-function | |
1627 file1 file2 file3 | |
1628 ;; arrange startup hooks | |
1629 (` (list (lambda () | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1630 (setq ediff-merge-store-file |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1631 (, (concat |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1632 merge-autostore-dir |
20206 | 1633 "merge_" |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1634 (file-name-nondirectory file1)))) |
20206 | 1635 (setq ediff-meta-buffer (, (current-buffer)) |
1636 ediff-meta-session-number | |
1637 (, session-number)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1638 ;; this arranges that ediff-startup will pass |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1639 ;; the value of ediff-control-buffer back to |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1640 ;; the meta level, to the record in the meta |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1641 ;; list containing the information about the |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1642 ;; session associated with that |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1643 ;; ediff-control-buffer |
13130 | 1644 (setcar |
1645 (quote (, info)) ediff-control-buffer)))))) | |
1646 ) ; cond | |
1647 ) ; eval in meta-buf | |
1648 )) | |
1649 | |
1650 (defun ediff-registry-action () | |
1651 "Switch to a selected session." | |
1652 (interactive) | |
1653 (let* ((pos (ediff-event-point last-command-event)) | |
1654 (buf (ediff-event-buffer last-command-event)) | |
1655 (ctl-buf (ediff-get-meta-info buf pos))) | |
1656 | |
1657 (if (ediff-buffer-live-p ctl-buf) | |
1658 ;; check if this is ediff-control-buffer or ediff-meta-buffer | |
19047 | 1659 (if (ediff-with-current-buffer ctl-buf |
13130 | 1660 (eq (key-binding "q") 'ediff-quit-meta-buffer)) |
1661 ;; it's a meta-buffer -- last action should just display it | |
20206 | 1662 (ediff-show-meta-buffer ctl-buf t) |
13130 | 1663 ;; it's a session buffer -- invoke go back to session |
19047 | 1664 (ediff-with-current-buffer ctl-buf |
13130 | 1665 (setq ediff-mouse-pixel-position (mouse-pixel-position)) |
1666 (ediff-recenter 'no-rehighlight))) | |
1667 (beep) | |
1668 (message "You've selected a stale session --- try again") | |
1669 (ediff-update-registry)) | |
19047 | 1670 (ediff-with-current-buffer buf |
13130 | 1671 (goto-char pos)) |
1672 )) | |
1673 | |
1674 | |
20206 | 1675 ;; If session number is t, means don't update meta buffer |
1676 (defun ediff-show-meta-buffer (&optional meta-buf session-number) | |
13130 | 1677 "Show the session group buffer." |
1678 (interactive) | |
1679 (let (wind frame silent) | |
1680 (if meta-buf (setq silent t)) | |
1681 | |
1682 (setq meta-buf (or meta-buf ediff-meta-buffer)) | |
1683 (cond ((not (bufferp meta-buf)) | |
1684 (error "This Ediff session is not part of a session group")) | |
1685 ((not (ediff-buffer-live-p meta-buf)) | |
1686 (error | |
1687 "Can't find this session's group panel -- session itself is ok"))) | |
1688 | |
20206 | 1689 (cond ((numberp session-number) |
1690 (ediff-update-meta-buffer meta-buf nil session-number)) | |
1691 ;; if session-number is t, don't update | |
1692 (session-number) | |
1693 (t (ediff-cleanup-meta-buffer meta-buf))) | |
1694 | |
19047 | 1695 (ediff-with-current-buffer meta-buf |
13130 | 1696 (save-excursion |
1697 (cond ((setq wind (ediff-get-visible-buffer-window meta-buf)) | |
1698 (or silent | |
1699 (message | |
1700 "Already showing the group panel for this session")) | |
1701 (set-window-buffer wind meta-buf) | |
1702 (select-window wind)) | |
1703 ((window-live-p (setq wind ediff-window-C)) ;in merge--merge buf | |
1704 (set-window-buffer ediff-window-C meta-buf) | |
1705 (select-window wind)) | |
1706 ((window-live-p (setq wind ediff-window-A)) | |
1707 (set-window-buffer ediff-window-A meta-buf) | |
1708 (select-window wind)) | |
1709 ((window-live-p (setq wind ediff-window-B)) | |
1710 (set-window-buffer ediff-window-B meta-buf) | |
1711 (select-window wind)) | |
1712 ((and | |
1713 (setq wind | |
1714 (ediff-get-visible-buffer-window ediff-registry-buffer)) | |
1715 (ediff-window-display-p)) | |
1716 (select-window wind) | |
1717 (other-window 1) | |
1718 (set-window-buffer (selected-window) meta-buf)) | |
1719 (t (ediff-skip-unsuitable-frames 'ok-unsplittable) | |
1720 (set-window-buffer (selected-window) meta-buf))) | |
1721 )) | |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1722 (if (and (ediff-window-display-p) |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1723 (window-live-p |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1724 (setq wind (ediff-get-visible-buffer-window meta-buf)))) |
13130 | 1725 (progn |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1726 (setq frame (window-frame wind)) |
13130 | 1727 (raise-frame frame) |
1728 (ediff-reset-mouse frame))) | |
1729 (run-hooks 'ediff-show-session-group-hook) | |
1730 )) | |
1731 | |
20206 | 1732 (defun ediff-show-current-session-meta-buffer () |
1733 (interactive) | |
1734 (ediff-show-meta-buffer nil ediff-meta-session-number)) | |
1735 | |
13130 | 1736 (defun ediff-show-meta-buff-from-registry () |
1737 "Display the session group buffer for a selected session group." | |
1738 (interactive) | |
1739 (let* ((pos (ediff-event-point last-command-event)) | |
1740 (meta-buf (ediff-event-buffer last-command-event)) | |
1741 (info (ediff-get-meta-info meta-buf pos)) | |
1742 (meta-or-session-buf info)) | |
19047 | 1743 (ediff-with-current-buffer meta-or-session-buf |
20206 | 1744 (ediff-show-meta-buffer nil t)))) |
13130 | 1745 |
1746 ;;;###autoload | |
1747 (defun ediff-show-registry () | |
1748 "Display Ediff's registry." | |
1749 (interactive) | |
1750 (ediff-update-registry) | |
1751 (if (not (ediff-buffer-live-p ediff-registry-buffer)) | |
1752 (error "No active Ediff sessions or corrupted session registry")) | |
1753 (let (wind frame) | |
1754 ;; for some reason, point moves in ediff-registry-buffer, so we preserve it | |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1755 ;; explicitly |
19047 | 1756 (ediff-with-current-buffer ediff-registry-buffer |
13130 | 1757 (save-excursion |
1758 (cond ((setq wind | |
1759 (ediff-get-visible-buffer-window ediff-registry-buffer)) | |
1760 (message "Already showing the registry") | |
1761 (set-window-buffer wind ediff-registry-buffer) | |
1762 (select-window wind)) | |
1763 ((window-live-p ediff-window-C) | |
1764 (set-window-buffer ediff-window-C ediff-registry-buffer) | |
1765 (select-window ediff-window-C)) | |
1766 ((window-live-p ediff-window-A) | |
1767 (set-window-buffer ediff-window-A ediff-registry-buffer) | |
1768 (select-window ediff-window-A)) | |
1769 ((window-live-p ediff-window-B) | |
1770 (set-window-buffer ediff-window-B ediff-registry-buffer) | |
1771 (select-window ediff-window-B)) | |
1772 ((and (setq wind | |
1773 (ediff-get-visible-buffer-window ediff-meta-buffer)) | |
1774 (ediff-window-display-p)) | |
1775 (select-window wind) | |
1776 (other-window 1) | |
1777 (set-window-buffer (selected-window) ediff-registry-buffer)) | |
1778 (t (ediff-skip-unsuitable-frames 'ok-unsplittable) | |
1779 (set-window-buffer (selected-window) ediff-registry-buffer))) | |
1780 )) | |
1781 (if (ediff-window-display-p) | |
1782 (progn | |
1783 (setq frame | |
1784 (window-frame | |
1785 (ediff-get-visible-buffer-window ediff-registry-buffer))) | |
1786 (raise-frame frame) | |
1787 (ediff-reset-mouse frame))) | |
1788 (run-hooks 'ediff-show-registry-hook) | |
1789 )) | |
1790 | |
1791 ;;;###autoload | |
1792 (defalias 'eregistry 'ediff-show-registry) | |
1793 | |
1794 ;; If meta-buf doesn't exist, it is created. In that case, id doesn't have a | |
1795 ;; parent meta-buf | |
1796 ;; Check if META-BUF exists before calling this function | |
20206 | 1797 ;; Optional MUST-REDRAW, if non-nil, would force redrawal of the whole meta |
1798 ;; buffer. Otherwise, it will just go over the buffer and update activity marks | |
1799 ;; and session status. | |
1800 ;; SESSION-NUMBER, if specified, says which session caused the update. | |
1801 (defun ediff-update-meta-buffer (meta-buf &optional must-redraw session-number) | |
1802 (if (ediff-buffer-live-p meta-buf) | |
1803 (ediff-with-current-buffer meta-buf | |
1804 (cond (must-redraw ; completely redraw the meta buffer | |
1805 (funcall ediff-meta-redraw-function ediff-meta-list)) | |
1806 ((numberp session-number) ; redraw only for the given session | |
1807 (ediff-update-session-marker-in-dir-meta-buffer session-number)) | |
1808 (t ; update only what's changed, but scan the entire meta buffer | |
1809 (ediff-update-markers-in-dir-meta-buffer ediff-meta-list))) | |
1810 ))) | |
13130 | 1811 |
1812 (defun ediff-update-registry () | |
19047 | 1813 (ediff-with-current-buffer (current-buffer) |
13130 | 1814 (if (ediff-buffer-live-p ediff-registry-buffer) |
1815 (ediff-redraw-registry-buffer) | |
1816 (ediff-prepare-meta-buffer | |
1817 'ediff-registry-action | |
1818 ediff-session-registry | |
1819 "*Ediff Registry" | |
1820 'ediff-redraw-registry-buffer | |
1821 'ediff-registry)) | |
1822 )) | |
1823 | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1824 ;; If meta-buf exists, it is redrawn along with parent. |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1825 ;; Otherwise, nothing happens. |
13130 | 1826 (defun ediff-cleanup-meta-buffer (meta-buffer) |
1827 (if (ediff-buffer-live-p meta-buffer) | |
19047 | 1828 (ediff-with-current-buffer meta-buffer |
13130 | 1829 (ediff-update-meta-buffer meta-buffer) |
1830 (if (ediff-buffer-live-p ediff-parent-meta-buffer) | |
20206 | 1831 (ediff-update-meta-buffer |
1832 ediff-parent-meta-buffer nil ediff-meta-session-number))))) | |
13130 | 1833 |
20206 | 1834 ;; t if no session is in progress |
13130 | 1835 (defun ediff-safe-to-quit (meta-buffer) |
1836 (if (ediff-buffer-live-p meta-buffer) | |
1837 (let ((lis ediff-meta-list) | |
1838 (cont t) | |
1839 buffer-read-only) | |
20206 | 1840 ;;(ediff-update-meta-buffer meta-buffer) |
19047 | 1841 (ediff-with-current-buffer meta-buffer |
13130 | 1842 (setq lis (cdr lis)) ; discard the description part of meta-list |
1843 (while (and cont lis) | |
1844 (if (ediff-buffer-live-p | |
1845 (ediff-get-group-buffer lis)) ; in progress | |
1846 (setq cont nil)) | |
1847 (setq lis (cdr lis))) | |
1848 cont)))) | |
1849 | |
1850 (defun ediff-quit-meta-buffer () | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1851 "If the group has no active session, delete the meta buffer. |
13130 | 1852 If no session is in progress, ask to confirm before deleting meta buffer. |
1853 Otherwise, bury the meta buffer. | |
1854 If this is a session registry buffer then just bury it." | |
1855 (interactive) | |
1856 (let* ((buf (current-buffer)) | |
1857 (dir-diffs-buffer ediff-dir-diffs-buffer) | |
1858 (meta-diff-buffer ediff-meta-diff-buffer) | |
20206 | 1859 (session-number ediff-meta-session-number) |
13130 | 1860 (parent-buf ediff-parent-meta-buffer) |
1861 (dont-show-registry (eq buf ediff-registry-buffer))) | |
1862 (if dont-show-registry | |
1863 (bury-buffer) | |
20206 | 1864 ;;(ediff-cleanup-meta-buffer buf) |
13130 | 1865 (cond ((and (ediff-safe-to-quit buf) |
1866 (y-or-n-p "Quit this session group? ")) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
1867 (run-hooks 'ediff-quit-session-group-hook) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1868 (message "") |
13130 | 1869 (ediff-dispose-of-meta-buffer buf)) |
1870 ((ediff-safe-to-quit buf) | |
1871 (bury-buffer)) | |
1872 (t | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1873 (error |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1874 "This session group has active sessions---cannot exit"))) |
20206 | 1875 (ediff-update-meta-buffer parent-buf nil session-number) |
13130 | 1876 (ediff-kill-buffer-carefully dir-diffs-buffer) |
1877 (ediff-kill-buffer-carefully meta-diff-buffer) | |
1878 (if (ediff-buffer-live-p parent-buf) | |
1879 (progn | |
1880 (setq dont-show-registry t) | |
20206 | 1881 (ediff-show-meta-buffer parent-buf session-number))) |
13130 | 1882 ) |
1883 (or dont-show-registry | |
1884 (ediff-show-registry)))) | |
1885 | |
1886 (defun ediff-dispose-of-meta-buffer (buf) | |
1887 (setq ediff-session-registry (delq buf ediff-session-registry)) | |
19047 | 1888 (ediff-with-current-buffer buf |
13130 | 1889 (if (ediff-buffer-live-p ediff-dir-diffs-buffer) |
1890 (kill-buffer ediff-dir-diffs-buffer))) | |
1891 (kill-buffer buf)) | |
1892 | |
1893 | |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
1894 ;; Obtain information on a meta record where the user clicked or typed |
13130 | 1895 ;; BUF is the buffer where this happened and POINT is the position |
1896 ;; If optional NOERROR arg is given, don't report error and return nil if no | |
1897 ;; meta info is found on line. | |
1898 (defun ediff-get-meta-info (buf point &optional noerror) | |
1899 (let (result olist tmp) | |
1900 (if (and point (ediff-buffer-live-p buf)) | |
19047 | 1901 (ediff-with-current-buffer buf |
13130 | 1902 (if ediff-xemacs-p |
1903 (setq result | |
1904 (if (setq tmp (extent-at point buf 'ediff-meta-info)) | |
1905 (ediff-overlay-get tmp 'ediff-meta-info))) | |
1906 (setq olist (overlays-at point)) | |
1907 (setq olist | |
1908 (mapcar (function (lambda (elt) | |
1909 (overlay-get elt 'ediff-meta-info))) | |
1910 olist)) | |
1911 (while (and olist (null (car olist)) | |
1912 (overlay-get (car olist) 'invisible)) | |
1913 (setq olist (cdr olist))) | |
1914 (setq result (car olist))))) | |
1915 (if result | |
1916 result | |
1917 (if noerror | |
1918 nil | |
1919 (ediff-update-registry) | |
1920 (error "No session info in this line"))))) | |
1921 | |
20206 | 1922 |
1923 (defun ediff-get-meta-overlay-at-pos (point) | |
1924 (if ediff-xemacs-p | |
1925 (extent-at point (current-buffer) 'ediff-meta-info) | |
1926 (let* ((overl-list (overlays-at point)) | |
1927 (overl (car overl-list))) | |
1928 (while (and overl (null (overlay-get overl 'ediff-meta-info))) | |
1929 (setq overl-list (cdr overl-list) | |
1930 overl (car overl-list))) | |
1931 overl))) | |
1932 | |
20343 | 1933 (defsubst ediff-get-session-number-at-pos (point &optional meta-buffer) |
1934 (setq meta-buffer (if (ediff-buffer-live-p meta-buffer) | |
1935 meta-buffer | |
1936 (current-buffer))) | |
1937 (ediff-with-current-buffer meta-buffer | |
1938 (ediff-overlay-get | |
1939 (ediff-get-meta-overlay-at-pos point) 'ediff-meta-session-number))) | |
20206 | 1940 |
1941 | |
1942 ;; Return location of the next meta overlay after point | |
13130 | 1943 (defun ediff-next-meta-overlay-start (point) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1944 (if (eobp) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1945 (goto-char (point-min)) |
20206 | 1946 (let ((overl (ediff-get-meta-overlay-at-pos point))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1947 (if ediff-xemacs-p |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1948 (progn |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1949 (if overl |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1950 (setq overl (next-extent overl)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1951 (setq overl (next-extent (current-buffer)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1952 (if overl |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1953 (extent-start-position overl) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1954 (point-max))) |
20206 | 1955 (if overl |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1956 ;; note: end of current overlay is the beginning of the next one |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1957 (overlay-end overl) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1958 (next-overlay-change point)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1959 )) |
13130 | 1960 |
20206 | 1961 |
13130 | 1962 (defun ediff-previous-meta-overlay-start (point) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1963 (if (bobp) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1964 (goto-char (point-max)) |
20206 | 1965 (let ((overl (ediff-get-meta-overlay-at-pos point))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1966 (if ediff-xemacs-p |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1967 (progn |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1968 (if overl |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1969 (setq overl (previous-extent overl)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1970 (setq overl (previous-extent (current-buffer)))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1971 (if overl |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1972 (extent-start-position overl) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1973 (point-min))) |
20206 | 1974 (if overl (setq point (overlay-start overl))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1975 ;; to get to the beginning of prev overlay |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1976 (if (not (bobp)) |
20206 | 1977 ;; trick to overcome an emacs bug--doesn't always find previous |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1978 ;; overlay change correctly |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1979 (setq point (1- point))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1980 (setq point (previous-overlay-change point)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1981 ;; If we are not over an overlay after subtracting 1, it means we are |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1982 ;; in the description area preceding session records. In this case, |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1983 ;; goto the top of the registry buffer. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1984 (or (car (overlays-at point)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1985 (setq point (point-min))) |
20206 | 1986 point)))) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1987 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1988 ;; this is the action invoked when the user selects a patch from the meta |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1989 ;; buffer. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1990 (defun ediff-patch-file-form-meta (file &optional startup-hooks) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1991 (let* ((pos (ediff-event-point last-command-event)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1992 (meta-buf (ediff-event-buffer last-command-event)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1993 ;; ediff-get-meta-info gives error if meta-buf or pos are invalid |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1994 (info (ediff-get-meta-info meta-buf pos)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1995 (meta-patchbuf ediff-meta-patchbufer) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1996 session-buf beg-marker end-marker) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1997 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1998 (if (or (file-directory-p file) (string-match "/dev/null" file)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
1999 (error "`%s' is not an ordinary file" (file-name-as-directory file))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2000 (setq session-buf (ediff-get-session-buffer info) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2001 beg-marker (ediff-get-session-objB-name info) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2002 end-marker (ediff-get-session-objC-name info)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2003 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2004 (or (ediff-buffer-live-p session-buf) ; either an active patch session |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2005 (null session-buf) ; or it is a virgin session |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2006 (error |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2007 "Patch has been already applied to this file--cannot be repeated!")) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2008 |
19047 | 2009 (ediff-with-current-buffer meta-patchbuf |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2010 (save-restriction |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2011 (widen) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2012 (narrow-to-region beg-marker end-marker) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2013 (ediff-patch-file-internal meta-patchbuf file startup-hooks))))) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2014 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2015 |
22286 | 2016 (defun ediff-unmark-all-for-operation () |
2017 "Unmark all sessions marked for operation." | |
2018 (interactive) | |
2019 (let ((list (cdr ediff-meta-list))) | |
2020 (while (setq elt (car list)) | |
2021 (ediff-mark-session-for-operation elt 'unmark) | |
2022 (setq list (cdr list)))) | |
2023 (ediff-update-meta-buffer (current-buffer) 'must-redraw)) | |
2024 | |
2025 (defun ediff-unmark-all-for-hiding () | |
2026 "Unmark all sessions marked for hiding." | |
2027 (interactive) | |
2028 (let ((list (cdr ediff-meta-list))) | |
2029 (while (setq elt (car list)) | |
2030 (ediff-mark-session-for-hiding elt 'unmark) | |
2031 (setq list (cdr list)))) | |
2032 (ediff-update-meta-buffer (current-buffer) 'must-redraw)) | |
2033 | |
2034 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2035 (defun ediff-meta-mark-equal-files () |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2036 "Run though the session list and mark identical files. |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2037 This is used only for sessions that involve 2 or 3 files at the same time." |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2038 (interactive) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2039 (let ((list (cdr ediff-meta-list)) |
22286 | 2040 marked1 marked2 marked3 |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2041 fileinfo1 fileinfo2 fileinfo3 elt) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2042 (while (setq elt (car list)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2043 (setq fileinfo1 (ediff-get-session-objA elt) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2044 fileinfo2 (ediff-get-session-objB elt) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2045 fileinfo3 (ediff-get-session-objC elt)) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2046 (ediff-set-file-eqstatus fileinfo1 nil) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2047 (ediff-set-file-eqstatus fileinfo2 nil) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2048 (ediff-set-file-eqstatus fileinfo3 nil) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2049 |
22286 | 2050 (setq marked1 t |
2051 marked2 t | |
2052 marked3 t) | |
2053 (or (ediff-mark-if-equal fileinfo1 fileinfo2) | |
2054 (setq marked1 nil)) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2055 (if (ediff-metajob3) |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2056 (progn |
22286 | 2057 (or (ediff-mark-if-equal fileinfo1 fileinfo3) |
2058 (setq marked2 nil)) | |
2059 (or (ediff-mark-if-equal fileinfo2 fileinfo3) | |
2060 (setq marked3 nil)))) | |
2061 (if (and marked1 marked2 marked3) | |
2062 (cond ((eq last-command-char ?h) | |
2063 (ediff-mark-session-for-hiding elt 'mark)) | |
2064 ((eq last-command-char ?m) | |
2065 (ediff-mark-session-for-operation elt 'mark)) | |
2066 )) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2067 (setq list (cdr list)))) |
20206 | 2068 (ediff-update-meta-buffer (current-buffer) 'must-redraw)) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2069 |
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2070 ;; mark files 1 and 2 as equal, if they are. |
22286 | 2071 ;; returns t, if something was marked |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2072 (defun ediff-mark-if-equal (fileinfo1 fileinfo2) |
20206 | 2073 (let ((f1 (car fileinfo1)) |
2074 (f2 (car fileinfo2))) | |
22286 | 2075 (cond ((file-directory-p f1) nil) |
2076 ((file-directory-p f2) nil) | |
2077 ((ediff-same-file-contents f1 f2) | |
2078 (ediff-set-file-eqstatus fileinfo1 t) | |
2079 (ediff-set-file-eqstatus fileinfo2 t) | |
2080 t)) | |
2081 )) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
2082 |
13130 | 2083 |
2084 | |
2085 ;;; Local Variables: | |
2086 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) | |
19047 | 2087 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) |
2088 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) | |
13130 | 2089 ;;; End: |
2090 | |
13607
71a4a349d998
Renamed from ediff-meta.el. Changed provide.
Richard M. Stallman <rms@gnu.org>
parents:
13216
diff
changeset
|
2091 ;;; ediff-mult.el ends here |