annotate lisp/emerge.el @ 9580:bcc9342cf633

(x_set_unsplittable): New function. (x_frame_parms): Add that function to the table.
author Karl Heuer <kwzh@gnu.org>
date Tue, 18 Oct 1994 02:32:43 +0000
parents 0d7b32820221
children a94dba376d9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1 ;;; emerge.el --- merge diffs under Emacs control
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3 ;;; The author has placed this file in the public domain.
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2029
diff changeset
4
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
5 ;; Author: Dale R. Worley <drw@math.mit.edu>
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
6 ;; Version: 5fsf
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
7 ;; Keywords: unix, tools
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
9 ;; This software was created by Dale R. Worley and is
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
10 ;; distributed free of charge. It is placed in the public domain and
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
11 ;; permission is granted to anyone to use, duplicate, modify and redistribute
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
12 ;; it provided that this notice is attached.
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2029
diff changeset
13
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
14 ;; Dale R. Worley provides absolutely NO WARRANTY OF ANY KIND
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
15 ;; with respect to this software. The entire risk as to the quality and
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
16 ;; performance of this software is with the user. IN NO EVENT WILL DALE
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
17 ;; R. WORLEY BE LIABLE TO ANYONE FOR ANY DAMAGES ARISING OUT THE
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
18 ;; USE OF THIS SOFTWARE, INCLUDING, WITHOUT LIMITATION, DAMAGES RESULTING FROM
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
19 ;; LOST DATA OR LOST PROFITS, OR FOR ANY SPECIAL, INCIDENTAL OR CONSEQUENTIAL
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
20 ;; DAMAGES.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
22 ;;; Code:
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
6281
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
24 ;;;###autoload
6809
071551122256 (menu-bar-emerge-menu): Improve menu title.
Richard M. Stallman <rms@gnu.org>
parents: 6556
diff changeset
25 (defvar menu-bar-emerge-menu (make-sparse-keymap "Emerge"))
6281
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
26 ;;;###autoload
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
27 (fset 'menu-bar-emerge-menu (symbol-value 'menu-bar-emerge-menu))
5798
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
28
6281
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
29 ;;;###autoload
5798
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
30 (define-key menu-bar-emerge-menu [emerge-merge-directories]
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
31 '("Merge Directories ..." . emerge-merge-directories))
6281
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
32 ;;;###autoload
5798
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
33 (define-key menu-bar-emerge-menu [emerge-revisions-with-ancestor]
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
34 '("Revisions with Ancestor ..." . emerge-revisions-with-ancestor))
6286
676773222f1f (emerge-revisions, emerge-revisions-with-ancestor)
Richard M. Stallman <rms@gnu.org>
parents: 6281
diff changeset
35 ;;;###autoload
5798
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
36 (define-key menu-bar-emerge-menu [emerge-revisions]
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
37 '("Revisions ..." . emerge-revisions))
6281
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
38 ;;;###autoload
5798
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
39 (define-key menu-bar-emerge-menu [emerge-files-with-ancestor]
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
40 '("Files with Ancestor ..." . emerge-files-with-ancestor))
6281
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
41 ;;;###autoload
5798
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
42 (define-key menu-bar-emerge-menu [emerge-files]
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
43 '("Files ..." . emerge-files))
6281
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
44 ;;;###autoload
5798
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
45 (define-key menu-bar-emerge-menu [emerge-buffers-with-ancestor]
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
46 '("Buffers with Ancestor ..." . emerge-buffers-with-ancestor))
6281
e98ae7dec34d (menu-bar-emerge-menu): Autoload the whole setup.
Richard M. Stallman <rms@gnu.org>
parents: 5798
diff changeset
47 ;;;###autoload
5798
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
48 (define-key menu-bar-emerge-menu [emerge-buffers]
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
49 '("Buffers ..." . emerge-buffers))
c75960d5f2ca (menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents: 5796
diff changeset
50
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 ;;; Macros
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 (defmacro emerge-eval-in-buffer (buffer &rest forms)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 "Macro to switch to BUFFER, evaluate FORMS, returns to original buffer.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
55 Differs from `save-excursion' in that it doesn't save the point and mark."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 (` (let ((StartBuffer (current-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (unwind-protect
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (set-buffer (, buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (,@ forms))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (set-buffer StartBuffer)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (defmacro emerge-defvar-local (var value doc)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
64 "Defines SYMBOL as an advertised variable.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
65 Performs a defvar, then executes `make-variable-buffer-local' on
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
66 the variable. Also sets the `preserved' property, so that
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
67 `kill-all-local-variables' (called by major-mode setting commands)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
68 won't destroy Emerge control variables."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (` (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 (defvar (, var) (, value) (, doc))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (make-variable-buffer-local '(, var))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (put '(, var) 'preserved t))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 ;; Add entries to minor-mode-alist so that emerge modes show correctly
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
75 (defvar emerge-minor-modes-list
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
76 '((emerge-mode " Emerge")
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
77 (emerge-fast-mode " F")
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
78 (emerge-edit-mode " E")
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
79 (emerge-auto-advance " A")
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
80 (emerge-skip-prefers " S")))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 (if (not (assq 'emerge-mode minor-mode-alist))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 (setq minor-mode-alist (append emerge-minor-modes-list
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 minor-mode-alist)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 ;; We need to define this function so describe-mode can describe Emerge mode.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (defun emerge-mode ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
87 "Emerge mode is used by the Emerge file-merging package.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
88 It is entered only through one of the functions:
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
89 `emerge-files'
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
90 `emerge-files-with-ancestor'
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
91 `emerge-buffers'
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
92 `emerge-buffers-with-ancestor'
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
93 `emerge-files-command'
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
94 `emerge-files-with-ancestor-command'
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
95 `emerge-files-remote'
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
96 `emerge-files-with-ancestor-remote'
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 Commands:
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 \\{emerge-basic-keymap}
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
100 Commands must be prefixed by \\<emerge-fast-keymap>\\[emerge-basic-keymap] in `edit' mode,
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
101 but can be invoked directly in `fast' mode.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
103 (defvar emerge-version "5fsf"
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 "The version of Emerge.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 (defun emerge-version ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
107 "Return string describing the version of Emerge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
108 When called interactively, displays the version."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (if (interactive-p)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (message "Emerge version %s" (emerge-version))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 emerge-version))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 ;;; Emerge configuration variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 ;; Commands that produce difference files
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 ;; All that can be configured is the name of the programs to execute
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 ;; (emerge-diff-program and emerge-diff3-program) and the options
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 ;; to be provided (emerge-diff-options). The order in which the file names
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 ;; are given is fixed.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 ;; The file names are always expanded (see expand-file-name) before being
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 ;; passed to diff, thus they need not be invoked under a shell that
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
123 ;; understands `~'.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 ;; The code which processes the diff/diff3 output depends on all the
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 ;; finicky details of their output, including the somewhat strange
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 ;; way they number lines of a file.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (defvar emerge-diff-program "diff"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 "*Name of the program which compares two files.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 (defvar emerge-diff3-program "diff3"
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
130 "*Name of the program which compares three files.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
131 Its arguments are the ancestor file and the two variant files.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (defvar emerge-diff-options ""
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
133 "*Options to pass to `emerge-diff-program' and `emerge-diff3-program'.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (defvar emerge-match-diff-line (let ((x "\\([0-9]+\\)\\(\\|,\\([0-9]+\\)\\)"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (concat "^" x "\\([acd]\\)" x "$"))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
136 "*Pattern to match lines produced by diff that describe differences.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
137 This is as opposed to lines from the source files.")
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
138 (defvar emerge-diff-ok-lines-regexp
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 "^\\([0-9,]+[acd][0-9,]+$\\|[<>] \\|---\\)"
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
140 "*Regexp that matches normal output lines from `emerge-diff-program'.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
141 Lines that do not match are assumed to be error messages.")
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
142 (defvar emerge-diff3-ok-lines-regexp
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 "^\\([1-3]:\\|====\\| \\)"
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
144 "*Regexp that matches normal output lines from `emerge-diff3-program'.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
145 Lines that do not match are assumed to be error messages.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
147 (defvar emerge-rcs-ci-program "ci"
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
148 "*Name of the program that checks in RCS revisions.")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
149 (defvar emerge-rcs-co-program "co"
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
150 "*Name of the program that checks out RCS revisions.")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
151
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
152 (defvar emerge-process-local-variables nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
153 "*Non-nil if Emerge should process local-variables lists in merge buffers.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
154 \(You can explicitly request processing the local-variables
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
155 by executing `(hack-local-variables)'.)")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
156 (defvar emerge-execute-line-deletions nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
157 "*If non-nil: `emerge-execute-line' makes no output if an input was deleted.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
158 It concludes that an input version has been deleted when an ancestor entry
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
159 is present, only one A or B entry is present, and an output entry is present.
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
160 If nil: In such circumstances, the A or B file that is present will be
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
161 copied to the designated output file.")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
162
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
163 (defvar emerge-before-flag "vvvvvvvvvvvvvvvvvvvv\n"
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
164 "*Flag placed above the highlighted block of code. Must end with newline.
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
165 Must be set before Emerge is loaded, or emerge-new-flags must be run
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
166 after setting.")
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
167 (defvar emerge-after-flag "^^^^^^^^^^^^^^^^^^^^\n"
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
168 "*Flag placed below the highlighted block of code. Must end with newline.
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
169 Must be set before Emerge is loaded, or emerge-new-flags must be run
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
170 after setting.")
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
171
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
172 ;; Hook variables
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
173
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
174 (defvar emerge-startup-hook nil
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
175 "*Hook to run in the merge buffer after the merge has been set up.")
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
176 (defvar emerge-select-hook nil
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
177 "*Hook to run after a difference has been selected.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
178 The variable `n' holds the (internal) number of the difference.")
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
179 (defvar emerge-unselect-hook nil
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
180 "*Hook to run after a difference has been unselected.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
181 The variable `n' holds the (internal) number of the difference.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
182
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
183 ;; Variables to control the default directories of the arguments to
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
184 ;; Emerge commands.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
185
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
186 (defvar emerge-default-last-directories nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
187 "*If nil, default dir for filenames in emerge is `default-directory'.
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
188 If non-nil, filenames complete in the directory of the last argument of the
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
189 same type to an `emerge-files...' command.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
190
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
191 (defvar emerge-last-dir-A nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
192 "Last directory for the first file of an `emerge-files...' command.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
193 (defvar emerge-last-dir-B nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
194 "Last directory for the second file of an `emerge-files...' command.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
195 (defvar emerge-last-dir-ancestor nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
196 "Last directory for the ancestor file of an `emerge-files...' command.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
197 (defvar emerge-last-dir-output nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
198 "Last directory for the output file of an `emerge-files...' command.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
199 (defvar emerge-last-revision-A nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
200 "Last RCS revision used for first file of an `emerge-revisions...' command.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
201 (defvar emerge-last-revision-B nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
202 "Last RCS revision used for second file of an `emerge-revisions...' command.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
203 (defvar emerge-last-revision-ancestor nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
204 "Last RCS revision used for ancestor file of an `emerge-revisions...' command.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
205
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
206 (defvar emerge-before-flag-length)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
207 (defvar emerge-before-flag-lines)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
208 (defvar emerge-before-flag-match)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
209 (defvar emerge-after-flag-length)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
210 (defvar emerge-after-flag-lines)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
211 (defvar emerge-after-flag-match)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
212 (defvar emerge-diff-buffer)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
213 (defvar emerge-diff-error-buffer)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
214 (defvar emerge-prefix-argument)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
215 (defvar emerge-file-out)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
216 (defvar emerge-exit-func)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
217 (defvar emerge-globalized-difference-list)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
218 (defvar emerge-globalized-number-of-differences)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
219
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 ;; The flags used to mark differences in the buffers.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 ;; These function definitions need to be up here, because they are used
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 ;; during loading.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (defun emerge-new-flags ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
225 "Function to be called after `emerge-{before,after}-flag'.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
226 This is called after these functions are changed to compute values that
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
227 depend on the flags."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (setq emerge-before-flag-length (length emerge-before-flag))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (setq emerge-before-flag-lines
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
230 (emerge-count-matches-string emerge-before-flag "\n"))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (setq emerge-before-flag-match (regexp-quote emerge-before-flag))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (setq emerge-after-flag-length (length emerge-after-flag))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 (setq emerge-after-flag-lines
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
234 (emerge-count-matches-string emerge-after-flag "\n"))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (setq emerge-after-flag-match (regexp-quote emerge-after-flag)))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
236
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
237 (defun emerge-count-matches-string (string regexp)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 "Return the number of matches in STRING for REGEXP."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (let ((i 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (count 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (while (string-match regexp string i)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (setq count (1+ count))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (setq i (match-end 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 count))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 ;; Calculate dependent variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 (emerge-new-flags)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (defvar emerge-min-visible-lines 3
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 "*Number of lines that we want to show above and below the flags when we are
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 displaying a difference.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (defvar emerge-temp-file-prefix
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (let ((env (getenv "TMPDIR"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 d)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (setq d (if (and env (> (length env) 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 env
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 "/tmp"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (if (= (aref d (1- (length d))) ?/)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 (setq d (substring d 0 -1)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (concat d "/emerge"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 "*Prefix to put on Emerge temporary file names.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
263 Do not start with `~/' or `~user-name/'.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (defvar emerge-temp-file-mode 384 ; u=rw only
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 "*Mode for Emerge temporary files.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (defvar emerge-combine-versions-template
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 "#ifdef NEW\n%b#else /* NEW */\n%a#endif /* NEW */\n"
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
270 "*Template for `emerge-combine-versions' to combine the two versions.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 The template is inserted as a string, with the following interpolations:
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 %a the A version of the difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 %b the B version of the difference
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
274 %% the character `%'
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 Don't forget to end the template with a newline.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 Note that this variable can be made local to a particular merge buffer by
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
277 giving a prefix argument to `emerge-set-combine-versions-template'.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 ;; Build keymaps
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 (defvar emerge-basic-keymap nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 "Keymap of Emerge commands.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
283 Directly available in `fast' mode;
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
284 must be prefixed by \\<emerge-fast-keymap>\\[emerge-basic-keymap] in `edit' mode.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (defvar emerge-fast-keymap nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
287 "Local keymap used in Emerge `fast' mode.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 Makes Emerge commands directly available.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
290 (defvar emerge-options-menu
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
291 (make-sparse-keymap "Options"))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
292
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
293 (defvar emerge-merge-menu
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
294 (make-sparse-keymap "Merge"))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
295
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
296 (defvar emerge-move-menu
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
297 (make-sparse-keymap "Move"))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
298
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
299 (defvar emerge-command-prefix "\C-c\C-c"
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
300 "*Command prefix for Emerge commands in `edit' mode.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 Must be set before Emerge is loaded.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 ;; This function sets up the fixed keymaps. It is executed when the first
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 ;; Emerge is done to allow the user maximum time to set up the global keymap.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (defun emerge-setup-fixed-keymaps ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 ;; Set up the basic keymap
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 (setq emerge-basic-keymap (make-keymap))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 (suppress-keymap emerge-basic-keymap) ; this sets 0..9 to digit-argument and
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 ; - to negative-argument
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (define-key emerge-basic-keymap "p" 'emerge-previous-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (define-key emerge-basic-keymap "n" 'emerge-next-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (define-key emerge-basic-keymap "a" 'emerge-select-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (define-key emerge-basic-keymap "b" 'emerge-select-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (define-key emerge-basic-keymap "j" 'emerge-jump-to-difference)
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
315 (define-key emerge-basic-keymap "." 'emerge-find-difference)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (define-key emerge-basic-keymap "q" 'emerge-quit)
2772
9dba5812b3ff (emerge-setup-fixed-keymaps): Put emerge-abort on C-].
Richard M. Stallman <rms@gnu.org>
parents: 2771
diff changeset
317 (define-key emerge-basic-keymap "\C-]" 'emerge-abort)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 (define-key emerge-basic-keymap "f" 'emerge-fast-mode)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (define-key emerge-basic-keymap "e" 'emerge-edit-mode)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (define-key emerge-basic-keymap "s" nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (define-key emerge-basic-keymap "sa" 'emerge-auto-advance)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (define-key emerge-basic-keymap "ss" 'emerge-skip-prefers)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (define-key emerge-basic-keymap "l" 'emerge-recenter)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (define-key emerge-basic-keymap "d" nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (define-key emerge-basic-keymap "da" 'emerge-default-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 (define-key emerge-basic-keymap "db" 'emerge-default-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (define-key emerge-basic-keymap "c" nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (define-key emerge-basic-keymap "ca" 'emerge-copy-as-kill-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (define-key emerge-basic-keymap "cb" 'emerge-copy-as-kill-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (define-key emerge-basic-keymap "i" nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (define-key emerge-basic-keymap "ia" 'emerge-insert-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 (define-key emerge-basic-keymap "ib" 'emerge-insert-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 (define-key emerge-basic-keymap "m" 'emerge-mark-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (define-key emerge-basic-keymap "v" 'emerge-scroll-up)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (define-key emerge-basic-keymap "^" 'emerge-scroll-down)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (define-key emerge-basic-keymap "<" 'emerge-scroll-left)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (define-key emerge-basic-keymap ">" 'emerge-scroll-right)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (define-key emerge-basic-keymap "|" 'emerge-scroll-reset)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (define-key emerge-basic-keymap "x" nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 (define-key emerge-basic-keymap "x1" 'emerge-one-line-window)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (define-key emerge-basic-keymap "xc" 'emerge-combine-versions)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (define-key emerge-basic-keymap "xC" 'emerge-combine-versions-register)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (define-key emerge-basic-keymap "xf" 'emerge-file-names)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (define-key emerge-basic-keymap "xj" 'emerge-join-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (define-key emerge-basic-keymap "xl" 'emerge-line-numbers)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 (define-key emerge-basic-keymap "xm" 'emerge-set-merge-mode)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 (define-key emerge-basic-keymap "xs" 'emerge-split-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (define-key emerge-basic-keymap "xt" 'emerge-trim-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (define-key emerge-basic-keymap "xx" 'emerge-set-combine-versions-template)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 ;; Allow emerge-basic-keymap to be referenced indirectly
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (fset 'emerge-basic-keymap emerge-basic-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 ;; Set up the fast mode keymap
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (setq emerge-fast-keymap (copy-keymap emerge-basic-keymap))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 ;; Allow prefixed commands to work in fast mode
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 (define-key emerge-fast-keymap emerge-command-prefix 'emerge-basic-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 ;; Allow emerge-fast-keymap to be referenced indirectly
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 (fset 'emerge-fast-keymap emerge-fast-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 ;; Suppress write-file and save-buffer
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
359 (substitute-key-definition 'write-file 'emerge-query-write-file
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
360 emerge-fast-keymap (current-global-map))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
361 (substitute-key-definition 'save-buffer 'emerge-query-save-buffer
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
362 emerge-fast-keymap (current-global-map))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
363
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
364 (define-key emerge-basic-keymap [menu-bar] (make-sparse-keymap))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
365
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
366 (define-key emerge-fast-keymap [menu-bar options]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
367 (cons "Options" emerge-options-menu))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
368 (define-key emerge-fast-keymap [menu-bar merge]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
369 (cons "Merge" emerge-merge-menu))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
370 (define-key emerge-fast-keymap [menu-bar move]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
371 (cons "Move" emerge-move-menu))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
372
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
373 (define-key emerge-move-menu [emerge-scroll-reset]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
374 '("Scroll Reset" . emerge-scroll-reset))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
375 (define-key emerge-move-menu [emerge-scroll-right]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
376 '("Scroll Right" . emerge-scroll-right))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
377 (define-key emerge-move-menu [emerge-scroll-left]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
378 '("Scroll Left" . emerge-scroll-left))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
379 (define-key emerge-move-menu [emerge-scroll-down]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
380 '("Scroll Down" . emerge-scroll-down))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
381 (define-key emerge-move-menu [emerge-scroll-up]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
382 '("Scroll Up" . emerge-scroll-up))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
383 (define-key emerge-move-menu [emerge-recenter]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
384 '("Recenter" . emerge-recenter))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
385 (define-key emerge-move-menu [emerge-mark-difference]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
386 '("Mark Difference" . emerge-mark-difference))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
387 (define-key emerge-move-menu [emerge-jump-to-difference]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
388 '("Jump To Difference" . emerge-jump-to-difference))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
389 (define-key emerge-move-menu [emerge-find-difference]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
390 '("Find Difference" . emerge-find-difference))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
391 (define-key emerge-move-menu [emerge-previous-difference]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
392 '("Previous Difference" . emerge-previous-difference))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
393 (define-key emerge-move-menu [emerge-next-difference]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
394 '("Next Difference" . emerge-next-difference))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
395
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
396
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
397 (define-key emerge-options-menu [emerge-one-line-window]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
398 '("One Line Window" . emerge-one-line-window))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
399 (define-key emerge-options-menu [emerge-set-merge-mode]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
400 '("Set Merge Mode" . emerge-set-merge-mode))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
401 (define-key emerge-options-menu [emerge-set-combine-template]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
402 '("Set Combine Template..." . emerge-set-combine-template))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
403 (define-key emerge-options-menu [emerge-default-B]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
404 '("Default B" . emerge-default-B))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
405 (define-key emerge-options-menu [emerge-default-A]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
406 '("Default A" . emerge-default-A))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
407 (define-key emerge-options-menu [emerge-skip-prefers]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
408 '("Skip Prefers" . emerge-skip-prefers))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
409 (define-key emerge-options-menu [emerge-auto-advance]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
410 '("Auto Advance" . emerge-auto-advance))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
411 (define-key emerge-options-menu [emerge-edit-mode]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
412 '("Edit Mode" . emerge-edit-mode))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
413 (define-key emerge-options-menu [emerge-fast-mode]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
414 '("Fast Mode" . emerge-fast-mode))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
415
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
416 (define-key emerge-merge-menu [emerge-abort] '("Abort" . emerge-abort))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
417 (define-key emerge-merge-menu [emerge-quit] '("Quit" . emerge-quit))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
418 (define-key emerge-merge-menu [emerge-split-difference]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
419 '("Split Difference" . emerge-split-difference))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
420 (define-key emerge-merge-menu [emerge-join-differences]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
421 '("Join Differences" . emerge-join-differences))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
422 (define-key emerge-merge-menu [emerge-trim-difference]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
423 '("Trim Difference" . emerge-trim-difference))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
424 (define-key emerge-merge-menu [emerge-combine-versions]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
425 '("Combine Versions" . emerge-combine-versions))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
426 (define-key emerge-merge-menu [emerge-copy-as-kill-B]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
427 '("Copy B as Kill" . emerge-copy-as-kill-B))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
428 (define-key emerge-merge-menu [emerge-copy-as-kill-A]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
429 '("Copy A as Kill" . emerge-copy-as-kill-A))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
430 (define-key emerge-merge-menu [emerge-insert-B]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
431 '("Insert B" . emerge-insert-B))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
432 (define-key emerge-merge-menu [emerge-insert-A]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
433 '("Insert A" . emerge-insert-A))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
434 (define-key emerge-merge-menu [emerge-select-B]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
435 '("Select B" . emerge-select-B))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
436 (define-key emerge-merge-menu [emerge-select-A]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
437 '("Select A" . emerge-select-A)))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
438
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 ;; Variables which control each merge. They are local to the merge buffer.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 ;; Mode variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 (emerge-defvar-local emerge-mode nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 "Indicator for emerge-mode.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (emerge-defvar-local emerge-fast-mode nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 "Indicator for emerge-mode fast submode.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (emerge-defvar-local emerge-edit-mode nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 "Indicator for emerge-mode edit submode.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 (emerge-defvar-local emerge-A-buffer nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 "The buffer in which the A variant is stored.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (emerge-defvar-local emerge-B-buffer nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 "The buffer in which the B variant is stored.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (emerge-defvar-local emerge-merge-buffer nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 "The buffer in which the merged file is manipulated.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (emerge-defvar-local emerge-ancestor-buffer nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 "The buffer in which the ancestor variant is stored,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 or nil if there is none.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (defconst emerge-saved-variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 '((buffer-modified-p set-buffer-modified-p)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 buffer-read-only
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 buffer-auto-save-file-name)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 "Variables and properties of a buffer which are saved, modified and restored
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 during a merge.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 (defconst emerge-merging-values '(nil t nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 "Values to be assigned to emerge-saved-variables during a merge.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 (emerge-defvar-local emerge-A-buffer-values nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 "Remembers emerge-saved-variables for emerge-A-buffer.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 (emerge-defvar-local emerge-B-buffer-values nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 "Remembers emerge-saved-variables for emerge-B-buffer.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 (emerge-defvar-local emerge-difference-list nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 "Vector of differences between the variants, and markers in the buffers to
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 show where they are. Each difference is represented by a vector of seven
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 elements. The first two are markers to the beginning and end of the difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 section in the A buffer, the second two are markers for the B buffer, the third
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 two are markers for the merge buffer, and the last element is the \"state\" of
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 that difference in the merge buffer.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 A section of a buffer is described by two markers, one to the beginning of
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 the first line of the section, and one to the beginning of the first line
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 after the section. (If the section is empty, both markers point to the same
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 point.) If the section is part of the selected difference, then the markers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 are moved into the flags, so the user can edit the section without disturbing
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 the markers.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 The \"states\" are:
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 A the merge buffer currently contains the A variant
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 B the merge buffer currently contains the B variant
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 default-A the merge buffer contains the A variant by default,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 but this difference hasn't been selected yet, so
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 change-default commands can alter it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 default-B the merge buffer contains the B variant by default,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 but this difference hasn't been selected yet, so
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 change-default commands can alter it
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2773
diff changeset
495 prefer-A in a three-file merge, the A variant is the preferred
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 choice
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2773
diff changeset
497 prefer-B in a three-file merge, the B variant is the preferred
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 choice")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 (emerge-defvar-local emerge-current-difference -1
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 "The difference that is currently selected.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 (emerge-defvar-local emerge-number-of-differences nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 "Number of differences found.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 (emerge-defvar-local emerge-edit-keymap nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 "The local keymap for the merge buffer, with the emerge commands defined in
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 it. Used to save the local keymap during fast mode, when the local keymap is
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 replaced by emerge-fast-keymap.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 (emerge-defvar-local emerge-old-keymap nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 "The original local keymap for the merge buffer.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 (emerge-defvar-local emerge-auto-advance nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 "*If non-nil, emerge-select-A and emerge-select-B automatically advance to
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 the next difference.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 (emerge-defvar-local emerge-skip-prefers nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 "*If non-nil, differences for which there is a preference are automatically
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 skipped.")
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
515 (emerge-defvar-local emerge-quit-hook nil
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 "Hooks to run in the merge buffer after the merge has been finished.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
517 `emerge-prefix-argument' will hold the prefix argument of the `emerge-quit'
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 command.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
519 This is *not* a user option, since Emerge uses it for its own processing.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 (emerge-defvar-local emerge-output-description nil
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
521 "Describes output destination of emerge, for `emerge-file-names'.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 ;;; Setup functions for two-file mode.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 (defun emerge-files-internal (file-A file-B &optional startup-hooks quit-hooks
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 output-file)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
527 (if (not (file-readable-p file-A))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
528 (error "File `%s' does not exist or is not readable" file-A))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
529 (if (not (file-readable-p file-B))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
530 (error "File `%s' does not exist or is not readable" file-B))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 (let ((buffer-A (find-file-noselect file-A))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 (buffer-B (find-file-noselect file-B)))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
533 ;; Record the directories of the files
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
534 (setq emerge-last-dir-A (file-name-directory file-A))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
535 (setq emerge-last-dir-B (file-name-directory file-B))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
536 (if output-file
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
537 (setq emerge-last-dir-output (file-name-directory output-file)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538 ;; Make sure the entire files are seen, and they reflect what is on disk
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
539 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
540 buffer-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
541 (widen)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
542 (let ((temp (file-local-copy file-A)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
543 (if temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
544 (setq file-A temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
545 startup-hooks
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
546 (cons (` (lambda () (delete-file (, file-A))))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
547 startup-hooks))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
548 ;; Verify that the file matches the buffer
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
549 (emerge-verify-file-buffer))))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
550 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
551 buffer-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
552 (widen)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
553 (let ((temp (file-local-copy file-B)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
554 (if temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
555 (setq file-B temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
556 startup-hooks
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
557 (cons (` (lambda () (delete-file (, file-B))))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
558 startup-hooks))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
559 ;; Verify that the file matches the buffer
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
560 (emerge-verify-file-buffer))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (emerge-setup buffer-A file-A buffer-B file-B startup-hooks quit-hooks
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 output-file)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 ;; Start up Emerge on two files
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 (defun emerge-setup (buffer-A file-A buffer-B file-B startup-hooks quit-hooks
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 output-file)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 (setq file-A (expand-file-name file-A))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 (setq file-B (expand-file-name file-B))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 (setq output-file (and output-file (expand-file-name output-file)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 (let* ((merge-buffer-name (emerge-unique-buffer-name "*merge" "*"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 ;; create the merge buffer from buffer A, so it inherits buffer A's
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 ;; default directory, etc.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (merge-buffer (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 buffer-A
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 (get-buffer-create merge-buffer-name))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 merge-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 (emerge-copy-modes buffer-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 (setq buffer-read-only nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 (auto-save-mode 1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 (setq emerge-mode t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (setq emerge-A-buffer buffer-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 (setq emerge-B-buffer buffer-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 (setq emerge-ancestor-buffer nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (setq emerge-merge-buffer merge-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (setq emerge-output-description
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 (if output-file
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 (concat "Output to file: " output-file)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 (concat "Output to buffer: " (buffer-name merge-buffer))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 (insert-buffer emerge-A-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 (emerge-set-keys)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 (setq emerge-difference-list (emerge-make-diff-list file-A file-B))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 (setq emerge-number-of-differences (length emerge-difference-list))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (setq emerge-current-difference -1)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
595 (setq emerge-quit-hook quit-hooks)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
596 (emerge-remember-buffer-characteristics)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
597 (emerge-handle-local-variables))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 (emerge-setup-windows buffer-A buffer-B merge-buffer t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 (emerge-eval-in-buffer merge-buffer
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
600 (run-hooks 'startup-hooks 'emerge-startup-hook)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 (setq buffer-read-only t))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 ;; Generate the Emerge difference list between two files
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 (defun emerge-make-diff-list (file-A file-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 (setq emerge-diff-buffer (get-buffer-create "*emerge-diff*"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 emerge-diff-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 (erase-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (shell-command
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 (format "%s %s %s %s"
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
611 emerge-diff-program emerge-diff-options
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
612 (emerge-protect-metachars file-A)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
613 (emerge-protect-metachars file-B))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 t))
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
615 (emerge-prepare-error-list emerge-diff-ok-lines-regexp)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 (emerge-convert-diffs-to-markers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 emerge-A-buffer emerge-B-buffer emerge-merge-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 (emerge-extract-diffs emerge-diff-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 (defun emerge-extract-diffs (diff-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 (let (list)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 diff-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 (goto-char (point-min))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 (while (re-search-forward emerge-match-diff-line nil t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 (let* ((a-begin (string-to-int (buffer-substring (match-beginning 1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 (match-end 1))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 (a-end (let ((b (match-beginning 3))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 (e (match-end 3)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 (if b
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 (string-to-int (buffer-substring b e))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 a-begin)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 (diff-type (buffer-substring (match-beginning 4) (match-end 4)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634 (b-begin (string-to-int (buffer-substring (match-beginning 5)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 (match-end 5))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 (b-end (let ((b (match-beginning 7))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 (e (match-end 7)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 (if b
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 (string-to-int (buffer-substring b e))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 b-begin))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 ;; fix the beginning and end numbers, because diff is somewhat
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 ;; strange about how it numbers lines
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 (if (string-equal diff-type "a")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 (setq b-end (1+ b-end))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 (setq a-begin (1+ a-begin))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 (setq a-end a-begin))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 (if (string-equal diff-type "d")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 (setq a-end (1+ a-end))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 (setq b-begin (1+ b-begin))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 (setq b-end b-begin))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 ;; (string-equal diff-type "c")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 (setq a-end (1+ a-end))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 (setq b-end (1+ b-end)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 (setq list (cons (vector a-begin a-end
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 b-begin b-end
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 'default-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 list)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 (nreverse list)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 ;; Set up buffer of diff/diff3 error messages.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 (defun emerge-prepare-error-list (ok-regexp)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 (setq emerge-diff-error-buffer (get-buffer-create "*emerge-diff-errors*"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 emerge-diff-error-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 (erase-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 (insert-buffer emerge-diff-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 (delete-matching-lines ok-regexp)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 ;;; Top-level and setup functions for three-file mode.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 (defun emerge-files-with-ancestor-internal (file-A file-B file-ancestor
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
675 &optional startup-hooks quit-hooks
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
676 output-file)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
677 (if (not (file-readable-p file-A))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
678 (error "File `%s' does not exist or is not readable" file-A))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
679 (if (not (file-readable-p file-B))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
680 (error "File `%s' does not exist or is not readable" file-B))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
681 (if (not (file-readable-p file-ancestor))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
682 (error "File `%s' does not exist or is not readable" file-ancestor))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 (let ((buffer-A (find-file-noselect file-A))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
684 (buffer-B (find-file-noselect file-B))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
685 (buffer-ancestor (find-file-noselect file-ancestor)))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
686 ;; Record the directories of the files
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
687 (setq emerge-last-dir-A (file-name-directory file-A))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
688 (setq emerge-last-dir-B (file-name-directory file-B))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
689 (setq emerge-last-dir-ancestor (file-name-directory file-ancestor))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
690 (if output-file
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
691 (setq emerge-last-dir-output (file-name-directory output-file)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 ;; Make sure the entire files are seen, and they reflect what is on disk
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
693 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
694 buffer-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
695 (widen)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
696 (let ((temp (file-local-copy file-A)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
697 (if temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
698 (setq file-A temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
699 startup-hooks
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
700 (cons (` (lambda () (delete-file (, file-A))))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
701 startup-hooks))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
702 ;; Verify that the file matches the buffer
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
703 (emerge-verify-file-buffer))))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
704 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
705 buffer-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
706 (widen)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
707 (let ((temp (file-local-copy file-B)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
708 (if temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
709 (setq file-B temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
710 startup-hooks
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
711 (cons (` (lambda () (delete-file (, file-B))))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
712 startup-hooks))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
713 ;; Verify that the file matches the buffer
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
714 (emerge-verify-file-buffer))))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
715 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
716 buffer-ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
717 (widen)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
718 (let ((temp (file-local-copy file-ancestor)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
719 (if temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
720 (setq file-ancestor temp
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
721 startup-hooks
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
722 (cons (` (lambda () (delete-file (, file-ancestor))))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
723 startup-hooks))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
724 ;; Verify that the file matches the buffer
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
725 (emerge-verify-file-buffer))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
726 (emerge-setup-with-ancestor buffer-A file-A buffer-B file-B
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
727 buffer-ancestor file-ancestor
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
728 startup-hooks quit-hooks output-file)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
729
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
730 ;; Start up Emerge on two files with an ancestor
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
731 (defun emerge-setup-with-ancestor (buffer-A file-A buffer-B file-B
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
732 buffer-ancestor file-ancestor
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 &optional startup-hooks quit-hooks
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 output-file)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 (setq file-A (expand-file-name file-A))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 (setq file-B (expand-file-name file-B))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 (setq file-ancestor (expand-file-name file-ancestor))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 (setq output-file (and output-file (expand-file-name output-file)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 (let* ((merge-buffer-name (emerge-unique-buffer-name "*merge" "*"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
740 ;; create the merge buffer from buffer A, so it inherits buffer A's
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
741 ;; default directory, etc.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 (merge-buffer (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
743 buffer-A
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
744 (get-buffer-create merge-buffer-name))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
746 merge-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 (emerge-copy-modes buffer-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
748 (setq buffer-read-only nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
749 (auto-save-mode 1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
750 (setq emerge-mode t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
751 (setq emerge-A-buffer buffer-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
752 (setq emerge-B-buffer buffer-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 (setq emerge-ancestor-buffer buffer-ancestor)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754 (setq emerge-merge-buffer merge-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
755 (setq emerge-output-description
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
756 (if output-file
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
757 (concat "Output to file: " output-file)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
758 (concat "Output to buffer: " (buffer-name merge-buffer))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
759 (insert-buffer emerge-A-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
760 (emerge-set-keys)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
761 (setq emerge-difference-list
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
762 (emerge-make-diff3-list file-A file-B file-ancestor))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
763 (setq emerge-number-of-differences (length emerge-difference-list))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 (setq emerge-current-difference -1)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
765 (setq emerge-quit-hook quit-hooks)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 (emerge-remember-buffer-characteristics)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
767 (emerge-select-prefer-Bs)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
768 (emerge-handle-local-variables))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 (emerge-setup-windows buffer-A buffer-B merge-buffer t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770 (emerge-eval-in-buffer merge-buffer
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
771 (run-hooks 'startup-hooks 'emerge-startup-hook)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 (setq buffer-read-only t))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
773
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 ;; Generate the Emerge difference list between two files with an ancestor
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
775 (defun emerge-make-diff3-list (file-A file-B file-ancestor)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 (setq emerge-diff-buffer (get-buffer-create "*emerge-diff*"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778 emerge-diff-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
779 (erase-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 (shell-command
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
781 (format "%s %s %s %s %s"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
782 emerge-diff3-program emerge-diff-options
3732
60292a8697bc (emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
783 (emerge-protect-metachars file-A)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
784 (emerge-protect-metachars file-ancestor)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
785 (emerge-protect-metachars file-B))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
786 t))
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
787 (emerge-prepare-error-list emerge-diff3-ok-lines-regexp)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 (emerge-convert-diffs-to-markers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 emerge-A-buffer emerge-B-buffer emerge-merge-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
790 (emerge-extract-diffs3 emerge-diff-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
791
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
792 (defun emerge-extract-diffs3 (diff-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
793 (let (list)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 diff-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
796 (while (re-search-forward "^====\\(.?\\)$" nil t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
797 ;; leave point after matched line
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
798 (beginning-of-line 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
799 (let ((agreement (buffer-substring (match-beginning 1) (match-end 1))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
800 ;; if the A and B files are the same, ignore the difference
3732
60292a8697bc (emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
801 (if (not (string-equal agreement "2"))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802 (setq list
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
803 (cons
3732
60292a8697bc (emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
804 (let (group-1 group-3 pos)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
805 (setq pos (point))
3732
60292a8697bc (emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
806 (setq group-1 (emerge-get-diff3-group "1"))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
807 (goto-char pos)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
808 (setq group-3 (emerge-get-diff3-group "3"))
3732
60292a8697bc (emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
809 (vector (car group-1) (car (cdr group-1))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
810 (car group-3) (car (cdr group-3))
3732
60292a8697bc (emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
811 (cond ((string-equal agreement "1") 'prefer-A)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
812 ((string-equal agreement "3") 'prefer-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 (t 'default-A))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 list))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
815 (nreverse list)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
817 (defun emerge-get-diff3-group (file)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818 ;; This save-excursion allows emerge-get-diff3-group to be called for the
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
819 ;; various groups of lines (1, 2, 3) in any order, and for the lines to
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
820 ;; appear in any order. The reason this is necessary is that Gnu diff3
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821 ;; can produce the groups in the order 1, 2, 3 or 1, 3, 2.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
822 (save-excursion
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
823 (re-search-forward
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
824 (concat "^" file ":\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\\([ac]\\)$"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
825 (beginning-of-line 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826 ;; treatment depends on whether it is an "a" group or a "c" group
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
827 (if (string-equal (buffer-substring (match-beginning 4) (match-end 4)) "c")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
828 ;; it is a "c" group
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
829 (if (match-beginning 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
830 ;; it has two numbers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
831 (list (string-to-int
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
832 (buffer-substring (match-beginning 1) (match-end 1)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
833 (1+ (string-to-int
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
834 (buffer-substring (match-beginning 3) (match-end 3)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835 ;; it has one number
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836 (let ((x (string-to-int
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837 (buffer-substring (match-beginning 1) (match-end 1)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
838 (list x (1+ x))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
839 ;; it is an "a" group
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
840 (let ((x (1+ (string-to-int
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
841 (buffer-substring (match-beginning 1) (match-end 1))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
842 (list x x)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
843
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
844 ;;; Functions to start Emerge on files
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
845
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
846 ;;;###autoload
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 (defun emerge-files (arg file-A file-B file-out &optional startup-hooks
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
848 quit-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
849 "Run Emerge on two files."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850 (interactive
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
851 (let (f)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
852 (list current-prefix-arg
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
853 (setq f (emerge-read-file-name "File A to merge" emerge-last-dir-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
854 nil nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
855 (emerge-read-file-name "File B to merge" emerge-last-dir-B nil f)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
856 (and current-prefix-arg
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
857 (emerge-read-file-name "Output file" emerge-last-dir-output
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
858 f f)))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859 (emerge-files-internal
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
860 file-A file-B startup-hooks
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
861 (if file-out
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
862 (cons (` (lambda () (emerge-files-exit (, file-out))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
863 quit-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
864 quit-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
865 file-out))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
866
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
867 ;;;###autoload
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
868 (defun emerge-files-with-ancestor (arg file-A file-B file-ancestor file-out
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
869 &optional startup-hooks quit-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
870 "Run Emerge on two files, giving another file as the ancestor."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
871 (interactive
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872 (let (f)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 (list current-prefix-arg
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
874 (setq f (emerge-read-file-name "File A to merge" emerge-last-dir-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
875 nil nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
876 (emerge-read-file-name "File B to merge" emerge-last-dir-B nil f)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
877 (emerge-read-file-name "Ancestor file" emerge-last-dir-ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
878 nil f)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
879 (and current-prefix-arg
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
880 (emerge-read-file-name "Output file" emerge-last-dir-output
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
881 f f)))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
882 (emerge-files-with-ancestor-internal
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 file-A file-B file-ancestor startup-hooks
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
884 (if file-out
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
885 (cons (` (lambda () (emerge-files-exit (, file-out))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
886 quit-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887 quit-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888 file-out))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890 ;; Write the merge buffer out in place of the file the A buffer is visiting.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
891 (defun emerge-files-exit (file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
892 ;; if merge was successful was given, save to disk
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 (if (not emerge-prefix-argument)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
894 (emerge-write-and-delete file-out)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
896 ;;; Functions to start Emerge on buffers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
897
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
898 ;;;###autoload
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 (defun emerge-buffers (buffer-A buffer-B &optional startup-hooks quit-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 "Run Emerge on two buffers."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 (interactive "bBuffer A to merge: \nbBuffer B to merge: ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 (let ((emerge-file-A (emerge-make-temp-file "A"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 (emerge-file-B (emerge-make-temp-file "B")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
904 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
905 buffer-A
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
906 (write-region (point-min) (point-max) emerge-file-A nil 'no-message))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
907 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908 buffer-B
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 (write-region (point-min) (point-max) emerge-file-B nil 'no-message))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 (emerge-setup (get-buffer buffer-A) emerge-file-A
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 (get-buffer buffer-B) emerge-file-B
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
912 (cons (` (lambda ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
913 (delete-file (, emerge-file-A))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
914 (delete-file (, emerge-file-B))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915 startup-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916 quit-hooks
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 nil)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
919 ;;;###autoload
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 (defun emerge-buffers-with-ancestor (buffer-A buffer-B buffer-ancestor
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921 &optional startup-hooks
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
922 quit-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923 "Run Emerge on two buffers, giving another buffer as the ancestor."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
924 (interactive
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
925 "bBuffer A to merge: \nbBuffer B to merge: \nbAncestor buffer: ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
926 (let ((emerge-file-A (emerge-make-temp-file "A"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
927 (emerge-file-B (emerge-make-temp-file "B"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928 (emerge-file-ancestor (emerge-make-temp-file "anc")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
930 buffer-A
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 (write-region (point-min) (point-max) emerge-file-A nil 'no-message))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933 buffer-B
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 (write-region (point-min) (point-max) emerge-file-B nil 'no-message))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 buffer-ancestor
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
937 (write-region (point-min) (point-max) emerge-file-ancestor nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 'no-message))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
939 (emerge-setup-with-ancestor (get-buffer buffer-A) emerge-file-A
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940 (get-buffer buffer-B) emerge-file-B
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
941 (get-buffer buffer-ancestor)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942 emerge-file-ancestor
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
943 (cons (` (lambda ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
944 (delete-file (, emerge-file-A))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
945 (delete-file (, emerge-file-B))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
946 (delete-file
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
947 (, emerge-file-ancestor))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948 startup-hooks)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949 quit-hooks
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
950 nil)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
951
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952 ;;; Functions to start Emerge from the command line
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
953
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
954 ;;;###autoload
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
955 (defun emerge-files-command ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
956 (let ((file-a (nth 0 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
957 (file-b (nth 1 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
958 (file-out (nth 2 command-line-args-left)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
959 (setq command-line-args-left (nthcdr 3 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960 (emerge-files-internal
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 file-a file-b nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
962 (list (` (lambda () (emerge-command-exit (, file-out))))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
964 ;;;###autoload
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
965 (defun emerge-files-with-ancestor-command ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
966 (let (file-a file-b file-anc file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
967 ;; check for a -a flag, for filemerge compatibility
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
968 (if (string= (car command-line-args-left) "-a")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
969 ;; arguments are "-a ancestor file-a file-b file-out"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 (setq file-a (nth 2 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
972 (setq file-b (nth 3 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973 (setq file-anc (nth 1 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 (setq file-out (nth 4 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
975 (setq command-line-args-left (nthcdr 5 command-line-args-left)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
976 ;; arguments are "file-a file-b ancestor file-out"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
977 (setq file-a (nth 0 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
978 (setq file-b (nth 1 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
979 (setq file-anc (nth 2 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 (setq file-out (nth 3 command-line-args-left))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 (setq command-line-args-left (nthcdr 4 command-line-args-left)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 (emerge-files-with-ancestor-internal
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983 file-a file-b file-anc nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984 (list (` (lambda () (emerge-command-exit (, file-out))))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
985
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
986 (defun emerge-command-exit (file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
987 (emerge-write-and-delete file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
988 (kill-emacs (if emerge-prefix-argument 1 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
989
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
990 ;;; Functions to start Emerge via remote request
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
991
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
992 ;;;###autoload
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
993 (defun emerge-files-remote (file-a file-b file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
994 (setq emerge-file-out file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
995 (emerge-files-internal
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
996 file-a file-b nil
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
997 (list (` (lambda () (emerge-remote-exit (, file-out) '(, emerge-exit-func)))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
998 file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
999 (throw 'client-wait nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1000
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1001 ;;;###autoload
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1002 (defun emerge-files-with-ancestor-remote (file-a file-b file-anc file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1003 (setq emerge-file-out file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004 (emerge-files-with-ancestor-internal
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1005 file-a file-b file-anc nil
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1006 (list (` (lambda () (emerge-remote-exit (, file-out) '(, emerge-exit-func)))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1007 file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1008 (throw 'client-wait nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1009
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1010 (defun emerge-remote-exit (file-out emerge-exit-func)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1011 (emerge-write-and-delete file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1012 (kill-buffer emerge-merge-buffer)
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1013 (funcall emerge-exit-func (if emerge-prefix-argument 1 0)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1014
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1015 ;;; Functions to start Emerge on RCS versions
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1016
6286
676773222f1f (emerge-revisions, emerge-revisions-with-ancestor)
Richard M. Stallman <rms@gnu.org>
parents: 6281
diff changeset
1017 ;;;###autoload
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1018 (defun emerge-revisions (arg file revision-A revision-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1019 &optional startup-hooks quit-hooks)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1020 "Emerge two RCS revisions of a file."
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1021 (interactive
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1022 (list current-prefix-arg
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1023 (read-file-name "File to merge: " nil nil 'confirm)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1024 (read-string "Revision A to merge: " emerge-last-revision-A)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1025 (read-string "Revision B to merge: " emerge-last-revision-B)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1026 (setq emerge-last-revision-A revision-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1027 emerge-last-revision-B revision-B)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1028 (emerge-revisions-internal
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1029 file revision-A revision-B startup-hooks
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1030 (if arg
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1031 (cons (` (lambda ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1032 (shell-command
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1033 (, (format "%s %s" emerge-rcs-ci-program file)))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1034 quit-hooks)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1035 quit-hooks)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1036
6286
676773222f1f (emerge-revisions, emerge-revisions-with-ancestor)
Richard M. Stallman <rms@gnu.org>
parents: 6281
diff changeset
1037 ;;;###autoload
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1038 (defun emerge-revisions-with-ancestor (arg file revision-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1039 revision-B ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1040 &optional
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1041 startup-hooks quit-hooks)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1042 "Emerge two RCS revisions of a file, with another revision as ancestor."
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1043 (interactive
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1044 (list current-prefix-arg
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1045 (read-file-name "File to merge: " nil nil 'confirm)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1046 (read-string "Revision A to merge: " emerge-last-revision-A)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1047 (read-string "Revision B to merge: " emerge-last-revision-B)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1048 (read-string "Ancestor: " emerge-last-revision-ancestor)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1049 (setq emerge-last-revision-A revision-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1050 emerge-last-revision-B revision-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1051 emerge-last-revision-ancestor ancestor)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1052 (emerge-revision-with-ancestor-internal
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1053 file revision-A revision-B ancestor startup-hooks
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1054 (if arg
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1055 (let ((cmd ))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1056 (cons (` (lambda ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1057 (shell-command
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1058 (, (format "%s %s" emerge-rcs-ci-program file)))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1059 quit-hooks))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1060 quit-hooks)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1061
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1062 (defun emerge-revisions-internal (file revision-A revision-B &optional
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1063 startup-hooks quit-hooks output-file)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1064 (let ((buffer-A (get-buffer-create (format "%s,%s" file revision-A)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1065 (buffer-B (get-buffer-create (format "%s,%s" file revision-B)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1066 (emerge-file-A (emerge-make-temp-file "A"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1067 (emerge-file-B (emerge-make-temp-file "B")))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1068 ;; Get the revisions into buffers
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1069 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1070 buffer-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1071 (erase-buffer)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1072 (shell-command
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1073 (format "%s -q -p%s %s" emerge-rcs-co-program revision-A file)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1074 t)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1075 (write-region (point-min) (point-max) emerge-file-A nil 'no-message)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1076 (set-buffer-modified-p nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1077 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1078 buffer-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1079 (erase-buffer)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1080 (shell-command
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1081 (format "%s -q -p%s %s" emerge-rcs-co-program revision-B file)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1082 t)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1083 (write-region (point-min) (point-max) emerge-file-B nil 'no-message)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1084 (set-buffer-modified-p nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1085 ;; Do the merge
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1086 (emerge-setup buffer-A emerge-file-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1087 buffer-B emerge-file-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1088 (cons (` (lambda ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1089 (delete-file (, emerge-file-A))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1090 (delete-file (, emerge-file-B))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1091 startup-hooks)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1092 (cons (` (lambda () (emerge-files-exit (, file))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1093 quit-hooks)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1094 nil)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1095
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1096 (defun emerge-revision-with-ancestor-internal (file revision-A revision-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1097 ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1098 &optional startup-hooks
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1099 quit-hooks output-file)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1100 (let ((buffer-A (get-buffer-create (format "%s,%s" file revision-A)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1101 (buffer-B (get-buffer-create (format "%s,%s" file revision-B)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1102 (buffer-ancestor (get-buffer-create (format "%s,%s" file ancestor)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1103 (emerge-file-A (emerge-make-temp-file "A"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1104 (emerge-file-B (emerge-make-temp-file "B"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1105 (emerge-ancestor (emerge-make-temp-file "ancestor")))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1106 ;; Get the revisions into buffers
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1107 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1108 buffer-A
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1109 (erase-buffer)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1110 (shell-command
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1111 (format "%s -q -p%s %s" emerge-rcs-co-program
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1112 revision-A file)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1113 t)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1114 (write-region (point-min) (point-max) emerge-file-A nil 'no-message)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1115 (set-buffer-modified-p nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1116 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1117 buffer-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1118 (erase-buffer)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1119 (shell-command
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1120 (format "%s -q -p%s %s" emerge-rcs-co-program revision-B file)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1121 t)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1122 (write-region (point-min) (point-max) emerge-file-B nil 'no-message)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1123 (set-buffer-modified-p nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1124 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1125 buffer-ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1126 (erase-buffer)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1127 (shell-command
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1128 (format "%s -q -p%s %s" emerge-rcs-co-program ancestor file)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1129 t)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1130 (write-region (point-min) (point-max) emerge-ancestor nil 'no-message)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1131 (set-buffer-modified-p nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1132 ;; Do the merge
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1133 (emerge-setup-with-ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1134 buffer-A emerge-file-A buffer-B emerge-file-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1135 buffer-ancestor emerge-ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1136 (cons (` (lambda ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1137 (delete-file (, emerge-file-A))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1138 (delete-file (, emerge-file-B))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1139 (delete-file (, emerge-ancestor))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1140 startup-hooks)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1141 (cons (` (lambda () (emerge-files-exit (, file))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1142 quit-hooks)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1143 output-file)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1144
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1145 ;;; Function to start Emerge based on a line in a file
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1146
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1147 (defun emerge-execute-line ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1148 "Run Emerge using files named in current text line.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1149 Looks in that line for whitespace-separated entries of these forms:
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1150 a=file1
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1151 b=file2
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1152 ancestor=file3
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1153 output=file4
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1154 to specify the files to use in Emerge.
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1155
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1156 In addition, if only one of `a=file' or `b=file' is present, and `output=file'
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1157 is present:
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1158 If `emerge-execute-line-deletions' is non-nil and `ancestor=file' is present,
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1159 it is assumed that the file in question has been deleted, and it is
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1160 not copied to the output file.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1161 Otherwise, the A or B file present is copied to the output file."
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1162 (interactive)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1163 (let (file-A file-B file-ancestor file-out
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1164 (case-fold-search t))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1165 ;; Stop if at end of buffer (even though we might be in a line, if
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1166 ;; the line does not end with newline)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1167 (if (eobp)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1168 (error "At end of buffer"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1169 ;; Go to the beginning of the line
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1170 (beginning-of-line)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1171 ;; Skip any initial whitespace
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1172 (if (looking-at "[ \t]*")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1173 (goto-char (match-end 0)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1174 ;; Process the entire line
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1175 (while (not (eolp))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1176 ;; Get the next entry
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1177 (if (looking-at "\\([a-z]+\\)=\\([^ \t\n]+\\)[ \t]*")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1178 ;; Break apart the tab (before =) and the filename (after =)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1179 (let ((tag (downcase
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1180 (buffer-substring (match-beginning 1) (match-end 1))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1181 (file (buffer-substring (match-beginning 2) (match-end 2))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1182 ;; Move point after the entry
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1183 (goto-char (match-end 0))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1184 ;; Store the filename in the right variable
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1185 (cond
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1186 ((string-equal tag "a")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1187 (if file-A
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1188 (error "This line has two `A' entries"))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1189 (setq file-A file))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1190 ((string-equal tag "b")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1191 (if file-B
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1192 (error "This line has two `B' entries"))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1193 (setq file-B file))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1194 ((or (string-equal tag "anc") (string-equal tag "ancestor"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1195 (if file-ancestor
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1196 (error "This line has two `ancestor' entries"))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1197 (setq file-ancestor file))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1198 ((or (string-equal tag "out") (string-equal tag "output"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1199 (if file-out
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1200 (error "This line has two `output' entries"))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1201 (setq file-out file))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1202 (t
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1203 (error "Unrecognized entry"))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1204 ;; If the match on the entry pattern failed
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2773
diff changeset
1205 (error "Unparsable entry")))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1206 ;; Make sure that file-A and file-B are present
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1207 (if (not (or (and file-A file-B) file-out))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1208 (error "Must have both `A' and `B' entries"))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1209 (if (not (or file-A file-B))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1210 (error "Must have `A' or `B' entry"))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1211 ;; Go to the beginning of the next line, so next execution will use
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1212 ;; next line in buffer.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1213 (beginning-of-line 2)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1214 ;; Execute the correct command
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1215 (cond
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1216 ;; Merge of two files with ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1217 ((and file-A file-B file-ancestor)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1218 (message "Merging %s and %s..." file-A file-B)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1219 (emerge-files-with-ancestor (not (not file-out)) file-A file-B
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1220 file-ancestor file-out
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1221 nil
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1222 ;; When done, return to this buffer.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1223 (list
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1224 (` (lambda ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1225 (switch-to-buffer (, (current-buffer)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1226 (message "Merge done."))))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1227 ;; Merge of two files without ancestor
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1228 ((and file-A file-B)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1229 (message "Merging %s and %s..." file-A file-B)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1230 (emerge-files (not (not file-out)) file-A file-B file-out
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1231 nil
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1232 ;; When done, return to this buffer.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1233 (list
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1234 (` (lambda ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1235 (switch-to-buffer (, (current-buffer)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1236 (message "Merge done."))))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1237 ;; There is an output file (or there would have been an error above),
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1238 ;; but only one input file.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1239 ;; The file appears to have been deleted in one version; do nothing.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1240 ((and file-ancestor emerge-execute-line-deletions)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1241 (message "No action."))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1242 ;; The file should be copied from the version that contains it
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1243 (t (let ((input-file (or file-A file-B)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1244 (message "Copying...")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1245 (copy-file input-file file-out)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1246 (message "%s copied to %s." input-file file-out))))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1247
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1248 ;;; Sample function for creating information for emerge-execute-line
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1249
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1250 (defvar emerge-merge-directories-filename-regexp "[^.]"
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1251 "Regexp describing files to be processed by `emerge-merge-directories'.")
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1252
6286
676773222f1f (emerge-revisions, emerge-revisions-with-ancestor)
Richard M. Stallman <rms@gnu.org>
parents: 6281
diff changeset
1253 ;;;###autoload
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1254 (defun emerge-merge-directories (a-dir b-dir ancestor-dir output-dir)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1255 (interactive
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1256 (list
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1257 (read-file-name "A directory: " nil nil 'confirm)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1258 (read-file-name "B directory: " nil nil 'confirm)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1259 (read-file-name "Ancestor directory (null for none): " nil nil 'confirm)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1260 (read-file-name "Output directory (null for none): " nil nil 'confirm)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1261 ;; Check that we're not on a line
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1262 (if (not (and (bolp) (eolp)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1263 (error "There is text on this line"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1264 ;; Turn null strings into nil to indicate directories not used.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1265 (if (and ancestor-dir (string-equal ancestor-dir ""))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1266 (setq ancestor-dir nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1267 (if (and output-dir (string-equal output-dir ""))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1268 (setq output-dir nil))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1269 ;; Canonicalize the directory names
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1270 (setq a-dir (expand-file-name a-dir))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1271 (if (not (string-equal (substring a-dir -1) "/"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1272 (setq a-dir (concat a-dir "/")))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1273 (setq b-dir (expand-file-name b-dir))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1274 (if (not (string-equal (substring b-dir -1) "/"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1275 (setq b-dir (concat b-dir "/")))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1276 (if ancestor-dir
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1277 (progn
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1278 (setq ancestor-dir (expand-file-name ancestor-dir))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1279 (if (not (string-equal (substring ancestor-dir -1) "/"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1280 (setq ancestor-dir (concat ancestor-dir "/")))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1281 (if output-dir
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1282 (progn
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1283 (setq output-dir (expand-file-name output-dir))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1284 (if (not (string-equal (substring output-dir -1) "/"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1285 (setq output-dir (concat output-dir "/")))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1286 ;; Set the mark to where we start
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1287 (push-mark)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1288 ;; Find out what files are in the directories.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1289 (let* ((a-dir-files
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1290 (directory-files a-dir nil emerge-merge-directories-filename-regexp))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1291 (b-dir-files
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1292 (directory-files b-dir nil emerge-merge-directories-filename-regexp))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1293 (ancestor-dir-files
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1294 (and ancestor-dir
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1295 (directory-files ancestor-dir nil
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1296 emerge-merge-directories-filename-regexp)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1297 (all-files (sort (nconc (copy-sequence a-dir-files)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1298 (copy-sequence b-dir-files)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1299 (copy-sequence ancestor-dir-files))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1300 (function string-lessp))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1301 ;; Remove duplicates from all-files.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1302 (let ((p all-files))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1303 (while p
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1304 (if (and (cdr p) (string-equal (car p) (car (cdr p))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1305 (setcdr p (cdr (cdr p)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1306 (setq p (cdr p)))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1307 ;; Generate the control lines for the various files.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1308 (while all-files
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1309 (let ((f (car all-files)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1310 (setq all-files (cdr all-files))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1311 (if (and a-dir-files (string-equal (car a-dir-files) f))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1312 (progn
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1313 (insert "A=" a-dir f "\t")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1314 (setq a-dir-files (cdr a-dir-files))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1315 (if (and b-dir-files (string-equal (car b-dir-files) f))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1316 (progn
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1317 (insert "B=" b-dir f "\t")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1318 (setq b-dir-files (cdr b-dir-files))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1319 (if (and ancestor-dir-files (string-equal (car ancestor-dir-files) f))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1320 (progn
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1321 (insert "ancestor=" ancestor-dir f "\t")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1322 (setq ancestor-dir-files (cdr ancestor-dir-files))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1323 (if output-dir
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1324 (insert "output=" output-dir f "\t"))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1325 (backward-delete-char 1)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1326 (insert "\n")))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1327
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1328 ;;; Common setup routines
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1329
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330 ;; Set up the window configuration. If POS is given, set the points to
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1331 ;; the beginnings of the buffers.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1332 (defun emerge-setup-windows (buffer-A buffer-B merge-buffer &optional pos)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1333 ;; Make sure we are not in the minibuffer window when we try to delete
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1334 ;; all other windows.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1335 (if (eq (selected-window) (minibuffer-window))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1336 (other-window 1))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1337 (delete-other-windows)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1338 (switch-to-buffer merge-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1339 (emerge-refresh-mode-line)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1340 (split-window-vertically)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341 (split-window-horizontally)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1342 (switch-to-buffer buffer-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1343 (if pos
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1344 (goto-char (point-min)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1345 (other-window 1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1346 (switch-to-buffer buffer-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1347 (if pos
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1348 (goto-char (point-min)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1349 (other-window 1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1350 (if pos
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1351 (goto-char (point-min)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1352 ;; If diff/diff3 reports errors, display them rather than the merge buffer.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1353 (if (/= 0 (emerge-eval-in-buffer emerge-diff-error-buffer (buffer-size)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1354 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1355 (ding)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1356 (message "Errors found in diff/diff3 output. Merge buffer is %s."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1357 (buffer-name emerge-merge-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1358 (switch-to-buffer emerge-diff-error-buffer))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1359
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1360 ;; Set up the keymap in the merge buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1361 (defun emerge-set-keys ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1362 ;; Set up fixed keymaps if necessary
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1363 (if (not emerge-basic-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1364 (emerge-setup-fixed-keymaps))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1365 ;; Save the old local map
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1366 (setq emerge-old-keymap (current-local-map))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1367 ;; Construct the edit keymap
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1368 (setq emerge-edit-keymap (if emerge-old-keymap
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1369 (copy-keymap emerge-old-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1370 (make-sparse-keymap)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1371 ;; Install the Emerge commands
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1372 (emerge-force-define-key emerge-edit-keymap emerge-command-prefix
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1373 'emerge-basic-keymap)
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1374 (define-key emerge-edit-keymap [menu-bar] (make-sparse-keymap))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1375
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1376 ;; Create the additional menu bar items.
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1377 (define-key emerge-edit-keymap [menu-bar options]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1378 (cons "Options" emerge-options-menu))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1379 (define-key emerge-edit-keymap [menu-bar merge]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1380 (cons "Merge" emerge-merge-menu))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1381 (define-key emerge-edit-keymap [menu-bar move]
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1382 (cons "Move" emerge-move-menu))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1383
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1384 ;; Suppress write-file and save-buffer
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1385 (substitute-key-definition 'write-file
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1386 'emerge-query-write-file
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1387 emerge-edit-keymap)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1388 (substitute-key-definition 'save-buffer
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1389 'emerge-query-save-buffer
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1390 emerge-edit-keymap)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1391 (substitute-key-definition 'write-file 'emerge-query-write-file
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1392 emerge-edit-keymap (current-global-map))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1393 (substitute-key-definition 'save-buffer 'emerge-query-save-buffer
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1394 emerge-edit-keymap (current-global-map))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1395 (use-local-map emerge-fast-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1396 (setq emerge-edit-mode nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1397 (setq emerge-fast-mode t))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1398
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1399 (defun emerge-remember-buffer-characteristics ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1400 "Record certain properties of the buffers being merged.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1401 Must be called in the merge buffer. Remembers read-only, modified,
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1402 auto-save, and saves them in buffer local variables. Sets the buffers
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1403 read-only and turns off `auto-save-mode'.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1404 These characteristics are restored by `emerge-restore-buffer-characteristics'."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405 ;; force auto-save, because we will turn off auto-saving in buffers for the
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1406 ;; duration
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1407 (do-auto-save)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1408 ;; remember and alter buffer characteristics
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 (setq emerge-A-buffer-values
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1412 (prog1
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1413 (emerge-save-variables emerge-saved-variables)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1414 (emerge-restore-variables emerge-saved-variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 emerge-merging-values))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 (setq emerge-B-buffer-values
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1417 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1418 emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1419 (prog1
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1420 (emerge-save-variables emerge-saved-variables)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1421 (emerge-restore-variables emerge-saved-variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1422 emerge-merging-values)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1423
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1424 (defun emerge-restore-buffer-characteristics ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1425 "Restores characteristics saved by `emerge-remember-buffer-characteristics'."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426 (let ((A-values emerge-A-buffer-values)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1427 (B-values emerge-B-buffer-values))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1428 (emerge-eval-in-buffer emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1429 (emerge-restore-variables emerge-saved-variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1430 A-values))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1431 (emerge-eval-in-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1432 (emerge-restore-variables emerge-saved-variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1433 B-values))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1434
6556
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1435 ;; Move to line DESIRED-LINE assuming we are at line CURRENT-LINE.
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1436 ;; Return DESIRED-LINE.
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1437 (defun emerge-goto-line (desired-line current-line)
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1438 (forward-line (- desired-line current-line))
6910
6566088ccf07 (emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents: 6809
diff changeset
1439 desired-line)
6556
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1440
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1441 (defun emerge-convert-diffs-to-markers (A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1442 B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1443 merge-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1444 lineno-list)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1445 (let* (marker-list
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1446 (A-point-min (emerge-eval-in-buffer A-buffer (point-min)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1447 (offset (1- A-point-min))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1448 (B-point-min (emerge-eval-in-buffer B-buffer (point-min)))
6556
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1449 ;; Record current line number in each buffer
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1450 ;; so we don't have to count from the beginning.
6910
6566088ccf07 (emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents: 6809
diff changeset
1451 (a-line 1)
6566088ccf07 (emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents: 6809
diff changeset
1452 (b-line 1))
6556
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1453 (emerge-eval-in-buffer A-buffer (goto-char (point-min)))
79884c55326f (emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents: 6286
diff changeset
1454 (emerge-eval-in-buffer B-buffer (goto-char (point-min)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1455 (while lineno-list
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1456 (let* ((list-element (car lineno-list))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1457 a-begin-marker
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1458 a-end-marker
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1459 b-begin-marker
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1460 b-end-marker
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1461 merge-begin-marker
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1462 merge-end-marker
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1463 (a-begin (aref list-element 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1464 (a-end (aref list-element 1))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1465 (b-begin (aref list-element 2))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1466 (b-end (aref list-element 3))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1467 (state (aref list-element 4)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1468 ;; place markers at the appropriate places in the buffers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1469 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1470 A-buffer
6910
6566088ccf07 (emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents: 6809
diff changeset
1471 (setq a-line (emerge-goto-line a-begin a-line))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1472 (setq a-begin-marker (point-marker))
6910
6566088ccf07 (emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents: 6809
diff changeset
1473 (setq a-line (emerge-goto-line a-end a-line))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1474 (setq a-end-marker (point-marker)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1475 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1476 B-buffer
6910
6566088ccf07 (emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents: 6809
diff changeset
1477 (setq b-line (emerge-goto-line b-begin b-line))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1478 (setq b-begin-marker (point-marker))
6910
6566088ccf07 (emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents: 6809
diff changeset
1479 (setq b-line (emerge-goto-line b-end b-line))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1480 (setq b-end-marker (point-marker)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1481 (setq merge-begin-marker (set-marker
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1482 (make-marker)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1483 (- (marker-position a-begin-marker)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1484 offset)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1485 merge-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1486 (setq merge-end-marker (set-marker
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1487 (make-marker)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1488 (- (marker-position a-end-marker)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1489 offset)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1490 merge-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1491 ;; record all the markers for this difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1492 (setq marker-list (cons (vector a-begin-marker a-end-marker
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1493 b-begin-marker b-end-marker
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1494 merge-begin-marker merge-end-marker
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1495 state)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1496 marker-list)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1497 (setq lineno-list (cdr lineno-list)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1498 ;; convert the list of difference information into a vector for
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1499 ;; fast access
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1500 (setq emerge-difference-list (apply 'vector (nreverse marker-list)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1501
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1502 ;; If we have an ancestor, select all B variants that we prefer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1503 (defun emerge-select-prefer-Bs ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1504 (let ((n 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1505 (while (< n emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1506 (if (eq (aref (aref emerge-difference-list n) 6) 'prefer-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1507 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1508 (emerge-unselect-and-select-difference n t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1509 (emerge-select-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1510 (aset (aref emerge-difference-list n) 6 'prefer-B)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1511 (setq n (1+ n))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1512 (emerge-unselect-and-select-difference -1))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1513
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1514 ;; Process the local-variables list at the end of the merged file, if
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1515 ;; requested.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1516 (defun emerge-handle-local-variables ()
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1517 (if emerge-process-local-variables
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1518 (condition-case err
3732
60292a8697bc (emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
1519 (hack-local-variables)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1520 (error (message "Local-variables error in merge buffer: %s"
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1521 (prin1-to-string err))))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1522
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1523 ;;; Common exit routines
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1524
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1525 (defun emerge-write-and-delete (file-out)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1526 ;; clear screen format
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1527 (delete-other-windows)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1528 ;; delete A, B, and ancestor buffers, if they haven't been changed
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1529 (if (not (buffer-modified-p emerge-A-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1530 (kill-buffer emerge-A-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1531 (if (not (buffer-modified-p emerge-B-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1532 (kill-buffer emerge-B-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1533 (if (and emerge-ancestor-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1534 (not (buffer-modified-p emerge-ancestor-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1535 (kill-buffer emerge-ancestor-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1536 ;; Write merge buffer to file
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1537 (and file-out
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1538 (write-file file-out)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1539
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1540 ;;; Commands
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1541
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542 (defun emerge-recenter (&optional arg)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1543 "Bring the highlighted region of all three merge buffers into view.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1544 This brings the buffers into view if they are in windows.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1545 With an argument, reestablish the default three-window display."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1546 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1547 ;; If there is an argument, rebuild the window structure
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1548 (if arg
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1549 (emerge-setup-windows emerge-A-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1550 emerge-merge-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1551 ;; Redisplay whatever buffers are showing, if there is a selected difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1552 (if (and (>= emerge-current-difference 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1553 (< emerge-current-difference emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1554 (let* ((merge-buffer emerge-merge-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1555 (buffer-A emerge-A-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1556 (buffer-B emerge-B-buffer)
8974
0d7b32820221 (emerge-recenter, emerge-operate-on-windows):
Richard M. Stallman <rms@gnu.org>
parents: 6910
diff changeset
1557 (window-A (get-buffer-window buffer-A 'visible))
0d7b32820221 (emerge-recenter, emerge-operate-on-windows):
Richard M. Stallman <rms@gnu.org>
parents: 6910
diff changeset
1558 (window-B (get-buffer-window buffer-B 'visible))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1559 (merge-window (get-buffer-window merge-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1560 (diff-vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1561 (aref emerge-difference-list emerge-current-difference)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1562 (if window-A (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1563 (select-window window-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1564 (emerge-position-region
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1565 (- (aref diff-vector 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1566 (1- emerge-before-flag-length))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1567 (+ (aref diff-vector 1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1568 (1- emerge-after-flag-length))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1569 (1+ (aref diff-vector 0)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1570 (if window-B (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1571 (select-window window-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1572 (emerge-position-region
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1573 (- (aref diff-vector 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1574 (1- emerge-before-flag-length))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1575 (+ (aref diff-vector 3)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1576 (1- emerge-after-flag-length))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1577 (1+ (aref diff-vector 2)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1578 (if merge-window (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1579 (select-window merge-window)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1580 (emerge-position-region
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1581 (- (aref diff-vector 4)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1582 (1- emerge-before-flag-length))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1583 (+ (aref diff-vector 5)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1584 (1- emerge-after-flag-length))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1585 (1+ (aref diff-vector 4))))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1586
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1587 ;;; Window scrolling operations
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1588 ;; These operations are designed to scroll all three windows the same amount,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1589 ;; so as to keep the text in them aligned.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1590
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1591 ;; Perform some operation on all three windows (if they are showing).
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1592 ;; Catches all errors on the operation in the A and B windows, but not
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1593 ;; in the merge window. Usually, errors come from scrolling off the
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1594 ;; beginning or end of the buffer, and this gives a nice error message:
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1595 ;; End of buffer is reported in the merge buffer, but if the scroll was
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1596 ;; possible in the A or B windows, it is performed there before the error
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1597 ;; is reported.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1598 (defun emerge-operate-on-windows (operation arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1599 (let* ((merge-buffer emerge-merge-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1600 (buffer-A emerge-A-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1601 (buffer-B emerge-B-buffer)
8974
0d7b32820221 (emerge-recenter, emerge-operate-on-windows):
Richard M. Stallman <rms@gnu.org>
parents: 6910
diff changeset
1602 (window-A (get-buffer-window buffer-A 'visible))
0d7b32820221 (emerge-recenter, emerge-operate-on-windows):
Richard M. Stallman <rms@gnu.org>
parents: 6910
diff changeset
1603 (window-B (get-buffer-window buffer-B 'visible))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1604 (merge-window (get-buffer-window merge-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1605 (if window-A (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1606 (select-window window-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1607 (condition-case nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1608 (funcall operation arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1609 (error))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1610 (if window-B (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1611 (select-window window-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1612 (condition-case nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1613 (funcall operation arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1614 (error))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1615 (if merge-window (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1616 (select-window merge-window)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1617 (funcall operation arg)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1618
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1619 (defun emerge-scroll-up (&optional arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1620 "Scroll up all three merge buffers, if they are in windows.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1621 With argument N, scroll N lines; otherwise scroll by nearly
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1622 the height of the merge window.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1623 `C-u -' alone as argument scrolls half the height of the merge window."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1624 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1625 (emerge-operate-on-windows
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1626 'scroll-up
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1627 ;; calculate argument to scroll-up
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1628 ;; if there is an explicit argument
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1629 (if (and arg (not (equal arg '-)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1630 ;; use it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1631 (prefix-numeric-value arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1632 ;; if not, see if we can determine a default amount (the window height)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1633 (let ((merge-window (get-buffer-window emerge-merge-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1634 (if (null merge-window)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1635 ;; no window, use nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1636 nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1637 (let ((default-amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1638 (- (window-height merge-window) 1 next-screen-context-lines)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1639 ;; the window was found
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1640 (if arg
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1641 ;; C-u as argument means half of default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1642 (/ default-amount 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1643 ;; no argument means default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1644 default-amount)))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1645
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1646 (defun emerge-scroll-down (&optional arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1647 "Scroll down all three merge buffers, if they are in windows.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1648 With argument N, scroll N lines; otherwise scroll by nearly
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1649 the height of the merge window.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1650 `C-u -' alone as argument scrolls half the height of the merge window."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1651 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1652 (emerge-operate-on-windows
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1653 'scroll-down
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1654 ;; calculate argument to scroll-down
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1655 ;; if there is an explicit argument
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1656 (if (and arg (not (equal arg '-)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1657 ;; use it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1658 (prefix-numeric-value arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1659 ;; if not, see if we can determine a default amount (the window height)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1660 (let ((merge-window (get-buffer-window emerge-merge-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1661 (if (null merge-window)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1662 ;; no window, use nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1663 nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1664 (let ((default-amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1665 (- (window-height merge-window) 1 next-screen-context-lines)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1666 ;; the window was found
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1667 (if arg
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1668 ;; C-u as argument means half of default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1669 (/ default-amount 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1670 ;; no argument means default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1671 default-amount)))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1672
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1673 (defun emerge-scroll-left (&optional arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1674 "Scroll left all three merge buffers, if they are in windows.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1675 If an argument is given, that is how many columns are scrolled, else nearly
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1676 the width of the A and B windows. `C-u -' alone as argument scrolls half the
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1677 width of the A and B windows."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1678 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1679 (emerge-operate-on-windows
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1680 'scroll-left
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1681 ;; calculate argument to scroll-left
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1682 ;; if there is an explicit argument
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1683 (if (and arg (not (equal arg '-)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1684 ;; use it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1685 (prefix-numeric-value arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1686 ;; if not, see if we can determine a default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1687 ;; (half the window width)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1688 (let ((merge-window (get-buffer-window emerge-merge-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1689 (if (null merge-window)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1690 ;; no window, use nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1691 nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1692 (let ((default-amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1693 (- (/ (window-width merge-window) 2) 3)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1694 ;; the window was found
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1695 (if arg
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1696 ;; C-u as argument means half of default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1697 (/ default-amount 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1698 ;; no argument means default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1699 default-amount)))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1700
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1701 (defun emerge-scroll-right (&optional arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1702 "Scroll right all three merge buffers, if they are in windows.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1703 If an argument is given, that is how many columns are scrolled, else nearly
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1704 the width of the A and B windows. `C-u -' alone as argument scrolls half the
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1705 width of the A and B windows."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1706 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1707 (emerge-operate-on-windows
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1708 'scroll-right
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1709 ;; calculate argument to scroll-right
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1710 ;; if there is an explicit argument
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1711 (if (and arg (not (equal arg '-)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1712 ;; use it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1713 (prefix-numeric-value arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1714 ;; if not, see if we can determine a default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1715 ;; (half the window width)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1716 (let ((merge-window (get-buffer-window emerge-merge-buffer)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1717 (if (null merge-window)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1718 ;; no window, use nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1719 nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1720 (let ((default-amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1721 (- (/ (window-width merge-window) 2) 3)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1722 ;; the window was found
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1723 (if arg
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1724 ;; C-u as argument means half of default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1725 (/ default-amount 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1726 ;; no argument means default amount
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1727 default-amount)))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1728
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1729 (defun emerge-scroll-reset ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1730 "Reset horizontal scrolling in Emerge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1731 This resets the horizontal scrolling of all three merge buffers
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1732 to the left margin, if they are in windows."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1733 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1734 (emerge-operate-on-windows
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1735 (function (lambda (x) (set-window-hscroll (selected-window) 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1736 nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1737
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1738 ;; Attempt to show the region nicely.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1739 ;; If there are min-lines lines above and below the region, then don't do
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1740 ;; anything.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1741 ;; If not, recenter the region to make it so.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1742 ;; If that isn't possible, remove context lines balancedly from top and botton
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1743 ;; so the entire region shows.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1744 ;; If that isn't possible, show the top of the region.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1745 ;; BEG must be at the beginning of a line.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1746 (defun emerge-position-region (beg end pos)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1747 ;; First test whether the entire region is visible with
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1748 ;; emerge-min-visible-lines above and below it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1749 (if (not (and (<= (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1750 (move-to-window-line emerge-min-visible-lines)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1751 (point))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1752 beg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1753 (<= end (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1754 (move-to-window-line
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1755 (- (1+ emerge-min-visible-lines)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1756 (point)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1757 ;; We failed that test, see if it fits at all
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1758 ;; Meanwhile positioning it correctly in case it doesn't fit
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1759 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1760 (set-window-start (selected-window) beg)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
1761 (if (pos-visible-in-window-p end)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1762 ;; Determine the number of lines that the region occupies
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1763 (let ((lines 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1764 (while (> end (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1765 (move-to-window-line lines)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1766 (point)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1767 (setq lines (1+ lines)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1768 ;; And position the beginning on the right line
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1769 (goto-char beg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1770 (recenter (/ (1+ (- (1- (window-height (selected-window)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1771 lines))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1772 2))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1773 (goto-char pos))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1774
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1775 (defun emerge-next-difference ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1776 "Advance to the next difference."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1777 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1778 (if (< emerge-current-difference emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1779 (let ((n (1+ emerge-current-difference)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1780 (while (and emerge-skip-prefers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1781 (< n emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1782 (memq (aref (aref emerge-difference-list n) 6)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1783 '(prefer-A prefer-B)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1784 (setq n (1+ n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1785 (let ((buffer-read-only nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1786 (emerge-unselect-and-select-difference n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1787 (error "At end")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1788
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1789 (defun emerge-previous-difference ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1790 "Go to the previous difference."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1791 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1792 (if (> emerge-current-difference -1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1793 (let ((n (1- emerge-current-difference)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1794 (while (and emerge-skip-prefers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1795 (> n -1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1796 (memq (aref (aref emerge-difference-list n) 6)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1797 '(prefer-A prefer-B)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1798 (setq n (1- n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1799 (let ((buffer-read-only nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1800 (emerge-unselect-and-select-difference n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1801 (error "At beginning")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1802
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1803 (defun emerge-jump-to-difference (difference-number)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1804 "Go to the N-th difference."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1805 (interactive "p")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1806 (let ((buffer-read-only nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1807 (setq difference-number (1- difference-number))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1808 (if (and (>= difference-number -1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1809 (< difference-number (1+ emerge-number-of-differences)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1810 (emerge-unselect-and-select-difference difference-number)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1811 (error "Bad difference number"))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1812
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1813 (defun emerge-abort ()
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1814 "Abort the Emerge session."
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1815 (interactive)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1816 (emerge-quit t))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1817
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1818 (defun emerge-quit (arg)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1819 "Finish the Emerge session and exit Emerge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1820 Prefix argument means to abort rather than successfully finish.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1821 The difference depends on how the merge was started,
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1822 but usually means to not write over one of the original files, or to signal
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1823 to some process which invoked Emerge a failure code.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1824
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1825 Unselects the selected difference, if any, restores the read-only and modified
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1826 flags of the merged file buffers, restores the local keymap of the merge
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1827 buffer, and sets off various emerge flags. Using Emerge commands in this
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1828 buffer after this will cause serious problems."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1829 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1830 (if (prog1
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1831 (y-or-n-p
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1832 (if (not arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1833 "Do you really want to successfully finish this merge? "
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1834 "Do you really want to abort this merge? "))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1835 (message ""))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1836 (emerge-really-quit arg)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1837
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1838 ;; Perform the quit operations.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1839 (defun emerge-really-quit (arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1840 (setq buffer-read-only nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1841 (emerge-unselect-and-select-difference -1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1842 (emerge-restore-buffer-characteristics)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1843 ;; null out the difference markers so they don't slow down future editing
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1844 ;; operations
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1845 (mapcar (function (lambda (d)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1846 (set-marker (aref d 0) nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1847 (set-marker (aref d 1) nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1848 (set-marker (aref d 2) nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1849 (set-marker (aref d 3) nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1850 (set-marker (aref d 4) nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1851 (set-marker (aref d 5) nil)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1852 emerge-difference-list)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1853 ;; allow them to be garbage collected
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1854 (setq emerge-difference-list nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1855 ;; restore the local map
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1856 (use-local-map emerge-old-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1857 ;; turn off all the emerge modes
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1858 (setq emerge-mode nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1859 (setq emerge-fast-mode nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1860 (setq emerge-edit-mode nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1861 (setq emerge-auto-advance nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1862 (setq emerge-skip-prefers nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1863 ;; restore mode line
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1864 (kill-local-variable 'mode-line-buffer-identification)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1865 (let ((emerge-prefix-argument arg))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1866 (run-hooks 'emerge-quit-hook)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1867
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1868 (defun emerge-select-A (&optional force)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1869 "Select the A variant of this difference.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1870 Refuses to function if this difference has been edited, i.e., if it
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1871 is neither the A nor the B variant.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1872 A prefix argument forces the variant to be selected
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1873 even if the difference has been edited."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1874 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1875 (let ((operate
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1876 (function (lambda ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1877 (emerge-select-A-edit merge-begin merge-end A-begin A-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1878 (if emerge-auto-advance
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1879 (emerge-next-difference)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1880 (operate-no-change
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1881 (function (lambda ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1882 (if emerge-auto-advance
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1883 (emerge-next-difference))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1884 (emerge-select-version force operate-no-change operate operate)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1885
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1886 ;; Actually select the A variant
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1887 (defun emerge-select-A-edit (merge-begin merge-end A-begin A-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1888 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1889 emerge-merge-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1890 (delete-region merge-begin merge-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1891 (goto-char merge-begin)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1892 (insert-buffer-substring emerge-A-buffer A-begin A-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1893 (goto-char merge-begin)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1894 (aset diff-vector 6 'A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1895 (emerge-refresh-mode-line)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1896
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1897 (defun emerge-select-B (&optional force)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1898 "Select the B variant of this difference.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1899 Refuses to function if this difference has been edited, i.e., if it
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1900 is neither the A nor the B variant.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1901 A prefix argument forces the variant to be selected
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1902 even if the difference has been edited."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1903 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1904 (let ((operate
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1905 (function (lambda ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1906 (emerge-select-B-edit merge-begin merge-end B-begin B-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1907 (if emerge-auto-advance
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1908 (emerge-next-difference)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1909 (operate-no-change
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1910 (function (lambda ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1911 (if emerge-auto-advance
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1912 (emerge-next-difference))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1913 (emerge-select-version force operate operate-no-change operate)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1914
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1915 ;; Actually select the B variant
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1916 (defun emerge-select-B-edit (merge-begin merge-end B-begin B-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1917 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1918 emerge-merge-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1919 (delete-region merge-begin merge-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1920 (goto-char merge-begin)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1921 (insert-buffer-substring emerge-B-buffer B-begin B-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1922 (goto-char merge-begin)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1923 (aset diff-vector 6 'B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1924 (emerge-refresh-mode-line)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1925
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1926 (defun emerge-default-A ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1927 "Make the A variant the default from here down.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1928 This selects the A variant for all differences from here down in the buffer
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1929 which are still defaulted, i.e., which the user has not selected and for
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1930 which there is no preference."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1931 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1932 (let ((buffer-read-only nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1933 (let ((selected-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1934 (n (max emerge-current-difference 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1935 (while (< n emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1936 (let ((diff-vector (aref emerge-difference-list n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1937 (if (eq (aref diff-vector 6) 'default-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1938 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1939 (emerge-unselect-and-select-difference n t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1940 (emerge-select-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1941 (aset diff-vector 6 'default-A))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1942 (setq n (1+ n))
4399
8080301bd1d9 (emerge-default-[AB]): Use (zerop (% A B)) instead of
Paul Eggert <eggert@twinsun.com>
parents: 3732
diff changeset
1943 (if (zerop (% n 10))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1944 (message "Setting default to A...%d" n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1945 (emerge-unselect-and-select-difference selected-difference)))
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1946 (message "Default choice is now A"))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1947
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1948 (defun emerge-default-B ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1949 "Make the B variant the default from here down.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1950 This selects the B variant for all differences from here down in the buffer
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1951 which are still defaulted, i.e., which the user has not selected and for
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1952 which there is no preference."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1953 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1954 (let ((buffer-read-only nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1955 (let ((selected-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1956 (n (max emerge-current-difference 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1957 (while (< n emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1958 (let ((diff-vector (aref emerge-difference-list n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1959 (if (eq (aref diff-vector 6) 'default-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1960 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1961 (emerge-unselect-and-select-difference n t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1962 (emerge-select-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1963 (aset diff-vector 6 'default-B))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1964 (setq n (1+ n))
4399
8080301bd1d9 (emerge-default-[AB]): Use (zerop (% A B)) instead of
Paul Eggert <eggert@twinsun.com>
parents: 3732
diff changeset
1965 (if (zerop (% n 10))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1966 (message "Setting default to B...%d" n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1967 (emerge-unselect-and-select-difference selected-difference)))
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
1968 (message "Default choice is now B"))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1969
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1970 (defun emerge-fast-mode ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1971 "Set fast mode, for Emerge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1972 In this mode ordinary Emacs commands are disabled, and Emerge commands
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1973 need not be prefixed with \\<emerge-fast-keymap>\\[emerge-basic-keymap]."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1974 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1975 (setq buffer-read-only t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1976 (use-local-map emerge-fast-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1977 (setq emerge-mode t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1978 (setq emerge-fast-mode t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1979 (setq emerge-edit-mode nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1980 (message "Fast mode set")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1981 ;; force mode line redisplay
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1982 (set-buffer-modified-p (buffer-modified-p)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1983
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1984 (defun emerge-edit-mode ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1985 "Set edit mode, for Emerge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1986 In this mode ordinary Emacs commands are available, and Emerge commands
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1987 must be prefixed with \\<emerge-fast-keymap>\\[emerge-basic-keymap]."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1988 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1989 (setq buffer-read-only nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1990 (use-local-map emerge-edit-keymap)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1991 (setq emerge-mode t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1992 (setq emerge-fast-mode nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1993 (setq emerge-edit-mode t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1994 (message "Edit mode set")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1995 ;; force mode line redisplay
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1996 (set-buffer-modified-p (buffer-modified-p)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1997
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1998 (defun emerge-auto-advance (arg)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
1999 "Toggle Auto-Advance mode, for Emerge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2000 This mode causes `emerge-select-A' and `emerge-select-B' to automatically
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2001 advance to the next difference.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2002 With a positive argument, turn on Auto-Advance mode.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2003 With a negative argument, turn off Auto-Advance mode."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2004 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2005 (setq emerge-auto-advance (if (null arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2006 (not emerge-auto-advance)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2007 (> (prefix-numeric-value arg) 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2008 (message (if emerge-skip-prefers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2009 "Auto-advance set"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2010 "Auto-advance cleared"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2011 ;; force mode line redisplay
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2012 (set-buffer-modified-p (buffer-modified-p)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2013
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2014 (defun emerge-skip-prefers (arg)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2015 "Toggle Skip-Prefers mode, for Emerge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2016 This mode causes `emerge-next-difference' and `emerge-previous-difference'
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2017 to automatically skip over differences for which there is a preference.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2018 With a positive argument, turn on Skip-Prefers mode.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2019 With a negative argument, turn off Skip-Prefers mode."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2020 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2021 (setq emerge-skip-prefers (if (null arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2022 (not emerge-skip-prefers)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2023 (> (prefix-numeric-value arg) 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2024 (message (if emerge-skip-prefers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2025 "Skip-prefers set"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2026 "Skip-prefers cleared"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2027 ;; force mode line redisplay
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2028 (set-buffer-modified-p (buffer-modified-p)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2029
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2030 (defun emerge-copy-as-kill-A ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2031 "Put the A variant of this difference in the kill ring."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2032 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2033 (emerge-validate-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2034 (let* ((diff-vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2035 (aref emerge-difference-list emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2036 (A-begin (1+ (aref diff-vector 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2037 (A-end (1- (aref diff-vector 1)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2038 ;; so further kills don't append
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2039 this-command)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2040 (save-excursion
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2041 (set-buffer emerge-A-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2042 (copy-region-as-kill A-begin A-end))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2043
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2044 (defun emerge-copy-as-kill-B ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2045 "Put the B variant of this difference in the kill ring."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2046 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2047 (emerge-validate-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2048 (let* ((diff-vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2049 (aref emerge-difference-list emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2050 (B-begin (1+ (aref diff-vector 2)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2051 (B-end (1- (aref diff-vector 3)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2052 ;; so further kills don't append
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2053 this-command)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2054 (save-excursion
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2055 (set-buffer emerge-B-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2056 (copy-region-as-kill B-begin B-end))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2057
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2058 (defun emerge-insert-A (arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2059 "Insert the A variant of this difference at the point.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2060 Leaves point after text, mark before.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2061 With prefix argument, puts point before, mark after."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2062 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2063 (emerge-validate-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2064 (let* ((diff-vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2065 (aref emerge-difference-list emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2066 (A-begin (1+ (aref diff-vector 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2067 (A-end (1- (aref diff-vector 1)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2068 (opoint (point))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2069 (buffer-read-only nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2070 (insert-buffer-substring emerge-A-buffer A-begin A-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2071 (if (not arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2072 (set-mark opoint)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2073 (set-mark (point))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2074 (goto-char opoint))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2075
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2076 (defun emerge-insert-B (arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2077 "Insert the B variant of this difference at the point.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2078 Leaves point after text, mark before.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2079 With prefix argument, puts point before, mark after."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2080 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2081 (emerge-validate-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2082 (let* ((diff-vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2083 (aref emerge-difference-list emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2084 (B-begin (1+ (aref diff-vector 2)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2085 (B-end (1- (aref diff-vector 3)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2086 (opoint (point))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2087 (buffer-read-only nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2088 (insert-buffer-substring emerge-B-buffer B-begin B-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2089 (if (not arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2090 (set-mark opoint)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2091 (set-mark (point))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2092 (goto-char opoint))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2093
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2094 (defun emerge-mark-difference (arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2095 "Leaves the point before this difference and the mark after it.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2096 With prefix argument, puts mark before, point after."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2097 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2098 (emerge-validate-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2099 (let* ((diff-vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2100 (aref emerge-difference-list emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2101 (merge-begin (1+ (aref diff-vector 4)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2102 (merge-end (1- (aref diff-vector 5))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2103 (if (not arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2104 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2105 (goto-char merge-begin)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2106 (set-mark merge-end))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2107 (goto-char merge-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2108 (set-mark merge-begin))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2109
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2110 (defun emerge-file-names ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2111 "Show the names of the buffers or files being operated on by Emerge.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2112 Use C-u l to reset the windows afterward."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2113 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2114 (delete-other-windows)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2115 (let ((temp-buffer-show-function
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2116 (function (lambda (buf)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2117 (split-window-vertically)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2118 (switch-to-buffer buf)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2119 (other-window 1)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2120 (with-output-to-temp-buffer "*Help*"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2121 (emerge-eval-in-buffer emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2122 (if buffer-file-name
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2123 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2124 (princ "File A is: ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2125 (princ buffer-file-name))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2126 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2127 (princ "Buffer A is: ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2128 (princ (buffer-name))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2129 (princ "\n"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2130 (emerge-eval-in-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2131 (if buffer-file-name
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2132 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2133 (princ "File B is: ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2134 (princ buffer-file-name))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2135 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2136 (princ "Buffer B is: ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2137 (princ (buffer-name))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2138 (princ "\n"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2139 (if emerge-ancestor-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2140 (emerge-eval-in-buffer emerge-ancestor-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2141 (if buffer-file-name
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2142 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2143 (princ "Ancestor file is: ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2144 (princ buffer-file-name))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2145 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2146 (princ "Ancestor buffer is: ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2147 (princ (buffer-name))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2148 (princ "\n")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2149 (princ emerge-output-description))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2150
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2151 (defun emerge-join-differences (arg)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2152 "Join the selected difference with the following one.
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2773
diff changeset
2153 With a prefix argument, join with the preceding one."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2154 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2155 (let ((n emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2156 ;; adjust n to be first difference to join
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2157 (if arg
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2158 (setq n (1- n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2159 ;; n and n+1 are the differences to join
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2160 ;; check that they are both differences
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2161 (if (or (< n 0) (>= n (1- emerge-number-of-differences)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2162 (error "Incorrect differences to join"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2163 ;; remove the flags
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2164 (emerge-unselect-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2165 ;; decrement total number of differences
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2166 (setq emerge-number-of-differences (1- emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2167 ;; build new differences vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2168 (let ((i 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2169 (new-differences (make-vector emerge-number-of-differences nil)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2170 (while (< i emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2171 (aset new-differences i
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2172 (cond
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2173 ((< i n) (aref emerge-difference-list i))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2174 ((> i n) (aref emerge-difference-list (1+ i)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2175 (t (let ((prev (aref emerge-difference-list i))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2176 (next (aref emerge-difference-list (1+ i))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2177 (vector (aref prev 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2178 (aref next 1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2179 (aref prev 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2180 (aref next 3)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2181 (aref prev 4)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2182 (aref next 5)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2183 (let ((ps (aref prev 6))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2184 (ns (aref next 6)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2185 (cond
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2186 ((eq ps ns)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2187 ps)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2188 ((and (or (eq ps 'B) (eq ps 'prefer-B))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2189 (or (eq ns 'B) (eq ns 'prefer-B)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2190 'B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2191 (t 'A))))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2192 (setq i (1+ i)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2193 (setq emerge-difference-list new-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2194 ;; set the current difference correctly
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2195 (setq emerge-current-difference n)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2196 ;; fix the mode line
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2197 (emerge-refresh-mode-line)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2198 ;; reinsert the flags
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2199 (emerge-select-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2200 (emerge-recenter)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2201
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2202 (defun emerge-split-difference ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2203 "Split the current difference where the points are in the three windows."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2204 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2205 (let ((n emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2206 ;; check that this is a valid difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2207 (emerge-validate-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2208 ;; get the point values and old difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2209 (let ((A-point (emerge-eval-in-buffer emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2210 (point-marker)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2211 (B-point (emerge-eval-in-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2212 (point-marker)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2213 (merge-point (point-marker))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2214 (old-diff (aref emerge-difference-list n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2215 ;; check location of the points, give error if they aren't in the
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2216 ;; differences
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2217 (if (or (< A-point (aref old-diff 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2218 (> A-point (aref old-diff 1)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2219 (error "Point outside of difference in A buffer"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2220 (if (or (< B-point (aref old-diff 2))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2221 (> B-point (aref old-diff 3)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2222 (error "Point outside of difference in B buffer"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2223 (if (or (< merge-point (aref old-diff 4))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2224 (> merge-point (aref old-diff 5)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2225 (error "Point outside of difference in merge buffer"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2226 ;; remove the flags
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2227 (emerge-unselect-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2228 ;; increment total number of differences
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2229 (setq emerge-number-of-differences (1+ emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2230 ;; build new differences vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2231 (let ((i 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2232 (new-differences (make-vector emerge-number-of-differences nil)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2233 (while (< i emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2234 (aset new-differences i
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2235 (cond
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2236 ((< i n)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2237 (aref emerge-difference-list i))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2238 ((> i (1+ n))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2239 (aref emerge-difference-list (1- i)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2240 ((= i n)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2241 (vector (aref old-diff 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2242 A-point
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2243 (aref old-diff 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2244 B-point
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2245 (aref old-diff 4)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2246 merge-point
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2247 (aref old-diff 6)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2248 (t
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2249 (vector (copy-marker A-point)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2250 (aref old-diff 1)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2251 (copy-marker B-point)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2252 (aref old-diff 3)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2253 (copy-marker merge-point)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2254 (aref old-diff 5)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2255 (aref old-diff 6)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2256 (setq i (1+ i)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2257 (setq emerge-difference-list new-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2258 ;; set the current difference correctly
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2259 (setq emerge-current-difference n)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2260 ;; fix the mode line
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2261 (emerge-refresh-mode-line)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2262 ;; reinsert the flags
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2263 (emerge-select-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2264 (emerge-recenter))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2265
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2266 (defun emerge-trim-difference ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2267 "Trim lines off top and bottom of difference that are the same.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2268 If lines are the same in both the A and the B versions, strip them off.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2269 \(This can happen when the A and B versions have common lines that the
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2270 ancestor version does not share.)"
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2271 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2272 ;; make sure we are in a real difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2273 (emerge-validate-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2274 ;; remove the flags
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2275 (emerge-unselect-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2276 (let* ((diff (aref emerge-difference-list emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2277 (top-a (marker-position (aref diff 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2278 (bottom-a (marker-position (aref diff 1)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2279 (top-b (marker-position (aref diff 2)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2280 (bottom-b (marker-position (aref diff 3)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2281 (top-m (marker-position (aref diff 4)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2282 (bottom-m (marker-position (aref diff 5)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2283 size success sa sb sm)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2284 ;; move down the tops of the difference regions as much as possible
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2285 ;; Try advancing comparing 1000 chars at a time.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2286 ;; When that fails, go 500 chars at a time, and so on.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2287 (setq size 1000)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2288 (while (> size 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2289 (setq success t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2290 (while success
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2291 (setq size (min size (- bottom-a top-a) (- bottom-b top-b)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2292 (- bottom-m top-m)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2293 (setq sa (emerge-eval-in-buffer emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2294 (buffer-substring top-a
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2295 (+ size top-a))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2296 (setq sb (emerge-eval-in-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2297 (buffer-substring top-b
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2298 (+ size top-b))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2299 (setq sm (buffer-substring top-m (+ size top-m)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2300 (setq success (and (> size 0) (equal sa sb) (equal sb sm)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2301 (if success
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2302 (setq top-a (+ top-a size)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2303 top-b (+ top-b size)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2304 top-m (+ top-m size))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2305 (setq size (/ size 2)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2306 ;; move up the bottoms of the difference regions as much as possible
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2307 ;; Try advancing comparing 1000 chars at a time.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2308 ;; When that fails, go 500 chars at a time, and so on.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2309 (setq size 1000)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2310 (while (> size 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2311 (setq success t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2312 (while success
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2313 (setq size (min size (- bottom-a top-a) (- bottom-b top-b)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2314 (- bottom-m top-m)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2315 (setq sa (emerge-eval-in-buffer emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2316 (buffer-substring (- bottom-a size)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2317 bottom-a)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2318 (setq sb (emerge-eval-in-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2319 (buffer-substring (- bottom-b size)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2320 bottom-b)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2321 (setq sm (buffer-substring (- bottom-m size) bottom-m))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2322 (setq success (and (> size 0) (equal sa sb) (equal sb sm)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2323 (if success
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2324 (setq bottom-a (- bottom-a size)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2325 bottom-b (- bottom-b size)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2326 bottom-m (- bottom-m size))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2327 (setq size (/ size 2)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2328 ;; {top,bottom}-{a,b,m} are now set at the new beginnings and ends
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2329 ;; of the difference regions. Move them to the beginning of lines, as
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2330 ;; appropriate.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2331 (emerge-eval-in-buffer emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2332 (goto-char top-a)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2333 (beginning-of-line)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2334 (aset diff 0 (point-marker))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2335 (goto-char bottom-a)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2336 (beginning-of-line 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2337 (aset diff 1 (point-marker)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2338 (emerge-eval-in-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2339 (goto-char top-b)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2340 (beginning-of-line)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2341 (aset diff 2 (point-marker))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2342 (goto-char bottom-b)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2343 (beginning-of-line 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2344 (aset diff 3 (point-marker)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2345 (goto-char top-m)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2346 (beginning-of-line)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2347 (aset diff 4 (point-marker))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2348 (goto-char bottom-m)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2349 (beginning-of-line 2)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2350 (aset diff 5 (point-marker))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2351 ;; put the flags back in, recenter the display
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2352 (emerge-select-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2353 (emerge-recenter)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2354
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2355 (defun emerge-find-difference (arg)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2356 "Find the difference containing the current position of the point.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2357 If there is no containing difference and the prefix argument is positive,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2358 it finds the nearest following difference. A negative prefix argument finds
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2359 the nearest previous difference."
4560
106e0040381f (emerge-find-difference): Add interactive spec.
Richard M. Stallman <rms@gnu.org>
parents: 4399
diff changeset
2360 (interactive "P")
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2361 (cond ((eq (current-buffer) emerge-A-buffer)
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2362 (emerge-find-difference-A arg))
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2363 ((eq (current-buffer) emerge-B-buffer)
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2364 (emerge-find-difference-B arg))
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2365 (t (emerge-find-difference-merge arg))))
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2366
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2367 (defun emerge-find-difference-merge (arg)
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2368 "Find the difference containing point, in the merge buffer.
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2369 If there is no containing difference and the prefix argument is positive,
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2370 it finds the nearest following difference. A negative prefix argument finds
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2371 the nearest previous difference."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2372 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2373 ;; search for the point in the merge buffer, using the markers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2374 ;; for the beginning and end of the differences in the merge buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2375 (emerge-find-difference1 arg (point) 4 5))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2376
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2377 (defun emerge-find-difference-A (arg)
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2378 "Find the difference containing point, in the A buffer.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2379 This command must be executed in the merge buffer.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2380 If there is no containing difference and the prefix argument is positive,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2381 it finds the nearest following difference. A negative prefix argument finds
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2382 the nearest previous difference."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2383 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2384 ;; search for the point in the A buffer, using the markers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2385 ;; for the beginning and end of the differences in the A buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2386 (emerge-find-difference1 arg
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2387 (emerge-eval-in-buffer emerge-A-buffer (point))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2388 0 1))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2389
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2390 (defun emerge-find-difference-B (arg)
2773
8ab8f28b78d1 (emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents: 2772
diff changeset
2391 "Find the difference containing point, in the B buffer.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2392 This command must be executed in the merge buffer.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2393 If there is no containing difference and the prefix argument is positive,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2394 it finds the nearest following difference. A negative prefix argument finds
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2395 the nearest previous difference."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2396 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2397 ;; search for the point in the B buffer, using the markers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2398 ;; for the beginning and end of the differences in the B buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2399 (emerge-find-difference1 arg
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2400 (emerge-eval-in-buffer emerge-B-buffer (point))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2401 2 3))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2402
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2403 (defun emerge-find-difference1 (arg location begin end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2404 (let* ((index
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2405 ;; find first difference containing or after the current position
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2406 (catch 'search
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2407 (let ((n 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2408 (while (< n emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2409 (let ((diff-vector (aref emerge-difference-list n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2410 (if (<= location (marker-position (aref diff-vector end)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2411 (throw 'search n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2412 (setq n (1+ n))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2413 emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2414 (contains
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2415 ;; whether the found difference contains the current position
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2416 (and (< index emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2417 (<= (marker-position (aref (aref emerge-difference-list index)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2418 begin))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2419 location)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2420 (arg-value
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2421 ;; numeric value of prefix argument
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2422 (prefix-numeric-value arg)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2423 (emerge-unselect-and-select-difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2424 (cond
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2425 ;; if the point is in a difference, select it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2426 (contains index)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2427 ;; if the arg is nil and the point is not in a difference, error
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2428 ((null arg) (error "No difference contains point"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2429 ;; if the arg is positive, select the following difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2430 ((> arg-value 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2431 (if (< index emerge-number-of-differences)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2432 index
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2433 (error "No difference contains or follows point")))
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2773
diff changeset
2434 ;; if the arg is negative, select the preceding difference
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2435 (t
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2436 (if (> index 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2437 (1- index)
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2773
diff changeset
2438 (error "No difference contains or precedes point")))))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2439
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2440 (defun emerge-line-numbers ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2441 "Display the current line numbers.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2442 This function displays the line numbers of the points in the A, B, and
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2443 merge buffers."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2444 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2445 (let* ((valid-diff
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2446 (and (>= emerge-current-difference 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2447 (< emerge-current-difference emerge-number-of-differences)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2448 (diff (and valid-diff
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2449 (aref emerge-difference-list emerge-current-difference)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2450 (merge-line (emerge-line-number-in-buf 4 5))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2451 (A-line (emerge-eval-in-buffer emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2452 (emerge-line-number-in-buf 0 1)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2453 (B-line (emerge-eval-in-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2454 (emerge-line-number-in-buf 2 3))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2455 (message "At lines: merge = %d, A = %d, B = %d"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2456 merge-line A-line B-line)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2457
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2458 (defun emerge-line-number-in-buf (begin-marker end-marker)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2459 (let (temp)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2460 (setq temp (save-excursion
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2461 (beginning-of-line)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2462 (1+ (count-lines 1 (point)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2463 (if valid-diff
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2464 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2465 (if (> (point) (aref diff begin-marker))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2466 (setq temp (- temp emerge-before-flag-lines)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2467 (if (> (point) (aref diff end-marker))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2468 (setq temp (- temp emerge-after-flag-lines)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2469 temp))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2470
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2471 (defun emerge-set-combine-template (string &optional localize)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2472 "Set `emerge-combine-versions-template' to STRING.
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2473 This value controls how `emerge-combine-versions' combines the two versions.
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2474 With prefix argument, `emerge-combine-versions-template' is made local to this
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2475 merge buffer. Localization is permanent for any particular merge buffer."
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2476 (interactive "s\nP")
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2477 (if localize
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2478 (make-local-variable 'emerge-combine-versions-template))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2479 (setq emerge-combine-versions-template string)
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2480 (message
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2481 (if (assq 'emerge-combine-versions-template (buffer-local-variables))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2482 "emerge-set-combine-versions-template set locally"
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2483 "emerge-set-combine-versions-template set")))
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2484
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2485 (defun emerge-set-combine-versions-template (start end &optional localize)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2486 "Copy region into `emerge-combine-versions-template'.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2487 This controls how `emerge-combine-versions' will combine the two versions.
5796
b53b2df1351d Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents: 4560
diff changeset
2488 With prefix argument, `emerge-combine-versions-template' is made local to this
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2489 merge buffer. Localization is permanent for any particular merge buffer."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2490 (interactive "r\nP")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2491 (if localize
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2492 (make-local-variable 'emerge-combine-versions-template))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2493 (setq emerge-combine-versions-template (buffer-substring start end))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2494 (message
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2495 (if (assq 'emerge-combine-versions-template (buffer-local-variables))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2496 "emerge-set-combine-versions-template set locally."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2497 "emerge-set-combine-versions-template set.")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2498
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2499 (defun emerge-combine-versions (&optional force)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2500 "Combine versions using the template in `emerge-combine-versions-template'.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2501 Refuses to function if this difference has been edited, i.e., if it is
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2502 neither the A nor the B variant.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2503 An argument forces the variant to be selected even if the difference has
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2504 been edited."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2505 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2506 (emerge-combine-versions-internal emerge-combine-versions-template force))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2507
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2508 (defun emerge-combine-versions-register (char &optional force)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2509 "Combine the two versions using the template in register REG.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2510 See documentation of the variable `emerge-combine-versions-template'
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2511 for how the template is interpreted.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2512 Refuses to function if this difference has been edited, i.e., if it is
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2513 neither the A nor the B variant.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2514 An argument forces the variant to be selected even if the difference has
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2515 been edited."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2516 (interactive "cRegister containing template: \nP")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2517 (let ((template (get-register char)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2518 (if (not (stringp template))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2519 (error "Register does not contain text"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2520 (emerge-combine-versions-internal template force)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2521
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2522 (defun emerge-combine-versions-internal (template force)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2523 (let ((operate
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2524 (function (lambda ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2525 (emerge-combine-versions-edit merge-begin merge-end
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2526 A-begin A-end B-begin B-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2527 (if emerge-auto-advance
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2528 (emerge-next-difference))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2529 (emerge-select-version force operate operate operate)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2530
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2531 (defun emerge-combine-versions-edit (merge-begin merge-end
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2532 A-begin A-end B-begin B-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2533 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2534 emerge-merge-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2535 (delete-region merge-begin merge-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2536 (goto-char merge-begin)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2537 (let ((i 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2538 (while (< i (length template))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2539 (let ((c (aref template i)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2540 (if (= c ?%)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2541 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2542 (setq i (1+ i))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2543 (setq c
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2544 (condition-case nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2545 (aref template i)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2546 (error ?%)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2547 (cond ((= c ?a)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2548 (insert-buffer-substring emerge-A-buffer A-begin A-end))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2549 ((= c ?b)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2550 (insert-buffer-substring emerge-B-buffer B-begin B-end))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2551 ((= c ?%)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2552 (insert ?%))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2553 (t
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2554 (insert c))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2555 (insert c)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2556 (setq i (1+ i))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2557 (goto-char merge-begin)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2558 (aset diff-vector 6 'combined)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2559 (emerge-refresh-mode-line)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2560
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2561 (defun emerge-set-merge-mode (mode)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2562 "Set the major mode in a merge buffer.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2563 Overrides any change that the mode might make to the mode line or local
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2564 keymap. Leaves merge in fast mode."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2565 (interactive
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2566 (list (intern (completing-read "New major mode for merge buffer: "
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2567 obarray 'commandp t nil))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2568 (funcall mode)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2569 (emerge-refresh-mode-line)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2570 (if emerge-fast-mode
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2571 (emerge-fast-mode)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2572 (emerge-edit-mode)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2573
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2574 (defun emerge-one-line-window ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2575 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2576 (let ((window-min-height 1))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2577 (shrink-window (- (window-height) 2))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2578
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2579 ;;; Support routines
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2580
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2581 ;; Select a difference by placing the visual flags around the appropriate
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2582 ;; group of lines in the A, B, and merge buffers
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2583 (defun emerge-select-difference (n)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2584 (let ((emerge-globalized-difference-list emerge-difference-list)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2585 (emerge-globalized-number-of-differences emerge-number-of-differences))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2586 (emerge-place-flags-in-buffer emerge-A-buffer n 0 1)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2587 (emerge-place-flags-in-buffer emerge-B-buffer n 2 3)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2588 (emerge-place-flags-in-buffer nil n 4 5))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2589 (run-hooks 'emerge-select-hook))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2590
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2591 (defun emerge-place-flags-in-buffer (buffer difference before-index
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2592 after-index)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2593 (if buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2594 (emerge-eval-in-buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2595 buffer
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2596 (emerge-place-flags-in-buffer1 difference before-index after-index))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2597 (emerge-place-flags-in-buffer1 difference before-index after-index)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2598
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2599 (defun emerge-place-flags-in-buffer1 (difference before-index after-index)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2600 (let ((buffer-read-only nil))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2601 ;; insert the flag before the difference
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2602 (let ((before (aref (aref emerge-globalized-difference-list difference)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2603 before-index))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2604 here)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2605 (goto-char before)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2606 ;; insert the flag itself
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2607 (insert-before-markers emerge-before-flag)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2608 (setq here (point))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2609 ;; Put the marker(s) referring to this position 1 character before the
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2610 ;; end of the flag, so it won't be damaged by the user.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2611 ;; This gets a bit tricky, as there could be a number of markers
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2612 ;; that have to be moved.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2613 (set-marker before (1- before))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2614 (let ((n (1- difference)) after-marker before-marker diff-list)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2615 (while (and
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2616 (>= n 0)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2617 (progn
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2618 (setq diff-list (aref emerge-globalized-difference-list n)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2619 after-marker (aref diff-list after-index))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2620 (= after-marker here)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2621 (set-marker after-marker (1- after-marker))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2622 (setq before-marker (aref diff-list before-index))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2623 (if (= before-marker here)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2624 (setq before-marker (1- before-marker)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2625 (setq n (1- n)))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2626 ;; insert the flag after the difference
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2627 (let* ((after (aref (aref emerge-globalized-difference-list difference)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2628 after-index))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2629 (here (marker-position after)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2630 (goto-char here)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2631 ;; insert the flag itself
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2632 (insert emerge-after-flag)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2633 ;; Put the marker(s) referring to this position 1 character after the
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2634 ;; beginning of the flag, so it won't be damaged by the user.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2635 ;; This gets a bit tricky, as there could be a number of markers
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2636 ;; that have to be moved.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2637 (set-marker after (1+ after))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2638 (let ((n (1+ difference)) before-marker after-marker diff-list)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2639 (while (and
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2640 (< n emerge-globalized-number-of-differences)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2641 (progn
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2642 (setq diff-list (aref emerge-globalized-difference-list n)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2643 before-marker (aref diff-list before-index))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2644 (= before-marker here)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2645 (set-marker before-marker (1+ before-marker))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2646 (setq after-marker (aref diff-list after-index))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2647 (if (= after-marker here)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2648 (setq after-marker (1+ after-marker)))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2649 (setq n (1+ n)))))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2650
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2651 ;; Unselect a difference by removing the visual flags in the buffers.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2652 (defun emerge-unselect-difference (n)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2653 (let ((diff-vector (aref emerge-difference-list n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2654 (emerge-remove-flags-in-buffer emerge-A-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2655 (aref diff-vector 0) (aref diff-vector 1))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2656 (emerge-remove-flags-in-buffer emerge-B-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2657 (aref diff-vector 2) (aref diff-vector 3))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2658 (emerge-remove-flags-in-buffer emerge-merge-buffer
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2659 (aref diff-vector 4) (aref diff-vector 5)))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2660 (run-hooks 'emerge-unselect-hook))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2661
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2662 (defun emerge-remove-flags-in-buffer (buffer before after)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2663 (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2664 buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2665 (let ((buffer-read-only nil))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2666 ;; remove the flags, if they're there
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2667 (goto-char (- before (1- emerge-before-flag-length)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2668 (if (looking-at emerge-before-flag-match)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2669 (delete-char emerge-before-flag-length)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2670 ;; the flag isn't there
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2671 (ding)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2672 (message "Trouble removing flag"))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2673 (goto-char (1- after))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2674 (if (looking-at emerge-after-flag-match)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2675 (delete-char emerge-after-flag-length)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2676 ;; the flag isn't there
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2677 (ding)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2678 (message "Trouble removing flag")))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2679
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2680 ;; Select a difference, removing any flags that exist now.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2681 (defun emerge-unselect-and-select-difference (n &optional suppress-display)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2682 (if (and (>= emerge-current-difference 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2683 (< emerge-current-difference emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2684 (emerge-unselect-difference emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2685 (if (and (>= n 0) (< n emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2686 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2687 (emerge-select-difference n)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2688 (let* ((diff-vector (aref emerge-difference-list n))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2689 (selection-type (aref diff-vector 6)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2690 (if (eq selection-type 'default-A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2691 (aset diff-vector 6 'A)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2692 (if (eq selection-type 'default-B)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2693 (aset diff-vector 6 'B))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2694 (setq emerge-current-difference n)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2695 (if (not suppress-display)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2696 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2697 (emerge-recenter)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2698 (emerge-refresh-mode-line))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2699
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2700 ;; Perform tests to see whether user should be allowed to select a version
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2701 ;; of this difference:
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2702 ;; a valid difference has been selected; and
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2703 ;; the difference text in the merge buffer is:
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2704 ;; the A version (execute a-version), or
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2705 ;; the B version (execute b-version), or
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2706 ;; empty (execute neither-version), or
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2707 ;; argument FORCE is true (execute neither-version)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2708 ;; Otherwise, signal an error.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2709 (defun emerge-select-version (force a-version b-version neither-version)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2710 (emerge-validate-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2711 (let ((buffer-read-only nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2712 (let* ((diff-vector
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2713 (aref emerge-difference-list emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2714 (A-begin (1+ (aref diff-vector 0)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2715 (A-end (1- (aref diff-vector 1)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2716 (B-begin (1+ (aref diff-vector 2)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2717 (B-end (1- (aref diff-vector 3)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2718 (merge-begin (1+ (aref diff-vector 4)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2719 (merge-end (1- (aref diff-vector 5))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2720 (if (emerge-compare-buffers emerge-A-buffer A-begin A-end
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2721 emerge-merge-buffer merge-begin
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2722 merge-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2723 (funcall a-version)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2724 (if (emerge-compare-buffers emerge-B-buffer B-begin B-end
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2725 emerge-merge-buffer merge-begin
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2726 merge-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2727 (funcall b-version)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2728 (if (or force (= merge-begin merge-end))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2729 (funcall neither-version)
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2730 (error "This difference region has been edited")))))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2731
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2732 ;; Read a file name, handling all of the various defaulting rules.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2733
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2734 (defun emerge-read-file-name (prompt alternative-default-dir default-file
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2735 A-file)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2736 ;; `prompt' should not have trailing ": ", so that it can be modified
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2737 ;; according to context.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2738 ;; If alternative-default-dir is non-nil, it should be used as the default
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2739 ;; directory instead if default-directory, if emerge-default-last-directories
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2740 ;; is set.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2741 ;; If default-file is set, it should be used as the default value.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2742 ;; If A-file is set, and its directory is different from
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2743 ;; alternative-default-dir, and if emerge-default-last-directories is set,
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2744 ;; the default file should be the last part of A-file in the default
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2745 ;; directory. (Overriding default-file.)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2746 (cond
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2747 ;; If this is not the A-file argument (shown by non-nil A-file), and
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2748 ;; if emerge-default-last-directories is set, and
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2749 ;; the default directory exists but is not the same as the directory of the
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2750 ;; A-file,
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2751 ;; then make the default file have the same name as the A-file, but in
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2752 ;; the default directory.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2753 ((and emerge-default-last-directories
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2754 A-file
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2755 alternative-default-dir
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2756 (not (string-equal alternative-default-dir
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2757 (file-name-directory A-file))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2758 (read-file-name (format "%s (default %s): "
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2759 prompt (file-name-nondirectory A-file))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2760 alternative-default-dir
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2761 (concat alternative-default-dir
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2762 (file-name-nondirectory A-file))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2763 'confirm))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2764 ;; If there is a default file, use it.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2765 (default-file
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2766 (read-file-name (format "%s (default %s): " prompt default-file)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2767 ;; If emerge-default-last-directories is set, use the
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2768 ;; directory from the same argument of the last call of
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2769 ;; Emerge as the default for this argument.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2770 (and emerge-default-last-directories
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2771 alternative-default-dir)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2772 default-file 'confirm))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2773 (t
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2774 (read-file-name (concat prompt ": ")
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2775 ;; If emerge-default-last-directories is set, use the
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2776 ;; directory from the same argument of the last call of
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2777 ;; Emerge as the default for this argument.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2778 (and emerge-default-last-directories
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2779 alternative-default-dir)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
2780 nil 'confirm))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2781
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2782 ;; Revise the mode line to display which difference we have selected
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2783
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2784 (defun emerge-refresh-mode-line ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2785 (setq mode-line-buffer-identification
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2786 (list (format "Emerge: %%b diff %d of %d%s"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2787 (1+ emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2788 emerge-number-of-differences
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2789 (if (and (>= emerge-current-difference 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2790 (< emerge-current-difference
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2791 emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2792 (cdr (assq (aref (aref emerge-difference-list
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2793 emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2794 6)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2795 '((A . " - A")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2796 (B . " - B")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2797 (prefer-A . " - A*")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2798 (prefer-B . " - B*")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2799 (combined . " - comb"))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2800 ""))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2801 ;; Force mode-line redisplay
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2802 (set-buffer-modified-p (buffer-modified-p)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2803
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2804 ;; compare two regions in two buffers for containing the same text
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2805 (defun emerge-compare-buffers (buffer-x x-begin x-end buffer-y y-begin y-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2806 ;; first check that the two regions are the same length
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2807 (if (not (and (= (- x-end x-begin) (- y-end y-begin))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2808 nil
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2809 (catch 'exit
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2810 (while (< x-begin x-end)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2811 ;; bite off and compare no more than 1000 characters at a time
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2812 (let* ((compare-length (min (- x-end x-begin) 1000))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2813 (x-string (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2814 buffer-x
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2815 (buffer-substring x-begin
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2816 (+ x-begin compare-length))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2817 (y-string (emerge-eval-in-buffer
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2818 buffer-y
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2819 (buffer-substring y-begin
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2820 (+ y-begin compare-length)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2821 (if (not (string-equal x-string y-string))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2822 (throw 'exit nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2823 (setq x-begin (+ x-begin compare-length))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2824 (setq y-begin (+ y-begin compare-length)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2825 t)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2826
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2827 ;; Construct a unique buffer name.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2828 ;; The first one tried is prefixsuffix, then prefix<2>suffix,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2829 ;; prefix<3>suffix, etc.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2830 (defun emerge-unique-buffer-name (prefix suffix)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2831 (if (null (get-buffer (concat prefix suffix)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2832 (concat prefix suffix)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2833 (let ((n 2))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2834 (while (get-buffer (format "%s<%d>%s" prefix n suffix))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2835 (setq n (1+ n)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2836 (format "%s<%d>%s" prefix n suffix))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2837
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2838 ;; Verify that we have a difference selected.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2839 (defun emerge-validate-difference ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2840 (if (not (and (>= emerge-current-difference 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2841 (< emerge-current-difference emerge-number-of-differences)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2842 (error "No difference selected")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2843
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2844 ;;; Functions for saving and restoring a batch of variables
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2845
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2846 ;; These functions save (get the values of) and restore (set the values of)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2847 ;; a list of variables. The argument is a list of symbols (the names of
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2848 ;; the variables). A list element can also be a list of two functions,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2849 ;; the first of which (when called with no arguments) gets the value, and
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2850 ;; the second (when called with a value as an argment) sets the value.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2851 ;; A "function" is anything that funcall can handle as an argument.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2852
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2853 (defun emerge-save-variables (vars)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2854 (mapcar (function (lambda (v) (if (symbolp v)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2855 (symbol-value v)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2856 (funcall (car v)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2857 vars))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2858
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2859 (defun emerge-restore-variables (vars values)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2860 (while vars
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2861 (let ((var (car vars))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2862 (value (car values)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2863 (if (symbolp var)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2864 (set var value)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2865 (funcall (car (cdr var)) value)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2866 (setq vars (cdr vars))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2867 (setq values (cdr values))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2868
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2869 ;; Make a temporary file that only we have access to.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2870 ;; PREFIX is appended to emerge-temp-file-prefix to make the filename prefix.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2871 (defun emerge-make-temp-file (prefix)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2872 (let ((f (make-temp-name (concat emerge-temp-file-prefix prefix))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2873 ;; create the file
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2874 (write-region (point-min) (point-min) f nil 'no-message)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2875 (set-file-modes f emerge-temp-file-mode)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2876 f))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2877
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2878 ;;; Functions that query the user before he can write out the current buffer.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2879
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2880 (defun emerge-query-write-file ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2881 "Ask the user whether to write out an incomplete merge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2882 If answer is yes, call `write-file' to do so. See `emerge-query-and-call'
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2883 for details of the querying process."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2884 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2885 (emerge-query-and-call 'write-file))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2886
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2887 (defun emerge-query-save-buffer ()
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2888 "Ask the user whether to save an incomplete merge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2889 If answer is yes, call `save-buffer' to do so. See `emerge-query-and-call'
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2890 for details of the querying process."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2891 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2892 (emerge-query-and-call 'save-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2893
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2894 (defun emerge-query-and-call (command)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2895 "Ask the user whether to save or write out the incomplete merge.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2896 If answer is yes, call COMMAND interactively. During the call, the flags
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2897 around the current difference are removed."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2898 (if (yes-or-no-p "Do you really write to write out this unfinished merge? ")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2899 ;; He really wants to do it -- unselect the difference for the duration
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2900 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2901 (if (and (>= emerge-current-difference 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2902 (< emerge-current-difference emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2903 (emerge-unselect-difference emerge-current-difference))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2904 ;; call-interactively takes the value of current-prefix-arg as the
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2905 ;; prefix argument value to be passed to the command. Thus, we have
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2906 ;; to do nothing special to make sure the prefix argument is
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2907 ;; transmitted to the command.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2908 (call-interactively command)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2909 (if (and (>= emerge-current-difference 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2910 (< emerge-current-difference emerge-number-of-differences))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2911 (progn
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2912 (emerge-select-difference emerge-current-difference)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2913 (emerge-recenter))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2914 ;; He's being smart and not doing it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2915 (message "Not written")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2916
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2917 ;; Make sure the current buffer (for a file) has the same contents as the
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2918 ;; file on disk, and attempt to remedy the situation if not.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2919 ;; Signal an error if we can't make them the same, or the user doesn't want
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2920 ;; to do what is necessary to make them the same.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2921 (defun emerge-verify-file-buffer ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2922 ;; First check if the file has been modified since the buffer visited it.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2923 (if (verify-visited-file-modtime (current-buffer))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2924 (if (buffer-modified-p)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2925 ;; If buffer is not obsolete and is modified, offer to save
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2926 (if (yes-or-no-p (format "Save file %s? " buffer-file-name))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2927 (save-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2928 (error "Buffer out of sync for file %s" buffer-file-name))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2929 ;; If buffer is not obsolete and is not modified, do nothing
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2930 nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2931 (if (buffer-modified-p)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2932 ;; If buffer is obsolete and is modified, give error
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2933 (error "Buffer out of sync for file %s" buffer-file-name)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2934 ;; If buffer is obsolete and is not modified, offer to revert
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2935 (if (yes-or-no-p (format "Revert file %s? " buffer-file-name))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2936 (revert-buffer t t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2937 (error "Buffer out of sync for file %s" buffer-file-name)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2938
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2939 ;; Utilities that might have value outside of Emerge.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2940
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2941 ;; Set up the mode in the current buffer to duplicate the mode in another
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2942 ;; buffer.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2943 (defun emerge-copy-modes (buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2944 ;; Set the major mode
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2945 (funcall (emerge-eval-in-buffer buffer major-mode)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2946
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2947 ;; Define a key, even if a prefix of it is defined
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2948 (defun emerge-force-define-key (keymap key definition)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2949 "Like `define-key', but forcibly creates prefix characters as needed.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2950 If some prefix of KEY has a non-prefix definition, it is redefined."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2951 ;; Find out if a prefix of key is defined
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2952 (let ((v (lookup-key keymap key)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2953 ;; If so, undefine it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2954 (if (integerp v)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2955 (define-key keymap (substring key 0 v) nil)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2956 ;; Now define the key
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2957 (define-key keymap key definition))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2958
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2959 ;;;;; Improvements to describe-mode, so that it describes minor modes as well
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2960 ;;;;; as the major mode
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2961 ;;(defun describe-mode (&optional minor)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2962 ;; "Display documentation of current major mode.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2963 ;;If optional arg MINOR is non-nil (or prefix argument is given if interactive),
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2964 ;;display documentation of active minor modes as well.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2965 ;;For this to work correctly for a minor mode, the mode's indicator variable
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2966 ;;\(listed in `minor-mode-alist') must also be a function whose documentation
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2967 ;;describes the minor mode."
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2968 ;; (interactive)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2969 ;; (with-output-to-temp-buffer "*Help*"
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2970 ;; (princ mode-name)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2971 ;; (princ " Mode:\n")
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2972 ;; (princ (documentation major-mode))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2973 ;; (let ((minor-modes minor-mode-alist)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2974 ;; (locals (buffer-local-variables)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2975 ;; (while minor-modes
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2976 ;; (let* ((minor-mode (car (car minor-modes)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2977 ;; (indicator (car (cdr (car minor-modes))))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2978 ;; (local-binding (assq minor-mode locals)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2979 ;; ;; Document a minor mode if it is listed in minor-mode-alist,
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2980 ;; ;; bound locally in this buffer, non-nil, and has a function
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2981 ;; ;; definition.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2982 ;; (if (and local-binding
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2983 ;; (cdr local-binding)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2984 ;; (fboundp minor-mode))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2985 ;; (progn
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2986 ;; (princ (format "\n\n\n%s minor mode (indicator%s):\n"
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2987 ;; minor-mode indicator))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2988 ;; (princ (documentation minor-mode)))))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2989 ;; (setq minor-modes (cdr minor-modes))))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2990 ;; (print-help-return-message)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2991
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2992 ;; This goes with the redefinition of describe-mode.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2993 ;;;; Adjust things so that keyboard macro definitions are documented correctly.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2994 ;;(fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2995
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2996 ;; substitute-key-definition should work now.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2997 ;;;; Function to shadow a definition in a keymap with definitions in another.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2998 ;;(defun emerge-shadow-key-definition (olddef newdef keymap shadowmap)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
2999 ;; "Shadow OLDDEF with NEWDEF for any keys in KEYMAP with entries in SHADOWMAP.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3000 ;;In other words, SHADOWMAP will now shadow all definitions of OLDDEF in KEYMAP
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3001 ;;with NEWDEF. Does not affect keys that are already defined in SHADOWMAP,
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3002 ;;including those whose definition is OLDDEF."
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3003 ;; ;; loop through all keymaps accessible from keymap
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3004 ;; (let ((maps (accessible-keymaps keymap)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3005 ;; (while maps
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3006 ;; (let ((prefix (car (car maps)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3007 ;; (map (cdr (car maps))))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3008 ;; ;; examine a keymap
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3009 ;; (if (arrayp map)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3010 ;; ;; array keymap
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3011 ;; (let ((len (length map))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3012 ;; (i 0))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3013 ;; (while (< i len)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3014 ;; (if (eq (aref map i) olddef)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3015 ;; ;; set the shadowing definition
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3016 ;; (let ((key (concat prefix (char-to-string i))))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3017 ;; (emerge-define-key-if-possible shadowmap key newdef)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3018 ;; (setq i (1+ i))))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3019 ;; ;; sparse keymap
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3020 ;; (while map
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3021 ;; (if (eq (cdr-safe (car-safe map)) olddef)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3022 ;; ;; set the shadowing definition
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3023 ;; (let ((key
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3024 ;; (concat prefix (char-to-string (car (car map))))))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3025 ;; (emerge-define-key-if-possible shadowmap key newdef)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3026 ;; (setq map (cdr map)))))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3027 ;; (setq maps (cdr maps)))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3028
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3029 ;; Define a key if it (or a prefix) is not already defined in the map.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3030 (defun emerge-define-key-if-possible (keymap key definition)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3031 ;; look up the present definition of the key
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3032 (let ((present (lookup-key keymap key)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3033 (if (integerp present)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3034 ;; if it is "too long", look up the valid prefix
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3035 (if (not (lookup-key keymap (substring key 0 present)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3036 ;; if the prefix isn't defined, define it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3037 (define-key keymap key definition))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3038 ;; if there is no present definition, define it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3039 (if (not present)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3040 (define-key keymap key definition)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3041
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3042 ;; Ordinary substitute-key-definition should do this now.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3043 ;;(defun emerge-recursively-substitute-key-definition (olddef newdef keymap)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3044 ;; "Like `substitute-key-definition', but act recursively on subkeymaps.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3045 ;;Make sure that subordinate keymaps aren't shared with other keymaps!
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3046 ;;\(`copy-keymap' will suffice.)"
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3047 ;; ;; Loop through all keymaps accessible from keymap
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3048 ;; (let ((maps (accessible-keymaps keymap)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3049 ;; (while maps
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3050 ;; ;; Substitute in this keymap
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3051 ;; (substitute-key-definition olddef newdef (cdr (car maps)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3052 ;; (setq maps (cdr maps)))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3053
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3054 ;; Show the name of the file in the buffer.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3055 (defun emerge-show-file-name ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3056 "Displays the name of the file loaded into the current buffer.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3057 If the name won't fit on one line, the minibuffer is expanded to hold it,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3058 and the command waits for a keystroke from the user. If the keystroke is
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3059 SPC, it is ignored; if it is anything else, it is processed as a command."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3060 (interactive)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3061 (let ((name (buffer-file-name)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3062 (or name
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3063 (setq name "Buffer has no file name."))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3064 (save-window-excursion
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3065 (select-window (minibuffer-window))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3066 (erase-buffer)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3067 (insert name)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3068 (if (not (pos-visible-in-window-p))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3069 (let ((echo-keystrokes 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3070 (while (and (not (pos-visible-in-window-p))
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3071 (> (1- (screen-height)) (window-height)))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3072 (enlarge-window 1))
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3073 (let ((c (read-event)))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3074 (if (not (eq c 32))
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3075 (setq unread-command-events (list c)))))))))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3076
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3077 ;; Improved auto-save file names.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3078 ;; This function fixes many problems with the standard auto-save file names:
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3079 ;; Auto-save files for non-file buffers get put in the default directory
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3080 ;; for the buffer, whether that makes sense or not.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3081 ;; Auto-save files for file buffers get put in the directory of the file,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3082 ;; regardless of whether we can write into it or not.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3083 ;; Auto-save files for non-file buffers don't use the process id, so if a
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3084 ;; user runs more than on Emacs, they can make auto-save files that overwrite
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3085 ;; each other.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3086 ;; To use this function, do:
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3087 ;; (fset 'make-auto-save-file-name
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3088 ;; (symbol-function 'emerge-make-auto-save-file-name))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3089 (defun emerge-make-auto-save-file-name ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3090 "Return file name to use for auto-saves of current buffer.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3091 Does not consider `auto-save-visited-file-name';
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3092 that is checked before calling this function.
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3093 You can redefine this for customization.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3094 See also `auto-save-file-name-p'."
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3095 (if buffer-file-name
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3096 ;; if buffer has a file, try the format <file directory>/#<file name>#
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3097 (let ((f (concat (file-name-directory buffer-file-name)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3098 "#"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3099 (file-name-nondirectory buffer-file-name)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3100 "#")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3101 (if (file-writable-p f)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3102 ;; the file is writable, so use it
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3103 f
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3104 ;; the file isn't writable, so use the format
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3105 ;; ~/#&<file name>&<hash of directory>#
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3106 (concat (getenv "HOME")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3107 "/#&"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3108 (file-name-nondirectory buffer-file-name)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3109 "&"
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3110 (emerge-hash-string-into-string
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3111 (file-name-directory buffer-file-name))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3112 "#")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3113 ;; if buffer has no file, use the format ~/#%<buffer name>%<process id>#
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3114 (expand-file-name (concat (getenv "HOME")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3115 "/#%"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3116 ;; quote / into \! and \ into \\
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3117 (emerge-unslashify-name (buffer-name))
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3118 "%"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3119 (make-temp-name "")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3120 "#"))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3121
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3122 ;; Hash a string into five characters more-or-less suitable for use in a file
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3123 ;; name. (Allowed characters are ! through ~, except /.)
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3124 (defun emerge-hash-string-into-string (s)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3125 (let ((bins (vector 0 0 0 0 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3126 (i 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3127 (while (< i (length s))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3128 (aset bins (% i 5) (% (+ (* (aref bins (% i 5)) 35)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3129 (aref s i))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3130 65536))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3131 (setq i (1+ i)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3132 (mapconcat (function (lambda (b)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3133 (setq b (+ (% b 93) ?!))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3134 (if (>= b ?/)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3135 (setq b (1+ b)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3136 (char-to-string b)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3137 bins "")))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3138
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3139 ;; Quote any /s in a string by replacing them with \!.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3140 ;; Also, replace any \s by \\, to make it one-to-one.
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3141 (defun emerge-unslashify-name (s)
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3142 (let ((limit 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3143 (while (string-match "[/\\]" s limit)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3144 (setq s (concat (substring s 0 (match-beginning 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3145 (if (string= (substring s (match-beginning 0)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3146 (match-end 0))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3147 "/")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3148 "\\!"
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3149 "\\\\")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3150 (substring s (match-end 0))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3151 (setq limit (1+ (match-end 0)))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3152 s)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3153
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3154 ;; Metacharacters that have to be protected from the shell when executing
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3155 ;; a diff/diff3 command.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3156 (defvar emerge-metachars "[ \t\n!\"#$&'()*;<=>?[\\^`{|~]"
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3157 "Characters that must be quoted with \\ when used in a shell command line.
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3158 More precisely, a [...] regexp to match any one such character.")
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3159
2770
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3160 ;; Quote metacharacters (using \) when executing a diff/diff3 command.
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3161 (defun emerge-protect-metachars (s)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3162 (let ((limit 0))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3163 (while (string-match emerge-metachars s limit)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3164 (setq s (concat (substring s 0 (match-beginning 0))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3165 "\\"
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3166 (substring s (match-beginning 0))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3167 (setq limit (1+ (match-end 0)))))
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3168 s)
6574a888b539 Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents: 2496
diff changeset
3169
2771
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3170 (provide 'emerge)
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3171
2d2b77186415 (emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents: 2770
diff changeset
3172 ;;; emerge.el ends here