Mercurial > emacs
annotate lisp/emerge.el @ 21679:11cba7297255
Add Slovak.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 20 Apr 1998 16:40:11 +0000 |
parents | 886039ba7b3e |
children | 171bb1a9c260 |
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 |
14659 | 5 ;; Author: Dale R. Worley <worley@world.std.com> |
2771
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 | 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 | 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 | 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] |
14110
454c8269c985
(menu-bar-emerge-menu): Delete spaces before `...'.
Karl Heuer <kwzh@gnu.org>
parents:
14040
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] |
14110
454c8269c985
(menu-bar-emerge-menu): Delete spaces before `...'.
Karl Heuer <kwzh@gnu.org>
parents:
14040
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] |
14110
454c8269c985
(menu-bar-emerge-menu): Delete spaces before `...'.
Karl Heuer <kwzh@gnu.org>
parents:
14040
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] |
14110
454c8269c985
(menu-bar-emerge-menu): Delete spaces before `...'.
Karl Heuer <kwzh@gnu.org>
parents:
14040
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] |
14110
454c8269c985
(menu-bar-emerge-menu): Delete spaces before `...'.
Karl Heuer <kwzh@gnu.org>
parents:
14040
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] |
14110
454c8269c985
(menu-bar-emerge-menu): Delete spaces before `...'.
Karl Heuer <kwzh@gnu.org>
parents:
14040
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] |
14110
454c8269c985
(menu-bar-emerge-menu): Delete spaces before `...'.
Karl Heuer <kwzh@gnu.org>
parents:
14040
diff
changeset
|
49 '("Buffers..." . emerge-buffers)) |
5798
c75960d5f2ca
(menu-bar-emerge-menu): New map.
Richard M. Stallman <rms@gnu.org>
parents:
5796
diff
changeset
|
50 |
583 | 51 ;;; Macros |
52 | |
53 (defmacro emerge-eval-in-buffer (buffer &rest forms) | |
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 | 56 (` (let ((StartBuffer (current-buffer))) |
57 (unwind-protect | |
58 (progn | |
59 (set-buffer (, buffer)) | |
60 (,@ forms)) | |
61 (set-buffer StartBuffer))))) | |
62 | |
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 | 69 (` (progn |
70 (defvar (, var) (, value) (, doc)) | |
71 (make-variable-buffer-local '(, var)) | |
72 (put '(, var) 'preserved t)))) | |
73 | |
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 | 81 (if (not (assq 'emerge-mode minor-mode-alist)) |
82 (setq minor-mode-alist (append emerge-minor-modes-list | |
83 minor-mode-alist))) | |
84 | |
85 ;; We need to define this function so describe-mode can describe Emerge mode. | |
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 | 97 |
98 Commands: | |
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 | 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 | 104 "The version of Emerge.") |
105 | |
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 | 109 (interactive) |
110 (if (interactive-p) | |
111 (message "Emerge version %s" (emerge-version)) | |
112 emerge-version)) | |
113 | |
114 ;;; Emerge configuration variables | |
115 | |
20597 | 116 (defgroup emerge nil |
117 "Merge diffs under Emacs control." | |
118 :group 'tools) | |
119 | |
583 | 120 ;; Commands that produce difference files |
121 ;; All that can be configured is the name of the programs to execute | |
122 ;; (emerge-diff-program and emerge-diff3-program) and the options | |
123 ;; to be provided (emerge-diff-options). The order in which the file names | |
124 ;; are given is fixed. | |
125 ;; The file names are always expanded (see expand-file-name) before being | |
126 ;; 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
|
127 ;; understands `~'. |
583 | 128 ;; The code which processes the diff/diff3 output depends on all the |
129 ;; finicky details of their output, including the somewhat strange | |
130 ;; way they number lines of a file. | |
20597 | 131 (defcustom emerge-diff-program "diff" |
132 "*Name of the program which compares two files." | |
133 :type 'string | |
134 :group 'emerge) | |
135 (defcustom 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
|
136 "*Name of the program which compares three files. |
20597 | 137 Its arguments are the ancestor file and the two variant files." |
138 :type 'string | |
139 :group 'emerge) | |
140 (defcustom emerge-diff-options "" | |
141 "*Options to pass to `emerge-diff-program' and `emerge-diff3-program'." | |
142 :type 'string | |
143 :group 'emerge) | |
144 (defcustom emerge-match-diff-line | |
145 (let ((x "\\([0-9]+\\)\\(\\|,\\([0-9]+\\)\\)")) | |
146 (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
|
147 "*Pattern to match lines produced by diff that describe differences. |
20597 | 148 This is as opposed to lines from the source files." |
149 :type 'regexp | |
150 :group 'emerge) | |
151 (defcustom emerge-diff-ok-lines-regexp | |
583 | 152 "^\\([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
|
153 "*Regexp that matches normal output lines from `emerge-diff-program'. |
20597 | 154 Lines that do not match are assumed to be error messages." |
155 :type 'regexp | |
156 :group 'emerge) | |
157 (defcustom emerge-diff3-ok-lines-regexp | |
583 | 158 "^\\([1-3]:\\|====\\| \\)" |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
159 "*Regexp that matches normal output lines from `emerge-diff3-program'. |
20597 | 160 Lines that do not match are assumed to be error messages." |
161 :type 'regexp | |
162 :group 'emerge) | |
583 | 163 |
20597 | 164 (defcustom emerge-rcs-ci-program "ci" |
165 "*Name of the program that checks in RCS revisions." | |
166 :type 'string | |
167 :group 'emerge) | |
168 (defcustom emerge-rcs-co-program "co" | |
169 "*Name of the program that checks out RCS revisions." | |
170 :type 'string | |
171 :group 'emerge) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
172 |
20597 | 173 (defcustom 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
|
174 "*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
|
175 \(You can explicitly request processing the local-variables |
20597 | 176 by executing `(hack-local-variables)'.)" |
177 :type 'boolean | |
178 :group 'emerge) | |
179 (defcustom 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
|
180 "*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
|
181 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
|
182 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
|
183 If nil: In such circumstances, the A or B file that is present will be |
20597 | 184 copied to the designated output file." |
185 :type 'boolean | |
186 :group 'emerge) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
187 |
20597 | 188 (defcustom emerge-before-flag "vvvvvvvvvvvvvvvvvvvv\n" |
5796
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
189 "*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
|
190 Must be set before Emerge is loaded, or emerge-new-flags must be run |
20597 | 191 after setting." |
192 :type 'string | |
193 :group 'emerge) | |
194 (defcustom emerge-after-flag "^^^^^^^^^^^^^^^^^^^^\n" | |
5796
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
195 "*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
|
196 Must be set before Emerge is loaded, or emerge-new-flags must be run |
20597 | 197 after setting." |
198 :type 'string | |
199 :group 'emerge) | |
5796
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
200 |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
201 ;; Hook variables |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
202 |
20597 | 203 (defcustom emerge-startup-hook nil |
204 "*Hook to run in the merge buffer after the merge has been set up." | |
205 :type 'hook | |
206 :group 'emerge) | |
207 (defcustom emerge-select-hook nil | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
208 "*Hook to run after a difference has been selected. |
20597 | 209 The variable `n' holds the (internal) number of the difference." |
210 :type 'hook | |
211 :group 'emerge) | |
212 (defcustom emerge-unselect-hook nil | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
213 "*Hook to run after a difference has been unselected. |
20597 | 214 The variable `n' holds the (internal) number of the difference." |
215 :type 'hook | |
216 :group 'emerge) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
217 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
218 ;; 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
|
219 ;; Emerge commands. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
220 |
20597 | 221 (defcustom 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
|
222 "*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
|
223 If non-nil, filenames complete in the directory of the last argument of the |
20597 | 224 same type to an `emerge-files...' command." |
225 :type 'boolean | |
226 :group 'emerge) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
227 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
228 (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
|
229 "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
|
230 (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
|
231 "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
|
232 (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
|
233 "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
|
234 (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
|
235 "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
|
236 (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
|
237 "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
|
238 (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
|
239 "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
|
240 (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
|
241 "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
|
242 |
5796
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
243 (defvar emerge-before-flag-length) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
244 (defvar emerge-before-flag-lines) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
245 (defvar emerge-before-flag-match) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
246 (defvar emerge-after-flag-length) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
247 (defvar emerge-after-flag-lines) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
248 (defvar emerge-after-flag-match) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
249 (defvar emerge-diff-buffer) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
250 (defvar emerge-diff-error-buffer) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
251 (defvar emerge-prefix-argument) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
252 (defvar emerge-file-out) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
253 (defvar emerge-exit-func) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
254 (defvar emerge-globalized-difference-list) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
255 (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
|
256 |
583 | 257 ;; The flags used to mark differences in the buffers. |
258 | |
259 ;; These function definitions need to be up here, because they are used | |
260 ;; during loading. | |
261 (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
|
262 "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
|
263 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
|
264 depend on the flags." |
583 | 265 (setq emerge-before-flag-length (length emerge-before-flag)) |
266 (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
|
267 (emerge-count-matches-string emerge-before-flag "\n")) |
583 | 268 (setq emerge-before-flag-match (regexp-quote emerge-before-flag)) |
269 (setq emerge-after-flag-length (length emerge-after-flag)) | |
270 (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
|
271 (emerge-count-matches-string emerge-after-flag "\n")) |
583 | 272 (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
|
273 |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
274 (defun emerge-count-matches-string (string regexp) |
583 | 275 "Return the number of matches in STRING for REGEXP." |
276 (let ((i 0) | |
277 (count 0)) | |
278 (while (string-match regexp string i) | |
279 (setq count (1+ count)) | |
280 (setq i (match-end 0))) | |
281 count)) | |
282 | |
283 ;; Calculate dependent variables | |
284 (emerge-new-flags) | |
285 | |
20597 | 286 (defcustom emerge-min-visible-lines 3 |
583 | 287 "*Number of lines that we want to show above and below the flags when we are |
20597 | 288 displaying a difference." |
289 :type 'integer | |
290 :group 'emerge) | |
583 | 291 |
20597 | 292 (defcustom emerge-temp-file-prefix |
9606 | 293 (let ((env (or (getenv "TMPDIR") |
294 (getenv "TMP") | |
295 (getenv "TEMP"))) | |
583 | 296 d) |
297 (setq d (if (and env (> (length env) 0)) | |
298 env | |
299 "/tmp")) | |
300 (if (= (aref d (1- (length d))) ?/) | |
301 (setq d (substring d 0 -1))) | |
302 (concat d "/emerge")) | |
303 "*Prefix to put on Emerge temporary file names. | |
20597 | 304 Do not start with `~/' or `~user-name/'." |
305 :type 'string | |
306 :group 'emerge) | |
583 | 307 |
20597 | 308 (defcustom emerge-temp-file-mode 384 ; u=rw only |
309 "*Mode for Emerge temporary files." | |
310 :type 'integer | |
311 :group 'emerge) | |
583 | 312 |
20597 | 313 (defcustom emerge-combine-versions-template |
14668
a281f3b85f32
(emerge-combine-versions-template): Make the
Richard M. Stallman <rms@gnu.org>
parents:
14659
diff
changeset
|
314 "#ifdef NEW\n%b#else /* not NEW */\n%a#endif /* not NEW */\n" |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
315 "*Template for `emerge-combine-versions' to combine the two versions. |
583 | 316 The template is inserted as a string, with the following interpolations: |
317 %a the A version of the difference | |
318 %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
|
319 %% the character `%' |
583 | 320 Don't forget to end the template with a newline. |
321 Note that this variable can be made local to a particular merge buffer by | |
20597 | 322 giving a prefix argument to `emerge-set-combine-versions-template'." |
323 :type 'string | |
324 :group 'emerge) | |
583 | 325 |
326 ;; Build keymaps | |
327 | |
328 (defvar emerge-basic-keymap nil | |
329 "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
|
330 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
|
331 must be prefixed by \\<emerge-fast-keymap>\\[emerge-basic-keymap] in `edit' mode.") |
583 | 332 |
333 (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
|
334 "Local keymap used in Emerge `fast' mode. |
583 | 335 Makes Emerge commands directly available.") |
336 | |
5796
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
337 (defvar emerge-options-menu |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
338 (make-sparse-keymap "Options")) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
339 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
340 (defvar emerge-merge-menu |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
341 (make-sparse-keymap "Merge")) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
342 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
343 (defvar emerge-move-menu |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
344 (make-sparse-keymap "Move")) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
345 |
20597 | 346 (defcustom emerge-command-prefix "\C-c\C-c" |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
347 "*Command prefix for Emerge commands in `edit' mode. |
20597 | 348 Must be set before Emerge is loaded." |
349 :type 'string | |
350 :group 'emerge) | |
583 | 351 |
352 ;; This function sets up the fixed keymaps. It is executed when the first | |
353 ;; Emerge is done to allow the user maximum time to set up the global keymap. | |
354 (defun emerge-setup-fixed-keymaps () | |
355 ;; Set up the basic keymap | |
356 (setq emerge-basic-keymap (make-keymap)) | |
357 (suppress-keymap emerge-basic-keymap) ; this sets 0..9 to digit-argument and | |
358 ; - to negative-argument | |
359 (define-key emerge-basic-keymap "p" 'emerge-previous-difference) | |
360 (define-key emerge-basic-keymap "n" 'emerge-next-difference) | |
361 (define-key emerge-basic-keymap "a" 'emerge-select-A) | |
362 (define-key emerge-basic-keymap "b" 'emerge-select-B) | |
363 (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
|
364 (define-key emerge-basic-keymap "." 'emerge-find-difference) |
583 | 365 (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
|
366 (define-key emerge-basic-keymap "\C-]" 'emerge-abort) |
583 | 367 (define-key emerge-basic-keymap "f" 'emerge-fast-mode) |
368 (define-key emerge-basic-keymap "e" 'emerge-edit-mode) | |
369 (define-key emerge-basic-keymap "s" nil) | |
370 (define-key emerge-basic-keymap "sa" 'emerge-auto-advance) | |
371 (define-key emerge-basic-keymap "ss" 'emerge-skip-prefers) | |
372 (define-key emerge-basic-keymap "l" 'emerge-recenter) | |
373 (define-key emerge-basic-keymap "d" nil) | |
374 (define-key emerge-basic-keymap "da" 'emerge-default-A) | |
375 (define-key emerge-basic-keymap "db" 'emerge-default-B) | |
376 (define-key emerge-basic-keymap "c" nil) | |
377 (define-key emerge-basic-keymap "ca" 'emerge-copy-as-kill-A) | |
378 (define-key emerge-basic-keymap "cb" 'emerge-copy-as-kill-B) | |
379 (define-key emerge-basic-keymap "i" nil) | |
380 (define-key emerge-basic-keymap "ia" 'emerge-insert-A) | |
381 (define-key emerge-basic-keymap "ib" 'emerge-insert-B) | |
382 (define-key emerge-basic-keymap "m" 'emerge-mark-difference) | |
383 (define-key emerge-basic-keymap "v" 'emerge-scroll-up) | |
384 (define-key emerge-basic-keymap "^" 'emerge-scroll-down) | |
385 (define-key emerge-basic-keymap "<" 'emerge-scroll-left) | |
386 (define-key emerge-basic-keymap ">" 'emerge-scroll-right) | |
387 (define-key emerge-basic-keymap "|" 'emerge-scroll-reset) | |
388 (define-key emerge-basic-keymap "x" nil) | |
389 (define-key emerge-basic-keymap "x1" 'emerge-one-line-window) | |
390 (define-key emerge-basic-keymap "xc" 'emerge-combine-versions) | |
391 (define-key emerge-basic-keymap "xC" 'emerge-combine-versions-register) | |
392 (define-key emerge-basic-keymap "xf" 'emerge-file-names) | |
393 (define-key emerge-basic-keymap "xj" 'emerge-join-differences) | |
394 (define-key emerge-basic-keymap "xl" 'emerge-line-numbers) | |
395 (define-key emerge-basic-keymap "xm" 'emerge-set-merge-mode) | |
396 (define-key emerge-basic-keymap "xs" 'emerge-split-difference) | |
397 (define-key emerge-basic-keymap "xt" 'emerge-trim-difference) | |
398 (define-key emerge-basic-keymap "xx" 'emerge-set-combine-versions-template) | |
399 ;; Allow emerge-basic-keymap to be referenced indirectly | |
400 (fset 'emerge-basic-keymap emerge-basic-keymap) | |
401 ;; Set up the fast mode keymap | |
402 (setq emerge-fast-keymap (copy-keymap emerge-basic-keymap)) | |
403 ;; Allow prefixed commands to work in fast mode | |
404 (define-key emerge-fast-keymap emerge-command-prefix 'emerge-basic-keymap) | |
405 ;; Allow emerge-fast-keymap to be referenced indirectly | |
406 (fset 'emerge-fast-keymap emerge-fast-keymap) | |
407 ;; 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
|
408 (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
|
409 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
|
410 (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
|
411 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
|
412 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
413 (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
|
414 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
415 (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
|
416 (cons "Options" emerge-options-menu)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
417 (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
|
418 (cons "Merge" emerge-merge-menu)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
419 (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
|
420 (cons "Move" emerge-move-menu)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
421 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
422 (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
|
423 '("Scroll Reset" . emerge-scroll-reset)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
424 (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
|
425 '("Scroll Right" . emerge-scroll-right)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
426 (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
|
427 '("Scroll Left" . emerge-scroll-left)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
428 (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
|
429 '("Scroll Down" . emerge-scroll-down)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
430 (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
|
431 '("Scroll Up" . emerge-scroll-up)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
432 (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
|
433 '("Recenter" . emerge-recenter)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
434 (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
|
435 '("Mark Difference" . emerge-mark-difference)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
436 (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
|
437 '("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
|
438 (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
|
439 '("Find Difference" . emerge-find-difference)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
440 (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
|
441 '("Previous Difference" . emerge-previous-difference)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
442 (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
|
443 '("Next Difference" . emerge-next-difference)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
444 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
445 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
446 (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
|
447 '("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
|
448 (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
|
449 '("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
|
450 (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
|
451 '("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
|
452 (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
|
453 '("Default B" . emerge-default-B)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
454 (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
|
455 '("Default A" . emerge-default-A)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
456 (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
|
457 '("Skip Prefers" . emerge-skip-prefers)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
458 (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
|
459 '("Auto Advance" . emerge-auto-advance)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
460 (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
|
461 '("Edit Mode" . emerge-edit-mode)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
462 (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
|
463 '("Fast Mode" . emerge-fast-mode)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
464 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
465 (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
|
466 (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
|
467 (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
|
468 '("Split Difference" . emerge-split-difference)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
469 (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
|
470 '("Join Differences" . emerge-join-differences)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
471 (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
|
472 '("Trim Difference" . emerge-trim-difference)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
473 (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
|
474 '("Combine Versions" . emerge-combine-versions)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
475 (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
|
476 '("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
|
477 (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
|
478 '("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
|
479 (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
|
480 '("Insert B" . emerge-insert-B)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
481 (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
|
482 '("Insert A" . emerge-insert-A)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
483 (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
|
484 '("Select B" . emerge-select-B)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
485 (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
|
486 '("Select A" . emerge-select-A))) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
487 |
583 | 488 |
489 ;; Variables which control each merge. They are local to the merge buffer. | |
490 | |
491 ;; Mode variables | |
492 (emerge-defvar-local emerge-mode nil | |
493 "Indicator for emerge-mode.") | |
494 (emerge-defvar-local emerge-fast-mode nil | |
495 "Indicator for emerge-mode fast submode.") | |
496 (emerge-defvar-local emerge-edit-mode nil | |
497 "Indicator for emerge-mode edit submode.") | |
498 (emerge-defvar-local emerge-A-buffer nil | |
499 "The buffer in which the A variant is stored.") | |
500 (emerge-defvar-local emerge-B-buffer nil | |
501 "The buffer in which the B variant is stored.") | |
502 (emerge-defvar-local emerge-merge-buffer nil | |
503 "The buffer in which the merged file is manipulated.") | |
504 (emerge-defvar-local emerge-ancestor-buffer nil | |
505 "The buffer in which the ancestor variant is stored, | |
506 or nil if there is none.") | |
507 | |
508 (defconst emerge-saved-variables | |
509 '((buffer-modified-p set-buffer-modified-p) | |
510 buffer-read-only | |
511 buffer-auto-save-file-name) | |
512 "Variables and properties of a buffer which are saved, modified and restored | |
513 during a merge.") | |
514 (defconst emerge-merging-values '(nil t nil) | |
515 "Values to be assigned to emerge-saved-variables during a merge.") | |
516 | |
517 (emerge-defvar-local emerge-A-buffer-values nil | |
518 "Remembers emerge-saved-variables for emerge-A-buffer.") | |
519 (emerge-defvar-local emerge-B-buffer-values nil | |
520 "Remembers emerge-saved-variables for emerge-B-buffer.") | |
521 | |
522 (emerge-defvar-local emerge-difference-list nil | |
523 "Vector of differences between the variants, and markers in the buffers to | |
524 show where they are. Each difference is represented by a vector of seven | |
525 elements. The first two are markers to the beginning and end of the difference | |
526 section in the A buffer, the second two are markers for the B buffer, the third | |
527 two are markers for the merge buffer, and the last element is the \"state\" of | |
528 that difference in the merge buffer. | |
529 A section of a buffer is described by two markers, one to the beginning of | |
530 the first line of the section, and one to the beginning of the first line | |
531 after the section. (If the section is empty, both markers point to the same | |
532 point.) If the section is part of the selected difference, then the markers | |
533 are moved into the flags, so the user can edit the section without disturbing | |
534 the markers. | |
535 The \"states\" are: | |
536 A the merge buffer currently contains the A variant | |
537 B the merge buffer currently contains the B variant | |
538 default-A the merge buffer contains the A variant by default, | |
539 but this difference hasn't been selected yet, so | |
540 change-default commands can alter it | |
541 default-B the merge buffer contains the B variant by default, | |
542 but this difference hasn't been selected yet, so | |
543 change-default commands can alter it | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2773
diff
changeset
|
544 prefer-A in a three-file merge, the A variant is the preferred |
583 | 545 choice |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2773
diff
changeset
|
546 prefer-B in a three-file merge, the B variant is the preferred |
583 | 547 choice") |
548 (emerge-defvar-local emerge-current-difference -1 | |
549 "The difference that is currently selected.") | |
550 (emerge-defvar-local emerge-number-of-differences nil | |
551 "Number of differences found.") | |
552 (emerge-defvar-local emerge-edit-keymap nil | |
553 "The local keymap for the merge buffer, with the emerge commands defined in | |
554 it. Used to save the local keymap during fast mode, when the local keymap is | |
555 replaced by emerge-fast-keymap.") | |
556 (emerge-defvar-local emerge-old-keymap nil | |
557 "The original local keymap for the merge buffer.") | |
558 (emerge-defvar-local emerge-auto-advance nil | |
559 "*If non-nil, emerge-select-A and emerge-select-B automatically advance to | |
560 the next difference.") | |
561 (emerge-defvar-local emerge-skip-prefers nil | |
562 "*If non-nil, differences for which there is a preference are automatically | |
563 skipped.") | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
564 (emerge-defvar-local emerge-quit-hook nil |
583 | 565 "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
|
566 `emerge-prefix-argument' will hold the prefix argument of the `emerge-quit' |
583 | 567 command. |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
568 This is *not* a user option, since Emerge uses it for its own processing.") |
583 | 569 (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
|
570 "Describes output destination of emerge, for `emerge-file-names'.") |
583 | 571 |
572 ;;; Setup functions for two-file mode. | |
573 | |
574 (defun emerge-files-internal (file-A file-B &optional startup-hooks quit-hooks | |
575 output-file) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
576 (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
|
577 (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
|
578 (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
|
579 (error "File `%s' does not exist or is not readable" file-B)) |
583 | 580 (let ((buffer-A (find-file-noselect file-A)) |
581 (buffer-B (find-file-noselect file-B))) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
582 ;; Record the directories of the files |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
583 (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
|
584 (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
|
585 (if output-file |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
586 (setq emerge-last-dir-output (file-name-directory output-file))) |
583 | 587 ;; 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
|
588 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
589 buffer-A |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
590 (widen) |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
591 (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
|
592 (if temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
593 (setq file-A temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
594 startup-hooks |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
595 (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
|
596 startup-hooks)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
597 ;; 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
|
598 (emerge-verify-file-buffer)))) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
599 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
600 buffer-B |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
601 (widen) |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
602 (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
|
603 (if temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
604 (setq file-B temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
605 startup-hooks |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
606 (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
|
607 startup-hooks)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
608 ;; 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
|
609 (emerge-verify-file-buffer)))) |
583 | 610 (emerge-setup buffer-A file-A buffer-B file-B startup-hooks quit-hooks |
611 output-file))) | |
612 | |
613 ;; Start up Emerge on two files | |
614 (defun emerge-setup (buffer-A file-A buffer-B file-B startup-hooks quit-hooks | |
615 output-file) | |
616 (setq file-A (expand-file-name file-A)) | |
617 (setq file-B (expand-file-name file-B)) | |
618 (setq output-file (and output-file (expand-file-name output-file))) | |
619 (let* ((merge-buffer-name (emerge-unique-buffer-name "*merge" "*")) | |
620 ;; create the merge buffer from buffer A, so it inherits buffer A's | |
621 ;; default directory, etc. | |
622 (merge-buffer (emerge-eval-in-buffer | |
623 buffer-A | |
624 (get-buffer-create merge-buffer-name)))) | |
625 (emerge-eval-in-buffer | |
626 merge-buffer | |
627 (emerge-copy-modes buffer-A) | |
628 (setq buffer-read-only nil) | |
629 (auto-save-mode 1) | |
630 (setq emerge-mode t) | |
631 (setq emerge-A-buffer buffer-A) | |
632 (setq emerge-B-buffer buffer-B) | |
633 (setq emerge-ancestor-buffer nil) | |
634 (setq emerge-merge-buffer merge-buffer) | |
635 (setq emerge-output-description | |
636 (if output-file | |
637 (concat "Output to file: " output-file) | |
638 (concat "Output to buffer: " (buffer-name merge-buffer)))) | |
639 (insert-buffer emerge-A-buffer) | |
640 (emerge-set-keys) | |
641 (setq emerge-difference-list (emerge-make-diff-list file-A file-B)) | |
642 (setq emerge-number-of-differences (length emerge-difference-list)) | |
643 (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
|
644 (setq emerge-quit-hook quit-hooks) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
645 (emerge-remember-buffer-characteristics) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
646 (emerge-handle-local-variables)) |
583 | 647 (emerge-setup-windows buffer-A buffer-B merge-buffer t) |
648 (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
|
649 (run-hooks 'startup-hooks 'emerge-startup-hook) |
583 | 650 (setq buffer-read-only t)))) |
651 | |
652 ;; Generate the Emerge difference list between two files | |
653 (defun emerge-make-diff-list (file-A file-B) | |
654 (setq emerge-diff-buffer (get-buffer-create "*emerge-diff*")) | |
655 (emerge-eval-in-buffer | |
656 emerge-diff-buffer | |
657 (erase-buffer) | |
658 (shell-command | |
659 (format "%s %s %s %s" | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
660 emerge-diff-program emerge-diff-options |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
661 (emerge-protect-metachars file-A) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
662 (emerge-protect-metachars file-B)) |
583 | 663 t)) |
2773
8ab8f28b78d1
(emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents:
2772
diff
changeset
|
664 (emerge-prepare-error-list emerge-diff-ok-lines-regexp) |
583 | 665 (emerge-convert-diffs-to-markers |
666 emerge-A-buffer emerge-B-buffer emerge-merge-buffer | |
667 (emerge-extract-diffs emerge-diff-buffer))) | |
668 | |
669 (defun emerge-extract-diffs (diff-buffer) | |
670 (let (list) | |
671 (emerge-eval-in-buffer | |
672 diff-buffer | |
673 (goto-char (point-min)) | |
674 (while (re-search-forward emerge-match-diff-line nil t) | |
675 (let* ((a-begin (string-to-int (buffer-substring (match-beginning 1) | |
676 (match-end 1)))) | |
677 (a-end (let ((b (match-beginning 3)) | |
678 (e (match-end 3))) | |
679 (if b | |
680 (string-to-int (buffer-substring b e)) | |
681 a-begin))) | |
682 (diff-type (buffer-substring (match-beginning 4) (match-end 4))) | |
683 (b-begin (string-to-int (buffer-substring (match-beginning 5) | |
684 (match-end 5)))) | |
685 (b-end (let ((b (match-beginning 7)) | |
686 (e (match-end 7))) | |
687 (if b | |
688 (string-to-int (buffer-substring b e)) | |
689 b-begin)))) | |
690 ;; fix the beginning and end numbers, because diff is somewhat | |
691 ;; strange about how it numbers lines | |
692 (if (string-equal diff-type "a") | |
693 (progn | |
694 (setq b-end (1+ b-end)) | |
695 (setq a-begin (1+ a-begin)) | |
696 (setq a-end a-begin)) | |
697 (if (string-equal diff-type "d") | |
698 (progn | |
699 (setq a-end (1+ a-end)) | |
700 (setq b-begin (1+ b-begin)) | |
701 (setq b-end b-begin)) | |
702 ;; (string-equal diff-type "c") | |
703 (progn | |
704 (setq a-end (1+ a-end)) | |
705 (setq b-end (1+ b-end))))) | |
706 (setq list (cons (vector a-begin a-end | |
707 b-begin b-end | |
708 'default-A) | |
709 list))))) | |
710 (nreverse list))) | |
711 | |
712 ;; Set up buffer of diff/diff3 error messages. | |
713 (defun emerge-prepare-error-list (ok-regexp) | |
714 (setq emerge-diff-error-buffer (get-buffer-create "*emerge-diff-errors*")) | |
715 (emerge-eval-in-buffer | |
716 emerge-diff-error-buffer | |
717 (erase-buffer) | |
718 (insert-buffer emerge-diff-buffer) | |
719 (delete-matching-lines ok-regexp))) | |
720 | |
721 ;;; Top-level and setup functions for three-file mode. | |
722 | |
723 (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
|
724 &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
|
725 output-file) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
726 (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
|
727 (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
|
728 (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
|
729 (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
|
730 (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
|
731 (error "File `%s' does not exist or is not readable" file-ancestor)) |
583 | 732 (let ((buffer-A (find-file-noselect file-A)) |
733 (buffer-B (find-file-noselect file-B)) | |
734 (buffer-ancestor (find-file-noselect file-ancestor))) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
735 ;; Record the directories of the files |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
736 (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
|
737 (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
|
738 (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
|
739 (if output-file |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
740 (setq emerge-last-dir-output (file-name-directory output-file))) |
583 | 741 ;; 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
|
742 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
743 buffer-A |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
744 (widen) |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
745 (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
|
746 (if temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
747 (setq file-A temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
748 startup-hooks |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
749 (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
|
750 startup-hooks)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
751 ;; 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
|
752 (emerge-verify-file-buffer)))) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
753 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
754 buffer-B |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
755 (widen) |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
756 (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
|
757 (if temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
758 (setq file-B temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
759 startup-hooks |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
760 (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
|
761 startup-hooks)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
762 ;; 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
|
763 (emerge-verify-file-buffer)))) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
764 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
765 buffer-ancestor |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
766 (widen) |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
767 (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
|
768 (if temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
769 (setq file-ancestor temp |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
770 startup-hooks |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
771 (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
|
772 startup-hooks)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
773 ;; 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
|
774 (emerge-verify-file-buffer)))) |
583 | 775 (emerge-setup-with-ancestor buffer-A file-A buffer-B file-B |
776 buffer-ancestor file-ancestor | |
777 startup-hooks quit-hooks output-file))) | |
778 | |
779 ;; Start up Emerge on two files with an ancestor | |
780 (defun emerge-setup-with-ancestor (buffer-A file-A buffer-B file-B | |
781 buffer-ancestor file-ancestor | |
782 &optional startup-hooks quit-hooks | |
783 output-file) | |
784 (setq file-A (expand-file-name file-A)) | |
785 (setq file-B (expand-file-name file-B)) | |
786 (setq file-ancestor (expand-file-name file-ancestor)) | |
787 (setq output-file (and output-file (expand-file-name output-file))) | |
788 (let* ((merge-buffer-name (emerge-unique-buffer-name "*merge" "*")) | |
789 ;; create the merge buffer from buffer A, so it inherits buffer A's | |
790 ;; default directory, etc. | |
791 (merge-buffer (emerge-eval-in-buffer | |
792 buffer-A | |
793 (get-buffer-create merge-buffer-name)))) | |
794 (emerge-eval-in-buffer | |
795 merge-buffer | |
796 (emerge-copy-modes buffer-A) | |
797 (setq buffer-read-only nil) | |
798 (auto-save-mode 1) | |
799 (setq emerge-mode t) | |
800 (setq emerge-A-buffer buffer-A) | |
801 (setq emerge-B-buffer buffer-B) | |
802 (setq emerge-ancestor-buffer buffer-ancestor) | |
803 (setq emerge-merge-buffer merge-buffer) | |
804 (setq emerge-output-description | |
805 (if output-file | |
806 (concat "Output to file: " output-file) | |
807 (concat "Output to buffer: " (buffer-name merge-buffer)))) | |
808 (insert-buffer emerge-A-buffer) | |
809 (emerge-set-keys) | |
810 (setq emerge-difference-list | |
811 (emerge-make-diff3-list file-A file-B file-ancestor)) | |
812 (setq emerge-number-of-differences (length emerge-difference-list)) | |
813 (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
|
814 (setq emerge-quit-hook quit-hooks) |
583 | 815 (emerge-remember-buffer-characteristics) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
816 (emerge-select-prefer-Bs) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
817 (emerge-handle-local-variables)) |
583 | 818 (emerge-setup-windows buffer-A buffer-B merge-buffer t) |
819 (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
|
820 (run-hooks 'startup-hooks 'emerge-startup-hook) |
583 | 821 (setq buffer-read-only t)))) |
822 | |
823 ;; Generate the Emerge difference list between two files with an ancestor | |
824 (defun emerge-make-diff3-list (file-A file-B file-ancestor) | |
825 (setq emerge-diff-buffer (get-buffer-create "*emerge-diff*")) | |
826 (emerge-eval-in-buffer | |
827 emerge-diff-buffer | |
828 (erase-buffer) | |
829 (shell-command | |
830 (format "%s %s %s %s %s" | |
831 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
|
832 (emerge-protect-metachars file-A) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
833 (emerge-protect-metachars file-ancestor) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
834 (emerge-protect-metachars file-B)) |
583 | 835 t)) |
2773
8ab8f28b78d1
(emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents:
2772
diff
changeset
|
836 (emerge-prepare-error-list emerge-diff3-ok-lines-regexp) |
583 | 837 (emerge-convert-diffs-to-markers |
838 emerge-A-buffer emerge-B-buffer emerge-merge-buffer | |
839 (emerge-extract-diffs3 emerge-diff-buffer))) | |
840 | |
841 (defun emerge-extract-diffs3 (diff-buffer) | |
842 (let (list) | |
843 (emerge-eval-in-buffer | |
844 diff-buffer | |
845 (while (re-search-forward "^====\\(.?\\)$" nil t) | |
846 ;; leave point after matched line | |
847 (beginning-of-line 2) | |
848 (let ((agreement (buffer-substring (match-beginning 1) (match-end 1)))) | |
849 ;; 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
|
850 (if (not (string-equal agreement "2")) |
583 | 851 (setq list |
852 (cons | |
3732
60292a8697bc
(emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
853 (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
|
854 (setq pos (point)) |
3732
60292a8697bc
(emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
855 (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
|
856 (goto-char pos) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
857 (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
|
858 (vector (car group-1) (car (cdr group-1)) |
583 | 859 (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
|
860 (cond ((string-equal agreement "1") 'prefer-A) |
583 | 861 ((string-equal agreement "3") 'prefer-B) |
862 (t 'default-A)))) | |
863 list)))))) | |
864 (nreverse list))) | |
865 | |
866 (defun emerge-get-diff3-group (file) | |
867 ;; This save-excursion allows emerge-get-diff3-group to be called for the | |
868 ;; various groups of lines (1, 2, 3) in any order, and for the lines to | |
869 ;; appear in any order. The reason this is necessary is that Gnu diff3 | |
870 ;; can produce the groups in the order 1, 2, 3 or 1, 3, 2. | |
871 (save-excursion | |
872 (re-search-forward | |
873 (concat "^" file ":\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\\([ac]\\)$")) | |
874 (beginning-of-line 2) | |
875 ;; treatment depends on whether it is an "a" group or a "c" group | |
876 (if (string-equal (buffer-substring (match-beginning 4) (match-end 4)) "c") | |
877 ;; it is a "c" group | |
878 (if (match-beginning 2) | |
879 ;; it has two numbers | |
880 (list (string-to-int | |
881 (buffer-substring (match-beginning 1) (match-end 1))) | |
882 (1+ (string-to-int | |
883 (buffer-substring (match-beginning 3) (match-end 3))))) | |
884 ;; it has one number | |
885 (let ((x (string-to-int | |
886 (buffer-substring (match-beginning 1) (match-end 1))))) | |
887 (list x (1+ x)))) | |
888 ;; it is an "a" group | |
889 (let ((x (1+ (string-to-int | |
890 (buffer-substring (match-beginning 1) (match-end 1)))))) | |
891 (list x x))))) | |
892 | |
893 ;;; Functions to start Emerge on files | |
894 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
895 ;;;###autoload |
583 | 896 (defun emerge-files (arg file-A file-B file-out &optional startup-hooks |
897 quit-hooks) | |
898 "Run Emerge on two files." | |
899 (interactive | |
900 (let (f) | |
901 (list current-prefix-arg | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
902 (setq f (emerge-read-file-name "File A to merge" emerge-last-dir-A |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
903 nil nil t)) |
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
904 (emerge-read-file-name "File B to merge" emerge-last-dir-B nil f t) |
583 | 905 (and current-prefix-arg |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
906 (emerge-read-file-name "Output file" emerge-last-dir-output |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
907 f f nil))))) |
15804
dd08f1c1f488
(emerge-files-with-ancestor, emerge-files):
Richard M. Stallman <rms@gnu.org>
parents:
14668
diff
changeset
|
908 (if file-out |
dd08f1c1f488
(emerge-files-with-ancestor, emerge-files):
Richard M. Stallman <rms@gnu.org>
parents:
14668
diff
changeset
|
909 (add-hook 'quit-hooks (` (lambda () (emerge-files-exit (, file-out)))))) |
583 | 910 (emerge-files-internal |
911 file-A file-B startup-hooks | |
15804
dd08f1c1f488
(emerge-files-with-ancestor, emerge-files):
Richard M. Stallman <rms@gnu.org>
parents:
14668
diff
changeset
|
912 quit-hooks |
583 | 913 file-out)) |
914 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
915 ;;;###autoload |
583 | 916 (defun emerge-files-with-ancestor (arg file-A file-B file-ancestor file-out |
917 &optional startup-hooks quit-hooks) | |
918 "Run Emerge on two files, giving another file as the ancestor." | |
919 (interactive | |
920 (let (f) | |
921 (list current-prefix-arg | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
922 (setq f (emerge-read-file-name "File A to merge" emerge-last-dir-A |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
923 nil nil t)) |
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
924 (emerge-read-file-name "File B to merge" emerge-last-dir-B nil f t) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
925 (emerge-read-file-name "Ancestor file" emerge-last-dir-ancestor |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
926 nil f t) |
583 | 927 (and current-prefix-arg |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
928 (emerge-read-file-name "Output file" emerge-last-dir-output |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
929 f f nil))))) |
15804
dd08f1c1f488
(emerge-files-with-ancestor, emerge-files):
Richard M. Stallman <rms@gnu.org>
parents:
14668
diff
changeset
|
930 (if file-out |
dd08f1c1f488
(emerge-files-with-ancestor, emerge-files):
Richard M. Stallman <rms@gnu.org>
parents:
14668
diff
changeset
|
931 (add-hook 'quit-hooks (` (lambda () (emerge-files-exit (, file-out)))))) |
583 | 932 (emerge-files-with-ancestor-internal |
933 file-A file-B file-ancestor startup-hooks | |
15804
dd08f1c1f488
(emerge-files-with-ancestor, emerge-files):
Richard M. Stallman <rms@gnu.org>
parents:
14668
diff
changeset
|
934 quit-hooks |
583 | 935 file-out)) |
936 | |
937 ;; Write the merge buffer out in place of the file the A buffer is visiting. | |
938 (defun emerge-files-exit (file-out) | |
939 ;; if merge was successful was given, save to disk | |
940 (if (not emerge-prefix-argument) | |
941 (emerge-write-and-delete file-out))) | |
942 | |
943 ;;; Functions to start Emerge on buffers | |
944 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
945 ;;;###autoload |
583 | 946 (defun emerge-buffers (buffer-A buffer-B &optional startup-hooks quit-hooks) |
947 "Run Emerge on two buffers." | |
948 (interactive "bBuffer A to merge: \nbBuffer B to merge: ") | |
949 (let ((emerge-file-A (emerge-make-temp-file "A")) | |
950 (emerge-file-B (emerge-make-temp-file "B"))) | |
951 (emerge-eval-in-buffer | |
952 buffer-A | |
953 (write-region (point-min) (point-max) emerge-file-A nil 'no-message)) | |
954 (emerge-eval-in-buffer | |
955 buffer-B | |
956 (write-region (point-min) (point-max) emerge-file-B nil 'no-message)) | |
957 (emerge-setup (get-buffer buffer-A) emerge-file-A | |
958 (get-buffer buffer-B) emerge-file-B | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
959 (cons (` (lambda () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
960 (delete-file (, emerge-file-A)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
961 (delete-file (, emerge-file-B)))) |
583 | 962 startup-hooks) |
963 quit-hooks | |
964 nil))) | |
965 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
966 ;;;###autoload |
583 | 967 (defun emerge-buffers-with-ancestor (buffer-A buffer-B buffer-ancestor |
968 &optional startup-hooks | |
969 quit-hooks) | |
970 "Run Emerge on two buffers, giving another buffer as the ancestor." | |
971 (interactive | |
972 "bBuffer A to merge: \nbBuffer B to merge: \nbAncestor buffer: ") | |
973 (let ((emerge-file-A (emerge-make-temp-file "A")) | |
974 (emerge-file-B (emerge-make-temp-file "B")) | |
975 (emerge-file-ancestor (emerge-make-temp-file "anc"))) | |
976 (emerge-eval-in-buffer | |
977 buffer-A | |
978 (write-region (point-min) (point-max) emerge-file-A nil 'no-message)) | |
979 (emerge-eval-in-buffer | |
980 buffer-B | |
981 (write-region (point-min) (point-max) emerge-file-B nil 'no-message)) | |
982 (emerge-eval-in-buffer | |
983 buffer-ancestor | |
984 (write-region (point-min) (point-max) emerge-file-ancestor nil | |
985 'no-message)) | |
986 (emerge-setup-with-ancestor (get-buffer buffer-A) emerge-file-A | |
987 (get-buffer buffer-B) emerge-file-B | |
988 (get-buffer buffer-ancestor) | |
989 emerge-file-ancestor | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
990 (cons (` (lambda () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
991 (delete-file (, emerge-file-A)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
992 (delete-file (, emerge-file-B)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
993 (delete-file |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
994 (, emerge-file-ancestor)))) |
583 | 995 startup-hooks) |
996 quit-hooks | |
997 nil))) | |
998 | |
999 ;;; Functions to start Emerge from the command line | |
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 | 1002 (defun emerge-files-command () |
1003 (let ((file-a (nth 0 command-line-args-left)) | |
1004 (file-b (nth 1 command-line-args-left)) | |
1005 (file-out (nth 2 command-line-args-left))) | |
1006 (setq command-line-args-left (nthcdr 3 command-line-args-left)) | |
1007 (emerge-files-internal | |
1008 file-a file-b nil | |
1009 (list (` (lambda () (emerge-command-exit (, file-out)))))))) | |
1010 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1011 ;;;###autoload |
583 | 1012 (defun emerge-files-with-ancestor-command () |
1013 (let (file-a file-b file-anc file-out) | |
1014 ;; check for a -a flag, for filemerge compatibility | |
1015 (if (string= (car command-line-args-left) "-a") | |
1016 ;; arguments are "-a ancestor file-a file-b file-out" | |
1017 (progn | |
1018 (setq file-a (nth 2 command-line-args-left)) | |
1019 (setq file-b (nth 3 command-line-args-left)) | |
1020 (setq file-anc (nth 1 command-line-args-left)) | |
1021 (setq file-out (nth 4 command-line-args-left)) | |
1022 (setq command-line-args-left (nthcdr 5 command-line-args-left))) | |
1023 ;; arguments are "file-a file-b ancestor file-out" | |
1024 (setq file-a (nth 0 command-line-args-left)) | |
1025 (setq file-b (nth 1 command-line-args-left)) | |
1026 (setq file-anc (nth 2 command-line-args-left)) | |
1027 (setq file-out (nth 3 command-line-args-left)) | |
1028 (setq command-line-args-left (nthcdr 4 command-line-args-left))) | |
1029 (emerge-files-with-ancestor-internal | |
1030 file-a file-b file-anc nil | |
1031 (list (` (lambda () (emerge-command-exit (, file-out)))))))) | |
1032 | |
1033 (defun emerge-command-exit (file-out) | |
1034 (emerge-write-and-delete file-out) | |
1035 (kill-emacs (if emerge-prefix-argument 1 0))) | |
1036 | |
1037 ;;; Functions to start Emerge via remote request | |
1038 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1039 ;;;###autoload |
583 | 1040 (defun emerge-files-remote (file-a file-b file-out) |
1041 (setq emerge-file-out file-out) | |
1042 (emerge-files-internal | |
1043 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
|
1044 (list (` (lambda () (emerge-remote-exit (, file-out) '(, emerge-exit-func))))) |
583 | 1045 file-out) |
1046 (throw 'client-wait nil)) | |
1047 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1048 ;;;###autoload |
583 | 1049 (defun emerge-files-with-ancestor-remote (file-a file-b file-anc file-out) |
1050 (setq emerge-file-out file-out) | |
1051 (emerge-files-with-ancestor-internal | |
1052 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
|
1053 (list (` (lambda () (emerge-remote-exit (, file-out) '(, emerge-exit-func))))) |
583 | 1054 file-out) |
1055 (throw 'client-wait nil)) | |
1056 | |
5796
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
1057 (defun emerge-remote-exit (file-out emerge-exit-func) |
583 | 1058 (emerge-write-and-delete file-out) |
1059 (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
|
1060 (funcall emerge-exit-func (if emerge-prefix-argument 1 0))) |
583 | 1061 |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1062 ;;; Functions to start Emerge on RCS versions |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1063 |
6286
676773222f1f
(emerge-revisions, emerge-revisions-with-ancestor)
Richard M. Stallman <rms@gnu.org>
parents:
6281
diff
changeset
|
1064 ;;;###autoload |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1065 (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
|
1066 &optional startup-hooks quit-hooks) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1067 "Emerge two RCS revisions of a file." |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1068 (interactive |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1069 (list current-prefix-arg |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1070 (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
|
1071 (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
|
1072 (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
|
1073 (setq emerge-last-revision-A revision-A |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1074 emerge-last-revision-B revision-B) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1075 (emerge-revisions-internal |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1076 file revision-A revision-B startup-hooks |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1077 (if arg |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1078 (cons (` (lambda () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1079 (shell-command |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1080 (, (format "%s %s" emerge-rcs-ci-program file))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1081 quit-hooks) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1082 quit-hooks))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1083 |
6286
676773222f1f
(emerge-revisions, emerge-revisions-with-ancestor)
Richard M. Stallman <rms@gnu.org>
parents:
6281
diff
changeset
|
1084 ;;;###autoload |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1085 (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
|
1086 revision-B ancestor |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1087 &optional |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1088 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
|
1089 "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
|
1090 (interactive |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1091 (list current-prefix-arg |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1092 (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
|
1093 (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
|
1094 (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
|
1095 (read-string "Ancestor: " emerge-last-revision-ancestor))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1096 (setq emerge-last-revision-A revision-A |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1097 emerge-last-revision-B revision-B |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1098 emerge-last-revision-ancestor ancestor) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1099 (emerge-revision-with-ancestor-internal |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1100 file revision-A revision-B ancestor startup-hooks |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1101 (if arg |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1102 (let ((cmd )) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1103 (cons (` (lambda () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1104 (shell-command |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1105 (, (format "%s %s" emerge-rcs-ci-program file))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1106 quit-hooks)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1107 quit-hooks))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1108 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1109 (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
|
1110 startup-hooks quit-hooks output-file) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1111 (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
|
1112 (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
|
1113 (emerge-file-A (emerge-make-temp-file "A")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1114 (emerge-file-B (emerge-make-temp-file "B"))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1115 ;; Get the revisions into buffers |
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-A |
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-A 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-A 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-B |
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 revision-B 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-file-B 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 buffer-A emerge-file-A |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1134 buffer-B emerge-file-B |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1135 (cons (` (lambda () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1136 (delete-file (, emerge-file-A)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1137 (delete-file (, emerge-file-B)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1138 startup-hooks) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1139 (cons (` (lambda () (emerge-files-exit (, file)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1140 quit-hooks) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1141 nil))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1142 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1143 (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
|
1144 ancestor |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1145 &optional startup-hooks |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1146 quit-hooks output-file) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1147 (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
|
1148 (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
|
1149 (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
|
1150 (emerge-file-A (emerge-make-temp-file "A")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1151 (emerge-file-B (emerge-make-temp-file "B")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1152 (emerge-ancestor (emerge-make-temp-file "ancestor"))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1153 ;; Get the revisions into buffers |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1154 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1155 buffer-A |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1156 (erase-buffer) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1157 (shell-command |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1158 (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
|
1159 revision-A file) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1160 t) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1161 (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
|
1162 (set-buffer-modified-p nil)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1163 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1164 buffer-B |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1165 (erase-buffer) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1166 (shell-command |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1167 (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
|
1168 t) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1169 (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
|
1170 (set-buffer-modified-p nil)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1171 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1172 buffer-ancestor |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1173 (erase-buffer) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1174 (shell-command |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1175 (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
|
1176 t) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1177 (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
|
1178 (set-buffer-modified-p nil)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1179 ;; Do the merge |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1180 (emerge-setup-with-ancestor |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1181 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
|
1182 buffer-ancestor emerge-ancestor |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1183 (cons (` (lambda () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1184 (delete-file (, emerge-file-A)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1185 (delete-file (, emerge-file-B)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1186 (delete-file (, emerge-ancestor)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1187 startup-hooks) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1188 (cons (` (lambda () (emerge-files-exit (, file)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1189 quit-hooks) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1190 output-file))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1191 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1192 ;;; 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
|
1193 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1194 (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
|
1195 "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
|
1196 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
|
1197 a=file1 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1198 b=file2 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1199 ancestor=file3 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1200 output=file4 |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1201 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
|
1202 |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1203 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
|
1204 is present: |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1205 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
|
1206 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
|
1207 not copied to the output file. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1208 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
|
1209 (interactive) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1210 (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
|
1211 (case-fold-search t)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1212 ;; 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
|
1213 ;; the line does not end with newline) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1214 (if (eobp) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1215 (error "At end of buffer")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1216 ;; Go to the beginning of the line |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1217 (beginning-of-line) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1218 ;; Skip any initial whitespace |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1219 (if (looking-at "[ \t]*") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1220 (goto-char (match-end 0))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1221 ;; Process the entire line |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1222 (while (not (eolp)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1223 ;; Get the next entry |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1224 (if (looking-at "\\([a-z]+\\)=\\([^ \t\n]+\\)[ \t]*") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1225 ;; 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
|
1226 (let ((tag (downcase |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1227 (buffer-substring (match-beginning 1) (match-end 1)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1228 (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
|
1229 ;; Move point after the entry |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1230 (goto-char (match-end 0)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1231 ;; Store the filename in the right variable |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1232 (cond |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1233 ((string-equal tag "a") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1234 (if file-A |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1235 (error "This line has two `A' entries")) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1236 (setq file-A file)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1237 ((string-equal tag "b") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1238 (if file-B |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1239 (error "This line has two `B' entries")) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1240 (setq file-B file)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1241 ((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
|
1242 (if file-ancestor |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1243 (error "This line has two `ancestor' entries")) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1244 (setq file-ancestor file)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1245 ((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
|
1246 (if file-out |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1247 (error "This line has two `output' entries")) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1248 (setq file-out file)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1249 (t |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1250 (error "Unrecognized entry")))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1251 ;; 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
|
1252 (error "Unparsable entry"))) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1253 ;; 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
|
1254 (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
|
1255 (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
|
1256 (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
|
1257 (error "Must have `A' or `B' entry")) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1258 ;; 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
|
1259 ;; next line in buffer. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1260 (beginning-of-line 2) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1261 ;; Execute the correct command |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1262 (cond |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1263 ;; Merge of two files with ancestor |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1264 ((and file-A file-B file-ancestor) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1265 (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
|
1266 (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
|
1267 file-ancestor file-out |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1268 nil |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1269 ;; When done, return to this buffer. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1270 (list |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1271 (` (lambda () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1272 (switch-to-buffer (, (current-buffer))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1273 (message "Merge done.")))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1274 ;; Merge of two files without ancestor |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1275 ((and file-A file-B) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1276 (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
|
1277 (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
|
1278 nil |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1279 ;; When done, return to this buffer. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1280 (list |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1281 (` (lambda () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1282 (switch-to-buffer (, (current-buffer))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1283 (message "Merge done.")))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1284 ;; 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
|
1285 ;; but only one input file. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1286 ;; 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
|
1287 ((and file-ancestor emerge-execute-line-deletions) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1288 (message "No action.")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1289 ;; 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
|
1290 (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
|
1291 (message "Copying...") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1292 (copy-file input-file file-out) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1293 (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
|
1294 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1295 ;;; 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
|
1296 |
20597 | 1297 (defcustom emerge-merge-directories-filename-regexp "[^.]" |
1298 "Regexp describing files to be processed by `emerge-merge-directories'." | |
1299 :type 'regexp | |
1300 :group 'emerge) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1301 |
6286
676773222f1f
(emerge-revisions, emerge-revisions-with-ancestor)
Richard M. Stallman <rms@gnu.org>
parents:
6281
diff
changeset
|
1302 ;;;###autoload |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1303 (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
|
1304 (interactive |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1305 (list |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1306 (read-file-name "A directory: " nil nil 'confirm) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1307 (read-file-name "B directory: " nil nil 'confirm) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1308 (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
|
1309 (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
|
1310 ;; Check that we're not on a line |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1311 (if (not (and (bolp) (eolp))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1312 (error "There is text on this line")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1313 ;; 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
|
1314 (if (and ancestor-dir (string-equal ancestor-dir "")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1315 (setq ancestor-dir nil)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1316 (if (and output-dir (string-equal output-dir "")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1317 (setq output-dir nil)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1318 ;; Canonicalize the directory names |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1319 (setq a-dir (expand-file-name a-dir)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1320 (if (not (string-equal (substring a-dir -1) "/")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1321 (setq a-dir (concat a-dir "/"))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1322 (setq b-dir (expand-file-name b-dir)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1323 (if (not (string-equal (substring b-dir -1) "/")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1324 (setq b-dir (concat b-dir "/"))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1325 (if ancestor-dir |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1326 (progn |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1327 (setq ancestor-dir (expand-file-name ancestor-dir)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1328 (if (not (string-equal (substring ancestor-dir -1) "/")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1329 (setq ancestor-dir (concat ancestor-dir "/"))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1330 (if output-dir |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1331 (progn |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1332 (setq output-dir (expand-file-name output-dir)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1333 (if (not (string-equal (substring output-dir -1) "/")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1334 (setq output-dir (concat output-dir "/"))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1335 ;; Set the mark to where we start |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1336 (push-mark) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1337 ;; Find out what files are in the directories. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1338 (let* ((a-dir-files |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1339 (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
|
1340 (b-dir-files |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1341 (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
|
1342 (ancestor-dir-files |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1343 (and ancestor-dir |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1344 (directory-files ancestor-dir nil |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1345 emerge-merge-directories-filename-regexp))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1346 (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
|
1347 (copy-sequence b-dir-files) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1348 (copy-sequence ancestor-dir-files)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1349 (function string-lessp)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1350 ;; Remove duplicates from all-files. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1351 (let ((p all-files)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1352 (while p |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1353 (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
|
1354 (setcdr p (cdr (cdr p))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1355 (setq p (cdr p))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1356 ;; Generate the control lines for the various files. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1357 (while all-files |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1358 (let ((f (car all-files))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1359 (setq all-files (cdr all-files)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1360 (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
|
1361 (progn |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1362 (insert "A=" a-dir f "\t") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1363 (setq a-dir-files (cdr a-dir-files)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1364 (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
|
1365 (progn |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1366 (insert "B=" b-dir f "\t") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1367 (setq b-dir-files (cdr b-dir-files)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1368 (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
|
1369 (progn |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1370 (insert "ancestor=" ancestor-dir f "\t") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1371 (setq ancestor-dir-files (cdr ancestor-dir-files)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1372 (if output-dir |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1373 (insert "output=" output-dir f "\t")) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1374 (backward-delete-char 1) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1375 (insert "\n"))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1376 |
583 | 1377 ;;; Common setup routines |
1378 | |
1379 ;; Set up the window configuration. If POS is given, set the points to | |
1380 ;; the beginnings of the buffers. | |
1381 (defun emerge-setup-windows (buffer-A buffer-B merge-buffer &optional pos) | |
1382 ;; Make sure we are not in the minibuffer window when we try to delete | |
1383 ;; all other windows. | |
1384 (if (eq (selected-window) (minibuffer-window)) | |
1385 (other-window 1)) | |
1386 (delete-other-windows) | |
1387 (switch-to-buffer merge-buffer) | |
1388 (emerge-refresh-mode-line) | |
1389 (split-window-vertically) | |
1390 (split-window-horizontally) | |
1391 (switch-to-buffer buffer-A) | |
1392 (if pos | |
1393 (goto-char (point-min))) | |
1394 (other-window 1) | |
1395 (switch-to-buffer buffer-B) | |
1396 (if pos | |
1397 (goto-char (point-min))) | |
1398 (other-window 1) | |
1399 (if pos | |
1400 (goto-char (point-min))) | |
1401 ;; If diff/diff3 reports errors, display them rather than the merge buffer. | |
1402 (if (/= 0 (emerge-eval-in-buffer emerge-diff-error-buffer (buffer-size))) | |
1403 (progn | |
1404 (ding) | |
1405 (message "Errors found in diff/diff3 output. Merge buffer is %s." | |
1406 (buffer-name emerge-merge-buffer)) | |
1407 (switch-to-buffer emerge-diff-error-buffer)))) | |
1408 | |
1409 ;; Set up the keymap in the merge buffer | |
1410 (defun emerge-set-keys () | |
1411 ;; Set up fixed keymaps if necessary | |
1412 (if (not emerge-basic-keymap) | |
1413 (emerge-setup-fixed-keymaps)) | |
1414 ;; Save the old local map | |
1415 (setq emerge-old-keymap (current-local-map)) | |
1416 ;; Construct the edit keymap | |
1417 (setq emerge-edit-keymap (if emerge-old-keymap | |
1418 (copy-keymap emerge-old-keymap) | |
1419 (make-sparse-keymap))) | |
1420 ;; Install the Emerge commands | |
1421 (emerge-force-define-key emerge-edit-keymap emerge-command-prefix | |
1422 'emerge-basic-keymap) | |
5796
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
1423 (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
|
1424 |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
1425 ;; 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
|
1426 (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
|
1427 (cons "Options" emerge-options-menu)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
1428 (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
|
1429 (cons "Merge" emerge-merge-menu)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
1430 (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
|
1431 (cons "Move" emerge-move-menu)) |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
1432 |
583 | 1433 ;; 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
|
1434 (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
|
1435 'emerge-query-write-file |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1436 emerge-edit-keymap) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1437 (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
|
1438 'emerge-query-save-buffer |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1439 emerge-edit-keymap) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1440 (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
|
1441 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
|
1442 (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
|
1443 emerge-edit-keymap (current-global-map)) |
583 | 1444 (use-local-map emerge-fast-keymap) |
1445 (setq emerge-edit-mode nil) | |
1446 (setq emerge-fast-mode t)) | |
1447 | |
1448 (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
|
1449 "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
|
1450 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
|
1451 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
|
1452 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
|
1453 These characteristics are restored by `emerge-restore-buffer-characteristics'." |
583 | 1454 ;; force auto-save, because we will turn off auto-saving in buffers for the |
1455 ;; duration | |
1456 (do-auto-save) | |
1457 ;; remember and alter buffer characteristics | |
1458 (setq emerge-A-buffer-values | |
1459 (emerge-eval-in-buffer | |
1460 emerge-A-buffer | |
1461 (prog1 | |
1462 (emerge-save-variables emerge-saved-variables) | |
1463 (emerge-restore-variables emerge-saved-variables | |
1464 emerge-merging-values)))) | |
1465 (setq emerge-B-buffer-values | |
1466 (emerge-eval-in-buffer | |
1467 emerge-B-buffer | |
1468 (prog1 | |
1469 (emerge-save-variables emerge-saved-variables) | |
1470 (emerge-restore-variables emerge-saved-variables | |
1471 emerge-merging-values))))) | |
1472 | |
1473 (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
|
1474 "Restores characteristics saved by `emerge-remember-buffer-characteristics'." |
583 | 1475 (let ((A-values emerge-A-buffer-values) |
1476 (B-values emerge-B-buffer-values)) | |
1477 (emerge-eval-in-buffer emerge-A-buffer | |
1478 (emerge-restore-variables emerge-saved-variables | |
1479 A-values)) | |
1480 (emerge-eval-in-buffer emerge-B-buffer | |
1481 (emerge-restore-variables emerge-saved-variables | |
1482 B-values)))) | |
1483 | |
6556
79884c55326f
(emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6286
diff
changeset
|
1484 ;; 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
|
1485 ;; Return DESIRED-LINE. |
79884c55326f
(emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6286
diff
changeset
|
1486 (defun emerge-goto-line (desired-line current-line) |
79884c55326f
(emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6286
diff
changeset
|
1487 (forward-line (- desired-line current-line)) |
6910
6566088ccf07
(emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents:
6809
diff
changeset
|
1488 desired-line) |
6556
79884c55326f
(emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6286
diff
changeset
|
1489 |
583 | 1490 (defun emerge-convert-diffs-to-markers (A-buffer |
1491 B-buffer | |
1492 merge-buffer | |
1493 lineno-list) | |
1494 (let* (marker-list | |
1495 (A-point-min (emerge-eval-in-buffer A-buffer (point-min))) | |
1496 (offset (1- A-point-min)) | |
1497 (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
|
1498 ;; Record current line number in each buffer |
79884c55326f
(emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6286
diff
changeset
|
1499 ;; 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
|
1500 (a-line 1) |
6566088ccf07
(emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents:
6809
diff
changeset
|
1501 (b-line 1)) |
6556
79884c55326f
(emerge-goto-line): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6286
diff
changeset
|
1502 (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
|
1503 (emerge-eval-in-buffer B-buffer (goto-char (point-min))) |
583 | 1504 (while lineno-list |
1505 (let* ((list-element (car lineno-list)) | |
1506 a-begin-marker | |
1507 a-end-marker | |
1508 b-begin-marker | |
1509 b-end-marker | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1510 merge-begin-marker |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1511 merge-end-marker |
583 | 1512 (a-begin (aref list-element 0)) |
1513 (a-end (aref list-element 1)) | |
1514 (b-begin (aref list-element 2)) | |
1515 (b-end (aref list-element 3)) | |
1516 (state (aref list-element 4))) | |
1517 ;; place markers at the appropriate places in the buffers | |
1518 (emerge-eval-in-buffer | |
1519 A-buffer | |
6910
6566088ccf07
(emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents:
6809
diff
changeset
|
1520 (setq a-line (emerge-goto-line a-begin a-line)) |
583 | 1521 (setq a-begin-marker (point-marker)) |
6910
6566088ccf07
(emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents:
6809
diff
changeset
|
1522 (setq a-line (emerge-goto-line a-end a-line)) |
583 | 1523 (setq a-end-marker (point-marker))) |
1524 (emerge-eval-in-buffer | |
1525 B-buffer | |
6910
6566088ccf07
(emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents:
6809
diff
changeset
|
1526 (setq b-line (emerge-goto-line b-begin b-line)) |
583 | 1527 (setq b-begin-marker (point-marker)) |
6910
6566088ccf07
(emerge-goto-line): Fix return value.
Karl Heuer <kwzh@gnu.org>
parents:
6809
diff
changeset
|
1528 (setq b-line (emerge-goto-line b-end b-line)) |
583 | 1529 (setq b-end-marker (point-marker))) |
1530 (setq merge-begin-marker (set-marker | |
1531 (make-marker) | |
1532 (- (marker-position a-begin-marker) | |
1533 offset) | |
1534 merge-buffer)) | |
1535 (setq merge-end-marker (set-marker | |
1536 (make-marker) | |
1537 (- (marker-position a-end-marker) | |
1538 offset) | |
1539 merge-buffer)) | |
1540 ;; record all the markers for this difference | |
1541 (setq marker-list (cons (vector a-begin-marker a-end-marker | |
1542 b-begin-marker b-end-marker | |
1543 merge-begin-marker merge-end-marker | |
1544 state) | |
1545 marker-list))) | |
1546 (setq lineno-list (cdr lineno-list))) | |
1547 ;; convert the list of difference information into a vector for | |
1548 ;; fast access | |
1549 (setq emerge-difference-list (apply 'vector (nreverse marker-list))))) | |
1550 | |
1551 ;; If we have an ancestor, select all B variants that we prefer | |
1552 (defun emerge-select-prefer-Bs () | |
1553 (let ((n 0)) | |
1554 (while (< n emerge-number-of-differences) | |
1555 (if (eq (aref (aref emerge-difference-list n) 6) 'prefer-B) | |
1556 (progn | |
1557 (emerge-unselect-and-select-difference n t) | |
1558 (emerge-select-B) | |
1559 (aset (aref emerge-difference-list n) 6 'prefer-B))) | |
1560 (setq n (1+ n)))) | |
1561 (emerge-unselect-and-select-difference -1)) | |
1562 | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1563 ;; 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
|
1564 ;; requested. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1565 (defun emerge-handle-local-variables () |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1566 (if emerge-process-local-variables |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1567 (condition-case err |
3732
60292a8697bc
(emerge-make-diff3-list): Pass ancestor second.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
1568 (hack-local-variables) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1569 (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
|
1570 (prin1-to-string err)))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1571 |
583 | 1572 ;;; Common exit routines |
1573 | |
1574 (defun emerge-write-and-delete (file-out) | |
1575 ;; clear screen format | |
1576 (delete-other-windows) | |
1577 ;; delete A, B, and ancestor buffers, if they haven't been changed | |
1578 (if (not (buffer-modified-p emerge-A-buffer)) | |
1579 (kill-buffer emerge-A-buffer)) | |
1580 (if (not (buffer-modified-p emerge-B-buffer)) | |
1581 (kill-buffer emerge-B-buffer)) | |
1582 (if (and emerge-ancestor-buffer | |
1583 (not (buffer-modified-p emerge-ancestor-buffer))) | |
1584 (kill-buffer emerge-ancestor-buffer)) | |
1585 ;; 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
|
1586 (and file-out |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1587 (write-file file-out))) |
583 | 1588 |
1589 ;;; Commands | |
1590 | |
1591 (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
|
1592 "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
|
1593 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
|
1594 With an argument, reestablish the default three-window display." |
583 | 1595 (interactive "P") |
1596 ;; If there is an argument, rebuild the window structure | |
1597 (if arg | |
1598 (emerge-setup-windows emerge-A-buffer emerge-B-buffer | |
1599 emerge-merge-buffer)) | |
1600 ;; Redisplay whatever buffers are showing, if there is a selected difference | |
1601 (if (and (>= emerge-current-difference 0) | |
1602 (< emerge-current-difference emerge-number-of-differences)) | |
1603 (let* ((merge-buffer emerge-merge-buffer) | |
1604 (buffer-A emerge-A-buffer) | |
1605 (buffer-B emerge-B-buffer) | |
8974
0d7b32820221
(emerge-recenter, emerge-operate-on-windows):
Richard M. Stallman <rms@gnu.org>
parents:
6910
diff
changeset
|
1606 (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
|
1607 (window-B (get-buffer-window buffer-B 'visible)) |
583 | 1608 (merge-window (get-buffer-window merge-buffer)) |
1609 (diff-vector | |
1610 (aref emerge-difference-list emerge-current-difference))) | |
1611 (if window-A (progn | |
1612 (select-window window-A) | |
1613 (emerge-position-region | |
1614 (- (aref diff-vector 0) | |
1615 (1- emerge-before-flag-length)) | |
1616 (+ (aref diff-vector 1) | |
1617 (1- emerge-after-flag-length)) | |
1618 (1+ (aref diff-vector 0))))) | |
1619 (if window-B (progn | |
1620 (select-window window-B) | |
1621 (emerge-position-region | |
1622 (- (aref diff-vector 2) | |
1623 (1- emerge-before-flag-length)) | |
1624 (+ (aref diff-vector 3) | |
1625 (1- emerge-after-flag-length)) | |
1626 (1+ (aref diff-vector 2))))) | |
1627 (if merge-window (progn | |
1628 (select-window merge-window) | |
1629 (emerge-position-region | |
1630 (- (aref diff-vector 4) | |
1631 (1- emerge-before-flag-length)) | |
1632 (+ (aref diff-vector 5) | |
1633 (1- emerge-after-flag-length)) | |
1634 (1+ (aref diff-vector 4)))))))) | |
1635 | |
1636 ;;; Window scrolling operations | |
1637 ;; These operations are designed to scroll all three windows the same amount, | |
1638 ;; so as to keep the text in them aligned. | |
1639 | |
1640 ;; Perform some operation on all three windows (if they are showing). | |
1641 ;; Catches all errors on the operation in the A and B windows, but not | |
1642 ;; in the merge window. Usually, errors come from scrolling off the | |
1643 ;; beginning or end of the buffer, and this gives a nice error message: | |
1644 ;; End of buffer is reported in the merge buffer, but if the scroll was | |
1645 ;; possible in the A or B windows, it is performed there before the error | |
1646 ;; is reported. | |
1647 (defun emerge-operate-on-windows (operation arg) | |
1648 (let* ((merge-buffer emerge-merge-buffer) | |
1649 (buffer-A emerge-A-buffer) | |
1650 (buffer-B emerge-B-buffer) | |
8974
0d7b32820221
(emerge-recenter, emerge-operate-on-windows):
Richard M. Stallman <rms@gnu.org>
parents:
6910
diff
changeset
|
1651 (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
|
1652 (window-B (get-buffer-window buffer-B 'visible)) |
583 | 1653 (merge-window (get-buffer-window merge-buffer))) |
1654 (if window-A (progn | |
1655 (select-window window-A) | |
1656 (condition-case nil | |
1657 (funcall operation arg) | |
1658 (error)))) | |
1659 (if window-B (progn | |
1660 (select-window window-B) | |
1661 (condition-case nil | |
1662 (funcall operation arg) | |
1663 (error)))) | |
1664 (if merge-window (progn | |
1665 (select-window merge-window) | |
1666 (funcall operation arg))))) | |
1667 | |
1668 (defun emerge-scroll-up (&optional arg) | |
1669 "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
|
1670 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
|
1671 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
|
1672 `C-u -' alone as argument scrolls half the height of the merge window." |
583 | 1673 (interactive "P") |
1674 (emerge-operate-on-windows | |
1675 'scroll-up | |
1676 ;; calculate argument to scroll-up | |
1677 ;; if there is an explicit argument | |
1678 (if (and arg (not (equal arg '-))) | |
1679 ;; use it | |
1680 (prefix-numeric-value arg) | |
1681 ;; if not, see if we can determine a default amount (the window height) | |
1682 (let ((merge-window (get-buffer-window emerge-merge-buffer))) | |
1683 (if (null merge-window) | |
1684 ;; no window, use nil | |
1685 nil | |
1686 (let ((default-amount | |
1687 (- (window-height merge-window) 1 next-screen-context-lines))) | |
1688 ;; the window was found | |
1689 (if arg | |
1690 ;; C-u as argument means half of default amount | |
1691 (/ default-amount 2) | |
1692 ;; no argument means default amount | |
1693 default-amount))))))) | |
1694 | |
1695 (defun emerge-scroll-down (&optional arg) | |
1696 "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
|
1697 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
|
1698 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
|
1699 `C-u -' alone as argument scrolls half the height of the merge window." |
583 | 1700 (interactive "P") |
1701 (emerge-operate-on-windows | |
1702 'scroll-down | |
1703 ;; calculate argument to scroll-down | |
1704 ;; if there is an explicit argument | |
1705 (if (and arg (not (equal arg '-))) | |
1706 ;; use it | |
1707 (prefix-numeric-value arg) | |
1708 ;; if not, see if we can determine a default amount (the window height) | |
1709 (let ((merge-window (get-buffer-window emerge-merge-buffer))) | |
1710 (if (null merge-window) | |
1711 ;; no window, use nil | |
1712 nil | |
1713 (let ((default-amount | |
1714 (- (window-height merge-window) 1 next-screen-context-lines))) | |
1715 ;; the window was found | |
1716 (if arg | |
1717 ;; C-u as argument means half of default amount | |
1718 (/ default-amount 2) | |
1719 ;; no argument means default amount | |
1720 default-amount))))))) | |
1721 | |
1722 (defun emerge-scroll-left (&optional arg) | |
1723 "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
|
1724 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
|
1725 the width of the A and B windows. `C-u -' alone as argument scrolls half the |
583 | 1726 width of the A and B windows." |
1727 (interactive "P") | |
1728 (emerge-operate-on-windows | |
1729 'scroll-left | |
1730 ;; calculate argument to scroll-left | |
1731 ;; if there is an explicit argument | |
1732 (if (and arg (not (equal arg '-))) | |
1733 ;; use it | |
1734 (prefix-numeric-value arg) | |
1735 ;; if not, see if we can determine a default amount | |
1736 ;; (half the window width) | |
1737 (let ((merge-window (get-buffer-window emerge-merge-buffer))) | |
1738 (if (null merge-window) | |
1739 ;; no window, use nil | |
1740 nil | |
1741 (let ((default-amount | |
1742 (- (/ (window-width merge-window) 2) 3))) | |
1743 ;; the window was found | |
1744 (if arg | |
1745 ;; C-u as argument means half of default amount | |
1746 (/ default-amount 2) | |
1747 ;; no argument means default amount | |
1748 default-amount))))))) | |
1749 | |
1750 (defun emerge-scroll-right (&optional arg) | |
1751 "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
|
1752 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
|
1753 the width of the A and B windows. `C-u -' alone as argument scrolls half the |
583 | 1754 width of the A and B windows." |
1755 (interactive "P") | |
1756 (emerge-operate-on-windows | |
1757 'scroll-right | |
1758 ;; calculate argument to scroll-right | |
1759 ;; if there is an explicit argument | |
1760 (if (and arg (not (equal arg '-))) | |
1761 ;; use it | |
1762 (prefix-numeric-value arg) | |
1763 ;; if not, see if we can determine a default amount | |
1764 ;; (half the window width) | |
1765 (let ((merge-window (get-buffer-window emerge-merge-buffer))) | |
1766 (if (null merge-window) | |
1767 ;; no window, use nil | |
1768 nil | |
1769 (let ((default-amount | |
1770 (- (/ (window-width merge-window) 2) 3))) | |
1771 ;; the window was found | |
1772 (if arg | |
1773 ;; C-u as argument means half of default amount | |
1774 (/ default-amount 2) | |
1775 ;; no argument means default amount | |
1776 default-amount))))))) | |
1777 | |
1778 (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
|
1779 "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
|
1780 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
|
1781 to the left margin, if they are in windows." |
583 | 1782 (interactive) |
1783 (emerge-operate-on-windows | |
1784 (function (lambda (x) (set-window-hscroll (selected-window) 0))) | |
1785 nil)) | |
1786 | |
1787 ;; Attempt to show the region nicely. | |
1788 ;; If there are min-lines lines above and below the region, then don't do | |
1789 ;; anything. | |
1790 ;; If not, recenter the region to make it so. | |
14040 | 1791 ;; If that isn't possible, remove context lines balancedly from top and bottom |
583 | 1792 ;; so the entire region shows. |
1793 ;; If that isn't possible, show the top of the region. | |
1794 ;; BEG must be at the beginning of a line. | |
1795 (defun emerge-position-region (beg end pos) | |
1796 ;; First test whether the entire region is visible with | |
1797 ;; emerge-min-visible-lines above and below it | |
1798 (if (not (and (<= (progn | |
1799 (move-to-window-line emerge-min-visible-lines) | |
1800 (point)) | |
1801 beg) | |
1802 (<= end (progn | |
1803 (move-to-window-line | |
1804 (- (1+ emerge-min-visible-lines))) | |
1805 (point))))) | |
1806 ;; We failed that test, see if it fits at all | |
1807 ;; Meanwhile positioning it correctly in case it doesn't fit | |
1808 (progn | |
1809 (set-window-start (selected-window) beg) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
1810 (if (pos-visible-in-window-p end) |
583 | 1811 ;; Determine the number of lines that the region occupies |
1812 (let ((lines 0)) | |
1813 (while (> end (progn | |
1814 (move-to-window-line lines) | |
1815 (point))) | |
1816 (setq lines (1+ lines))) | |
1817 ;; And position the beginning on the right line | |
1818 (goto-char beg) | |
1819 (recenter (/ (1+ (- (1- (window-height (selected-window))) | |
1820 lines)) | |
1821 2)))))) | |
1822 (goto-char pos)) | |
1823 | |
1824 (defun emerge-next-difference () | |
1825 "Advance to the next difference." | |
1826 (interactive) | |
1827 (if (< emerge-current-difference emerge-number-of-differences) | |
1828 (let ((n (1+ emerge-current-difference))) | |
1829 (while (and emerge-skip-prefers | |
1830 (< n emerge-number-of-differences) | |
1831 (memq (aref (aref emerge-difference-list n) 6) | |
1832 '(prefer-A prefer-B))) | |
1833 (setq n (1+ n))) | |
1834 (let ((buffer-read-only nil)) | |
1835 (emerge-unselect-and-select-difference n))) | |
1836 (error "At end"))) | |
1837 | |
1838 (defun emerge-previous-difference () | |
1839 "Go to the previous difference." | |
1840 (interactive) | |
1841 (if (> emerge-current-difference -1) | |
1842 (let ((n (1- emerge-current-difference))) | |
1843 (while (and emerge-skip-prefers | |
1844 (> n -1) | |
1845 (memq (aref (aref emerge-difference-list n) 6) | |
1846 '(prefer-A prefer-B))) | |
1847 (setq n (1- n))) | |
1848 (let ((buffer-read-only nil)) | |
1849 (emerge-unselect-and-select-difference n))) | |
1850 (error "At beginning"))) | |
1851 | |
1852 (defun emerge-jump-to-difference (difference-number) | |
1853 "Go to the N-th difference." | |
1854 (interactive "p") | |
1855 (let ((buffer-read-only nil)) | |
1856 (setq difference-number (1- difference-number)) | |
1857 (if (and (>= difference-number -1) | |
1858 (< difference-number (1+ emerge-number-of-differences))) | |
1859 (emerge-unselect-and-select-difference difference-number) | |
1860 (error "Bad difference number")))) | |
1861 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1862 (defun emerge-abort () |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1863 "Abort the Emerge session." |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1864 (interactive) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1865 (emerge-quit t)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
1866 |
583 | 1867 (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
|
1868 "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
|
1869 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
|
1870 The difference depends on how the merge was started, |
583 | 1871 but usually means to not write over one of the original files, or to signal |
1872 to some process which invoked Emerge a failure code. | |
1873 | |
1874 Unselects the selected difference, if any, restores the read-only and modified | |
1875 flags of the merged file buffers, restores the local keymap of the merge | |
1876 buffer, and sets off various emerge flags. Using Emerge commands in this | |
1877 buffer after this will cause serious problems." | |
1878 (interactive "P") | |
1879 (if (prog1 | |
1880 (y-or-n-p | |
1881 (if (not arg) | |
1882 "Do you really want to successfully finish this merge? " | |
1883 "Do you really want to abort this merge? ")) | |
1884 (message "")) | |
1885 (emerge-really-quit arg))) | |
1886 | |
1887 ;; Perform the quit operations. | |
1888 (defun emerge-really-quit (arg) | |
1889 (setq buffer-read-only nil) | |
1890 (emerge-unselect-and-select-difference -1) | |
1891 (emerge-restore-buffer-characteristics) | |
1892 ;; null out the difference markers so they don't slow down future editing | |
1893 ;; operations | |
1894 (mapcar (function (lambda (d) | |
1895 (set-marker (aref d 0) nil) | |
1896 (set-marker (aref d 1) nil) | |
1897 (set-marker (aref d 2) nil) | |
1898 (set-marker (aref d 3) nil) | |
1899 (set-marker (aref d 4) nil) | |
1900 (set-marker (aref d 5) nil))) | |
1901 emerge-difference-list) | |
1902 ;; allow them to be garbage collected | |
1903 (setq emerge-difference-list nil) | |
1904 ;; restore the local map | |
1905 (use-local-map emerge-old-keymap) | |
1906 ;; turn off all the emerge modes | |
1907 (setq emerge-mode nil) | |
1908 (setq emerge-fast-mode nil) | |
1909 (setq emerge-edit-mode nil) | |
1910 (setq emerge-auto-advance nil) | |
1911 (setq emerge-skip-prefers nil) | |
1912 ;; restore mode line | |
1913 (kill-local-variable 'mode-line-buffer-identification) | |
1914 (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
|
1915 (run-hooks 'emerge-quit-hook))) |
583 | 1916 |
1917 (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
|
1918 "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
|
1919 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
|
1920 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
|
1921 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
|
1922 even if the difference has been edited." |
583 | 1923 (interactive "P") |
1924 (let ((operate | |
1925 (function (lambda () | |
1926 (emerge-select-A-edit merge-begin merge-end A-begin A-end) | |
1927 (if emerge-auto-advance | |
1928 (emerge-next-difference))))) | |
1929 (operate-no-change | |
1930 (function (lambda () | |
1931 (if emerge-auto-advance | |
1932 (emerge-next-difference)))))) | |
1933 (emerge-select-version force operate-no-change operate operate))) | |
1934 | |
1935 ;; Actually select the A variant | |
1936 (defun emerge-select-A-edit (merge-begin merge-end A-begin A-end) | |
1937 (emerge-eval-in-buffer | |
1938 emerge-merge-buffer | |
1939 (delete-region merge-begin merge-end) | |
1940 (goto-char merge-begin) | |
1941 (insert-buffer-substring emerge-A-buffer A-begin A-end) | |
1942 (goto-char merge-begin) | |
1943 (aset diff-vector 6 'A) | |
1944 (emerge-refresh-mode-line))) | |
1945 | |
1946 (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
|
1947 "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
|
1948 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
|
1949 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
|
1950 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
|
1951 even if the difference has been edited." |
583 | 1952 (interactive "P") |
1953 (let ((operate | |
1954 (function (lambda () | |
1955 (emerge-select-B-edit merge-begin merge-end B-begin B-end) | |
1956 (if emerge-auto-advance | |
1957 (emerge-next-difference))))) | |
1958 (operate-no-change | |
1959 (function (lambda () | |
1960 (if emerge-auto-advance | |
1961 (emerge-next-difference)))))) | |
1962 (emerge-select-version force operate operate-no-change operate))) | |
1963 | |
1964 ;; Actually select the B variant | |
1965 (defun emerge-select-B-edit (merge-begin merge-end B-begin B-end) | |
1966 (emerge-eval-in-buffer | |
1967 emerge-merge-buffer | |
1968 (delete-region merge-begin merge-end) | |
1969 (goto-char merge-begin) | |
1970 (insert-buffer-substring emerge-B-buffer B-begin B-end) | |
1971 (goto-char merge-begin) | |
1972 (aset diff-vector 6 'B) | |
1973 (emerge-refresh-mode-line))) | |
1974 | |
1975 (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
|
1976 "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
|
1977 This selects the A variant for all differences from here down in the buffer |
583 | 1978 which are still defaulted, i.e., which the user has not selected and for |
1979 which there is no preference." | |
1980 (interactive) | |
1981 (let ((buffer-read-only nil)) | |
1982 (let ((selected-difference emerge-current-difference) | |
1983 (n (max emerge-current-difference 0))) | |
1984 (while (< n emerge-number-of-differences) | |
1985 (let ((diff-vector (aref emerge-difference-list n))) | |
1986 (if (eq (aref diff-vector 6) 'default-B) | |
1987 (progn | |
1988 (emerge-unselect-and-select-difference n t) | |
1989 (emerge-select-A) | |
1990 (aset diff-vector 6 'default-A)))) | |
1991 (setq n (1+ n)) | |
4399
8080301bd1d9
(emerge-default-[AB]): Use (zerop (% A B)) instead of
Paul Eggert <eggert@twinsun.com>
parents:
3732
diff
changeset
|
1992 (if (zerop (% n 10)) |
583 | 1993 (message "Setting default to A...%d" n))) |
1994 (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
|
1995 (message "Default choice is now A")) |
583 | 1996 |
1997 (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
|
1998 "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
|
1999 This selects the B variant for all differences from here down in the buffer |
583 | 2000 which are still defaulted, i.e., which the user has not selected and for |
2001 which there is no preference." | |
2002 (interactive) | |
2003 (let ((buffer-read-only nil)) | |
2004 (let ((selected-difference emerge-current-difference) | |
2005 (n (max emerge-current-difference 0))) | |
2006 (while (< n emerge-number-of-differences) | |
2007 (let ((diff-vector (aref emerge-difference-list n))) | |
2008 (if (eq (aref diff-vector 6) 'default-A) | |
2009 (progn | |
2010 (emerge-unselect-and-select-difference n t) | |
2011 (emerge-select-B) | |
2012 (aset diff-vector 6 'default-B)))) | |
2013 (setq n (1+ n)) | |
4399
8080301bd1d9
(emerge-default-[AB]): Use (zerop (% A B)) instead of
Paul Eggert <eggert@twinsun.com>
parents:
3732
diff
changeset
|
2014 (if (zerop (% n 10)) |
583 | 2015 (message "Setting default to B...%d" n))) |
2016 (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
|
2017 (message "Default choice is now B")) |
583 | 2018 |
2019 (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
|
2020 "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
|
2021 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
|
2022 need not be prefixed with \\<emerge-fast-keymap>\\[emerge-basic-keymap]." |
583 | 2023 (interactive) |
2024 (setq buffer-read-only t) | |
2025 (use-local-map emerge-fast-keymap) | |
2026 (setq emerge-mode t) | |
2027 (setq emerge-fast-mode t) | |
2028 (setq emerge-edit-mode nil) | |
2029 (message "Fast mode set") | |
11564
26d4ff74d4ab
(emerge-fast-mode, emerge-edit-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
10179
diff
changeset
|
2030 (force-mode-line-update)) |
583 | 2031 |
2032 (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
|
2033 "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
|
2034 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
|
2035 must be prefixed with \\<emerge-fast-keymap>\\[emerge-basic-keymap]." |
583 | 2036 (interactive) |
2037 (setq buffer-read-only nil) | |
2038 (use-local-map emerge-edit-keymap) | |
2039 (setq emerge-mode t) | |
2040 (setq emerge-fast-mode nil) | |
2041 (setq emerge-edit-mode t) | |
2042 (message "Edit mode set") | |
11564
26d4ff74d4ab
(emerge-fast-mode, emerge-edit-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
10179
diff
changeset
|
2043 (force-mode-line-update)) |
583 | 2044 |
2045 (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
|
2046 "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
|
2047 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
|
2048 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
|
2049 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
|
2050 With a negative argument, turn off Auto-Advance mode." |
583 | 2051 (interactive "P") |
2052 (setq emerge-auto-advance (if (null arg) | |
2053 (not emerge-auto-advance) | |
2054 (> (prefix-numeric-value arg) 0))) | |
9636
bfc3782dd769
(emerge-auto-advance): Fix criterion for which message.
Richard M. Stallman <rms@gnu.org>
parents:
9606
diff
changeset
|
2055 (message (if emerge-auto-advance |
583 | 2056 "Auto-advance set" |
2057 "Auto-advance cleared")) | |
11564
26d4ff74d4ab
(emerge-fast-mode, emerge-edit-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
10179
diff
changeset
|
2058 (force-mode-line-update)) |
583 | 2059 |
2060 (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
|
2061 "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
|
2062 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
|
2063 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
|
2064 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
|
2065 With a negative argument, turn off Skip-Prefers mode." |
583 | 2066 (interactive "P") |
2067 (setq emerge-skip-prefers (if (null arg) | |
2068 (not emerge-skip-prefers) | |
2069 (> (prefix-numeric-value arg) 0))) | |
2070 (message (if emerge-skip-prefers | |
2071 "Skip-prefers set" | |
2072 "Skip-prefers cleared")) | |
11564
26d4ff74d4ab
(emerge-fast-mode, emerge-edit-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
10179
diff
changeset
|
2073 (force-mode-line-update)) |
583 | 2074 |
2075 (defun emerge-copy-as-kill-A () | |
2076 "Put the A variant of this difference in the kill ring." | |
2077 (interactive) | |
2078 (emerge-validate-difference) | |
2079 (let* ((diff-vector | |
2080 (aref emerge-difference-list emerge-current-difference)) | |
2081 (A-begin (1+ (aref diff-vector 0))) | |
2082 (A-end (1- (aref diff-vector 1))) | |
2083 ;; so further kills don't append | |
2084 this-command) | |
2085 (save-excursion | |
2086 (set-buffer emerge-A-buffer) | |
2087 (copy-region-as-kill A-begin A-end)))) | |
2088 | |
2089 (defun emerge-copy-as-kill-B () | |
2090 "Put the B variant of this difference in the kill ring." | |
2091 (interactive) | |
2092 (emerge-validate-difference) | |
2093 (let* ((diff-vector | |
2094 (aref emerge-difference-list emerge-current-difference)) | |
2095 (B-begin (1+ (aref diff-vector 2))) | |
2096 (B-end (1- (aref diff-vector 3))) | |
2097 ;; so further kills don't append | |
2098 this-command) | |
2099 (save-excursion | |
2100 (set-buffer emerge-B-buffer) | |
2101 (copy-region-as-kill B-begin B-end)))) | |
2102 | |
2103 (defun emerge-insert-A (arg) | |
2104 "Insert the A variant of this difference at the point. | |
2105 Leaves point after text, mark before. | |
2106 With prefix argument, puts point before, mark after." | |
2107 (interactive "P") | |
2108 (emerge-validate-difference) | |
2109 (let* ((diff-vector | |
2110 (aref emerge-difference-list emerge-current-difference)) | |
2111 (A-begin (1+ (aref diff-vector 0))) | |
2112 (A-end (1- (aref diff-vector 1))) | |
2113 (opoint (point)) | |
2114 (buffer-read-only nil)) | |
2115 (insert-buffer-substring emerge-A-buffer A-begin A-end) | |
2116 (if (not arg) | |
2117 (set-mark opoint) | |
2118 (set-mark (point)) | |
2119 (goto-char opoint)))) | |
2120 | |
2121 (defun emerge-insert-B (arg) | |
2122 "Insert the B variant of this difference at the point. | |
2123 Leaves point after text, mark before. | |
2124 With prefix argument, puts point before, mark after." | |
2125 (interactive "P") | |
2126 (emerge-validate-difference) | |
2127 (let* ((diff-vector | |
2128 (aref emerge-difference-list emerge-current-difference)) | |
2129 (B-begin (1+ (aref diff-vector 2))) | |
2130 (B-end (1- (aref diff-vector 3))) | |
2131 (opoint (point)) | |
2132 (buffer-read-only nil)) | |
2133 (insert-buffer-substring emerge-B-buffer B-begin B-end) | |
2134 (if (not arg) | |
2135 (set-mark opoint) | |
2136 (set-mark (point)) | |
2137 (goto-char opoint)))) | |
2138 | |
2139 (defun emerge-mark-difference (arg) | |
2140 "Leaves the point before this difference and the mark after it. | |
2141 With prefix argument, puts mark before, point after." | |
2142 (interactive "P") | |
2143 (emerge-validate-difference) | |
2144 (let* ((diff-vector | |
2145 (aref emerge-difference-list emerge-current-difference)) | |
2146 (merge-begin (1+ (aref diff-vector 4))) | |
2147 (merge-end (1- (aref diff-vector 5)))) | |
2148 (if (not arg) | |
2149 (progn | |
2150 (goto-char merge-begin) | |
2151 (set-mark merge-end)) | |
2152 (goto-char merge-end) | |
2153 (set-mark merge-begin)))) | |
2154 | |
2155 (defun emerge-file-names () | |
2156 "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
|
2157 Use C-u l to reset the windows afterward." |
583 | 2158 (interactive) |
2159 (delete-other-windows) | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
2160 (let ((temp-buffer-show-function |
583 | 2161 (function (lambda (buf) |
2162 (split-window-vertically) | |
2163 (switch-to-buffer buf) | |
2164 (other-window 1))))) | |
2165 (with-output-to-temp-buffer "*Help*" | |
2166 (emerge-eval-in-buffer emerge-A-buffer | |
2167 (if buffer-file-name | |
2168 (progn | |
2169 (princ "File A is: ") | |
2170 (princ buffer-file-name)) | |
2171 (progn | |
2172 (princ "Buffer A is: ") | |
2173 (princ (buffer-name)))) | |
2174 (princ "\n")) | |
2175 (emerge-eval-in-buffer emerge-B-buffer | |
2176 (if buffer-file-name | |
2177 (progn | |
2178 (princ "File B is: ") | |
2179 (princ buffer-file-name)) | |
2180 (progn | |
2181 (princ "Buffer B is: ") | |
2182 (princ (buffer-name)))) | |
2183 (princ "\n")) | |
2184 (if emerge-ancestor-buffer | |
2185 (emerge-eval-in-buffer emerge-ancestor-buffer | |
2186 (if buffer-file-name | |
2187 (progn | |
2188 (princ "Ancestor file is: ") | |
2189 (princ buffer-file-name)) | |
2190 (progn | |
2191 (princ "Ancestor buffer is: ") | |
2192 (princ (buffer-name)))) | |
2193 (princ "\n"))) | |
9861
7a43916ca395
(emerge-file-names): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9636
diff
changeset
|
2194 (princ emerge-output-description) |
7a43916ca395
(emerge-file-names): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9636
diff
changeset
|
2195 (save-excursion |
7a43916ca395
(emerge-file-names): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9636
diff
changeset
|
2196 (set-buffer standard-output) |
7a43916ca395
(emerge-file-names): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9636
diff
changeset
|
2197 (help-mode))))) |
583 | 2198 |
2199 (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
|
2200 "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
|
2201 With a prefix argument, join with the preceding one." |
583 | 2202 (interactive "P") |
2203 (let ((n emerge-current-difference)) | |
2204 ;; adjust n to be first difference to join | |
2205 (if arg | |
2206 (setq n (1- n))) | |
2207 ;; n and n+1 are the differences to join | |
2208 ;; check that they are both differences | |
2209 (if (or (< n 0) (>= n (1- emerge-number-of-differences))) | |
2210 (error "Incorrect differences to join")) | |
2211 ;; remove the flags | |
2212 (emerge-unselect-difference emerge-current-difference) | |
2213 ;; decrement total number of differences | |
2214 (setq emerge-number-of-differences (1- emerge-number-of-differences)) | |
2215 ;; build new differences vector | |
2216 (let ((i 0) | |
2217 (new-differences (make-vector emerge-number-of-differences nil))) | |
2218 (while (< i emerge-number-of-differences) | |
2219 (aset new-differences i | |
2220 (cond | |
2221 ((< i n) (aref emerge-difference-list i)) | |
2222 ((> i n) (aref emerge-difference-list (1+ i))) | |
2223 (t (let ((prev (aref emerge-difference-list i)) | |
2224 (next (aref emerge-difference-list (1+ i)))) | |
2225 (vector (aref prev 0) | |
2226 (aref next 1) | |
2227 (aref prev 2) | |
2228 (aref next 3) | |
2229 (aref prev 4) | |
2230 (aref next 5) | |
2231 (let ((ps (aref prev 6)) | |
2232 (ns (aref next 6))) | |
2233 (cond | |
2234 ((eq ps ns) | |
2235 ps) | |
2236 ((and (or (eq ps 'B) (eq ps 'prefer-B)) | |
2237 (or (eq ns 'B) (eq ns 'prefer-B))) | |
2238 'B) | |
2239 (t 'A)))))))) | |
2240 (setq i (1+ i))) | |
2241 (setq emerge-difference-list new-differences)) | |
2242 ;; set the current difference correctly | |
2243 (setq emerge-current-difference n) | |
2244 ;; fix the mode line | |
2245 (emerge-refresh-mode-line) | |
2246 ;; reinsert the flags | |
2247 (emerge-select-difference emerge-current-difference) | |
2248 (emerge-recenter))) | |
2249 | |
2250 (defun emerge-split-difference () | |
2251 "Split the current difference where the points are in the three windows." | |
2252 (interactive) | |
2253 (let ((n emerge-current-difference)) | |
2254 ;; check that this is a valid difference | |
2255 (emerge-validate-difference) | |
2256 ;; get the point values and old difference | |
2257 (let ((A-point (emerge-eval-in-buffer emerge-A-buffer | |
2258 (point-marker))) | |
2259 (B-point (emerge-eval-in-buffer emerge-B-buffer | |
2260 (point-marker))) | |
2261 (merge-point (point-marker)) | |
2262 (old-diff (aref emerge-difference-list n))) | |
2263 ;; check location of the points, give error if they aren't in the | |
2264 ;; differences | |
2265 (if (or (< A-point (aref old-diff 0)) | |
2266 (> A-point (aref old-diff 1))) | |
2267 (error "Point outside of difference in A buffer")) | |
2268 (if (or (< B-point (aref old-diff 2)) | |
2269 (> B-point (aref old-diff 3))) | |
2270 (error "Point outside of difference in B buffer")) | |
2271 (if (or (< merge-point (aref old-diff 4)) | |
2272 (> merge-point (aref old-diff 5))) | |
2273 (error "Point outside of difference in merge buffer")) | |
2274 ;; remove the flags | |
2275 (emerge-unselect-difference emerge-current-difference) | |
2276 ;; increment total number of differences | |
2277 (setq emerge-number-of-differences (1+ emerge-number-of-differences)) | |
2278 ;; build new differences vector | |
2279 (let ((i 0) | |
2280 (new-differences (make-vector emerge-number-of-differences nil))) | |
2281 (while (< i emerge-number-of-differences) | |
2282 (aset new-differences i | |
2283 (cond | |
2284 ((< i n) | |
2285 (aref emerge-difference-list i)) | |
2286 ((> i (1+ n)) | |
2287 (aref emerge-difference-list (1- i))) | |
2288 ((= i n) | |
2289 (vector (aref old-diff 0) | |
2290 A-point | |
2291 (aref old-diff 2) | |
2292 B-point | |
2293 (aref old-diff 4) | |
2294 merge-point | |
2295 (aref old-diff 6))) | |
2296 (t | |
2297 (vector (copy-marker A-point) | |
2298 (aref old-diff 1) | |
2299 (copy-marker B-point) | |
2300 (aref old-diff 3) | |
2301 (copy-marker merge-point) | |
2302 (aref old-diff 5) | |
2303 (aref old-diff 6))))) | |
2304 (setq i (1+ i))) | |
2305 (setq emerge-difference-list new-differences)) | |
2306 ;; set the current difference correctly | |
2307 (setq emerge-current-difference n) | |
2308 ;; fix the mode line | |
2309 (emerge-refresh-mode-line) | |
2310 ;; reinsert the flags | |
2311 (emerge-select-difference emerge-current-difference) | |
2312 (emerge-recenter)))) | |
2313 | |
2314 (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
|
2315 "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
|
2316 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
|
2317 \(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
|
2318 ancestor version does not share.)" |
583 | 2319 (interactive) |
2320 ;; make sure we are in a real difference | |
2321 (emerge-validate-difference) | |
2322 ;; remove the flags | |
2323 (emerge-unselect-difference emerge-current-difference) | |
2324 (let* ((diff (aref emerge-difference-list emerge-current-difference)) | |
2325 (top-a (marker-position (aref diff 0))) | |
2326 (bottom-a (marker-position (aref diff 1))) | |
2327 (top-b (marker-position (aref diff 2))) | |
2328 (bottom-b (marker-position (aref diff 3))) | |
2329 (top-m (marker-position (aref diff 4))) | |
2330 (bottom-m (marker-position (aref diff 5))) | |
2331 size success sa sb sm) | |
2332 ;; move down the tops of the difference regions as much as possible | |
2333 ;; Try advancing comparing 1000 chars at a time. | |
2334 ;; When that fails, go 500 chars at a time, and so on. | |
2335 (setq size 1000) | |
2336 (while (> size 0) | |
2337 (setq success t) | |
2338 (while success | |
2339 (setq size (min size (- bottom-a top-a) (- bottom-b top-b) | |
2340 (- bottom-m top-m))) | |
2341 (setq sa (emerge-eval-in-buffer emerge-A-buffer | |
2342 (buffer-substring top-a | |
2343 (+ size top-a)))) | |
2344 (setq sb (emerge-eval-in-buffer emerge-B-buffer | |
2345 (buffer-substring top-b | |
2346 (+ size top-b)))) | |
2347 (setq sm (buffer-substring top-m (+ size top-m))) | |
2348 (setq success (and (> size 0) (equal sa sb) (equal sb sm))) | |
2349 (if success | |
2350 (setq top-a (+ top-a size) | |
2351 top-b (+ top-b size) | |
2352 top-m (+ top-m size)))) | |
2353 (setq size (/ size 2))) | |
2354 ;; move up the bottoms of the difference regions as much as possible | |
2355 ;; Try advancing comparing 1000 chars at a time. | |
2356 ;; When that fails, go 500 chars at a time, and so on. | |
2357 (setq size 1000) | |
2358 (while (> size 0) | |
2359 (setq success t) | |
2360 (while success | |
2361 (setq size (min size (- bottom-a top-a) (- bottom-b top-b) | |
2362 (- bottom-m top-m))) | |
2363 (setq sa (emerge-eval-in-buffer emerge-A-buffer | |
2364 (buffer-substring (- bottom-a size) | |
2365 bottom-a))) | |
2366 (setq sb (emerge-eval-in-buffer emerge-B-buffer | |
2367 (buffer-substring (- bottom-b size) | |
2368 bottom-b))) | |
2369 (setq sm (buffer-substring (- bottom-m size) bottom-m)) | |
2370 (setq success (and (> size 0) (equal sa sb) (equal sb sm))) | |
2371 (if success | |
2372 (setq bottom-a (- bottom-a size) | |
2373 bottom-b (- bottom-b size) | |
2374 bottom-m (- bottom-m size)))) | |
2375 (setq size (/ size 2))) | |
2376 ;; {top,bottom}-{a,b,m} are now set at the new beginnings and ends | |
2377 ;; of the difference regions. Move them to the beginning of lines, as | |
2378 ;; appropriate. | |
2379 (emerge-eval-in-buffer emerge-A-buffer | |
2380 (goto-char top-a) | |
2381 (beginning-of-line) | |
2382 (aset diff 0 (point-marker)) | |
2383 (goto-char bottom-a) | |
2384 (beginning-of-line 2) | |
2385 (aset diff 1 (point-marker))) | |
2386 (emerge-eval-in-buffer emerge-B-buffer | |
2387 (goto-char top-b) | |
2388 (beginning-of-line) | |
2389 (aset diff 2 (point-marker)) | |
2390 (goto-char bottom-b) | |
2391 (beginning-of-line 2) | |
2392 (aset diff 3 (point-marker))) | |
2393 (goto-char top-m) | |
2394 (beginning-of-line) | |
2395 (aset diff 4 (point-marker)) | |
2396 (goto-char bottom-m) | |
2397 (beginning-of-line 2) | |
2398 (aset diff 5 (point-marker)) | |
2399 ;; put the flags back in, recenter the display | |
2400 (emerge-select-difference emerge-current-difference) | |
2401 (emerge-recenter))) | |
2402 | |
2403 (defun emerge-find-difference (arg) | |
2404 "Find the difference containing the current position of the point. | |
2405 If there is no containing difference and the prefix argument is positive, | |
2406 it finds the nearest following difference. A negative prefix argument finds | |
2407 the nearest previous difference." | |
4560
106e0040381f
(emerge-find-difference): Add interactive spec.
Richard M. Stallman <rms@gnu.org>
parents:
4399
diff
changeset
|
2408 (interactive "P") |
2773
8ab8f28b78d1
(emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents:
2772
diff
changeset
|
2409 (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
|
2410 (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
|
2411 ((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
|
2412 (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
|
2413 (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
|
2414 |
8ab8f28b78d1
(emerge-find-difference-diff): Renamed from emerge-find-difference.
Richard M. Stallman <rms@gnu.org>
parents:
2772
diff
changeset
|
2415 (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
|
2416 "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
|
2417 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
|
2418 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
|
2419 the nearest previous difference." |
583 | 2420 (interactive "P") |
2421 ;; search for the point in the merge buffer, using the markers | |
2422 ;; for the beginning and end of the differences in the merge buffer | |
2423 (emerge-find-difference1 arg (point) 4 5)) | |
2424 | |
2425 (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
|
2426 "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
|
2427 This command must be executed in the merge buffer. |
583 | 2428 If there is no containing difference and the prefix argument is positive, |
2429 it finds the nearest following difference. A negative prefix argument finds | |
2430 the nearest previous difference." | |
2431 (interactive "P") | |
2432 ;; search for the point in the A buffer, using the markers | |
2433 ;; for the beginning and end of the differences in the A buffer | |
2434 (emerge-find-difference1 arg | |
2435 (emerge-eval-in-buffer emerge-A-buffer (point)) | |
2436 0 1)) | |
2437 | |
2438 (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
|
2439 "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
|
2440 This command must be executed in the merge buffer. |
583 | 2441 If there is no containing difference and the prefix argument is positive, |
2442 it finds the nearest following difference. A negative prefix argument finds | |
2443 the nearest previous difference." | |
2444 (interactive "P") | |
2445 ;; search for the point in the B buffer, using the markers | |
2446 ;; for the beginning and end of the differences in the B buffer | |
2447 (emerge-find-difference1 arg | |
2448 (emerge-eval-in-buffer emerge-B-buffer (point)) | |
2449 2 3)) | |
2450 | |
2451 (defun emerge-find-difference1 (arg location begin end) | |
2452 (let* ((index | |
2453 ;; find first difference containing or after the current position | |
2454 (catch 'search | |
2455 (let ((n 0)) | |
2456 (while (< n emerge-number-of-differences) | |
2457 (let ((diff-vector (aref emerge-difference-list n))) | |
2458 (if (<= location (marker-position (aref diff-vector end))) | |
2459 (throw 'search n))) | |
2460 (setq n (1+ n)))) | |
2461 emerge-number-of-differences)) | |
2462 (contains | |
2463 ;; whether the found difference contains the current position | |
2464 (and (< index emerge-number-of-differences) | |
2465 (<= (marker-position (aref (aref emerge-difference-list index) | |
2466 begin)) | |
2467 location))) | |
2468 (arg-value | |
2469 ;; numeric value of prefix argument | |
2470 (prefix-numeric-value arg))) | |
2471 (emerge-unselect-and-select-difference | |
2472 (cond | |
2473 ;; if the point is in a difference, select it | |
2474 (contains index) | |
2475 ;; if the arg is nil and the point is not in a difference, error | |
2476 ((null arg) (error "No difference contains point")) | |
2477 ;; if the arg is positive, select the following difference | |
2478 ((> arg-value 0) | |
2479 (if (< index emerge-number-of-differences) | |
2480 index | |
2481 (error "No difference contains or follows point"))) | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2773
diff
changeset
|
2482 ;; if the arg is negative, select the preceding difference |
583 | 2483 (t |
2484 (if (> index 0) | |
2485 (1- index) | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2773
diff
changeset
|
2486 (error "No difference contains or precedes point"))))))) |
583 | 2487 |
2488 (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
|
2489 "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
|
2490 This function displays the line numbers of the points in the A, B, and |
583 | 2491 merge buffers." |
2492 (interactive) | |
2493 (let* ((valid-diff | |
2494 (and (>= emerge-current-difference 0) | |
2495 (< emerge-current-difference emerge-number-of-differences))) | |
2496 (diff (and valid-diff | |
2497 (aref emerge-difference-list emerge-current-difference))) | |
2498 (merge-line (emerge-line-number-in-buf 4 5)) | |
2499 (A-line (emerge-eval-in-buffer emerge-A-buffer | |
2500 (emerge-line-number-in-buf 0 1))) | |
2501 (B-line (emerge-eval-in-buffer emerge-B-buffer | |
2502 (emerge-line-number-in-buf 2 3)))) | |
2503 (message "At lines: merge = %d, A = %d, B = %d" | |
2504 merge-line A-line B-line))) | |
2505 | |
2506 (defun emerge-line-number-in-buf (begin-marker end-marker) | |
2507 (let (temp) | |
2508 (setq temp (save-excursion | |
2509 (beginning-of-line) | |
2510 (1+ (count-lines 1 (point))))) | |
2511 (if valid-diff | |
2512 (progn | |
2513 (if (> (point) (aref diff begin-marker)) | |
2514 (setq temp (- temp emerge-before-flag-lines))) | |
2515 (if (> (point) (aref diff end-marker)) | |
2516 (setq temp (- temp emerge-after-flag-lines))))) | |
2517 temp)) | |
2518 | |
5796
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
2519 (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
|
2520 "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
|
2521 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
|
2522 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
|
2523 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
|
2524 (interactive "s\nP") |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
2525 (if localize |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
2526 (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
|
2527 (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
|
2528 (message |
b53b2df1351d
Add defvars for many vars already being used.
Richard M. Stallman <rms@gnu.org>
parents:
4560
diff
changeset
|
2529 (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
|
2530 "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
|
2531 "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
|
2532 |
583 | 2533 (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
|
2534 "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
|
2535 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
|
2536 With prefix argument, `emerge-combine-versions-template' is made local to this |
583 | 2537 merge buffer. Localization is permanent for any particular merge buffer." |
2538 (interactive "r\nP") | |
2539 (if localize | |
2540 (make-local-variable 'emerge-combine-versions-template)) | |
2541 (setq emerge-combine-versions-template (buffer-substring start end)) | |
2542 (message | |
2543 (if (assq 'emerge-combine-versions-template (buffer-local-variables)) | |
2544 "emerge-set-combine-versions-template set locally." | |
2545 "emerge-set-combine-versions-template set."))) | |
2546 | |
2547 (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
|
2548 "Combine versions using the template in `emerge-combine-versions-template'. |
583 | 2549 Refuses to function if this difference has been edited, i.e., if it is |
2550 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
|
2551 An argument forces the variant to be selected even if the difference has |
583 | 2552 been edited." |
2553 (interactive "P") | |
2554 (emerge-combine-versions-internal emerge-combine-versions-template force)) | |
2555 | |
2556 (defun emerge-combine-versions-register (char &optional force) | |
2557 "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
|
2558 See documentation of the variable `emerge-combine-versions-template' |
583 | 2559 for how the template is interpreted. |
2560 Refuses to function if this difference has been edited, i.e., if it is | |
2561 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
|
2562 An argument forces the variant to be selected even if the difference has |
583 | 2563 been edited." |
2564 (interactive "cRegister containing template: \nP") | |
2565 (let ((template (get-register char))) | |
2566 (if (not (stringp template)) | |
2567 (error "Register does not contain text")) | |
2568 (emerge-combine-versions-internal template force))) | |
2569 | |
2570 (defun emerge-combine-versions-internal (template force) | |
2571 (let ((operate | |
2572 (function (lambda () | |
2573 (emerge-combine-versions-edit merge-begin merge-end | |
2574 A-begin A-end B-begin B-end) | |
2575 (if emerge-auto-advance | |
2576 (emerge-next-difference)))))) | |
2577 (emerge-select-version force operate operate operate))) | |
2578 | |
2579 (defun emerge-combine-versions-edit (merge-begin merge-end | |
2580 A-begin A-end B-begin B-end) | |
2581 (emerge-eval-in-buffer | |
2582 emerge-merge-buffer | |
2583 (delete-region merge-begin merge-end) | |
2584 (goto-char merge-begin) | |
2585 (let ((i 0)) | |
2586 (while (< i (length template)) | |
2587 (let ((c (aref template i))) | |
2588 (if (= c ?%) | |
2589 (progn | |
2590 (setq i (1+ i)) | |
2591 (setq c | |
2592 (condition-case nil | |
2593 (aref template i) | |
2594 (error ?%))) | |
2595 (cond ((= c ?a) | |
2596 (insert-buffer-substring emerge-A-buffer A-begin A-end)) | |
2597 ((= c ?b) | |
2598 (insert-buffer-substring emerge-B-buffer B-begin B-end)) | |
2599 ((= c ?%) | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
2600 (insert ?%)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
2601 (t |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
2602 (insert c)))) |
583 | 2603 (insert c))) |
2604 (setq i (1+ i)))) | |
2605 (goto-char merge-begin) | |
2606 (aset diff-vector 6 'combined) | |
2607 (emerge-refresh-mode-line))) | |
2608 | |
2609 (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
|
2610 "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
|
2611 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
|
2612 keymap. Leaves merge in fast mode." |
583 | 2613 (interactive |
2614 (list (intern (completing-read "New major mode for merge buffer: " | |
2615 obarray 'commandp t nil)))) | |
2616 (funcall mode) | |
2617 (emerge-refresh-mode-line) | |
2618 (if emerge-fast-mode | |
2619 (emerge-fast-mode) | |
2620 (emerge-edit-mode))) | |
2621 | |
2622 (defun emerge-one-line-window () | |
2623 (interactive) | |
2624 (let ((window-min-height 1)) | |
2625 (shrink-window (- (window-height) 2)))) | |
2626 | |
2627 ;;; Support routines | |
2628 | |
2629 ;; Select a difference by placing the visual flags around the appropriate | |
2630 ;; group of lines in the A, B, and merge buffers | |
2631 (defun emerge-select-difference (n) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2632 (let ((emerge-globalized-difference-list emerge-difference-list) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2633 (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
|
2634 (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
|
2635 (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
|
2636 (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
|
2637 (run-hooks 'emerge-select-hook)) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2638 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2639 (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
|
2640 after-index) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2641 (if buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2642 (emerge-eval-in-buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2643 buffer |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2644 (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
|
2645 (emerge-place-flags-in-buffer1 difference before-index after-index))) |
583 | 2646 |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2647 (defun emerge-place-flags-in-buffer1 (difference before-index after-index) |
583 | 2648 (let ((buffer-read-only nil)) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2649 ;; insert the flag before the difference |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2650 (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
|
2651 before-index)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2652 here) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2653 (goto-char before) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2654 ;; insert the flag itself |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2655 (insert-before-markers emerge-before-flag) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2656 (setq here (point)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2657 ;; 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
|
2658 ;; 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
|
2659 ;; 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
|
2660 ;; that have to be moved. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2661 (set-marker before (1- before)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2662 (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
|
2663 (while (and |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2664 (>= n 0) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2665 (progn |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2666 (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
|
2667 after-marker (aref diff-list after-index)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2668 (= after-marker here))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2669 (set-marker after-marker (1- after-marker)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2670 (setq before-marker (aref diff-list before-index)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2671 (if (= before-marker here) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2672 (setq before-marker (1- before-marker))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2673 (setq n (1- n))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2674 ;; insert the flag after the difference |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2675 (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
|
2676 after-index)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2677 (here (marker-position after))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2678 (goto-char here) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2679 ;; insert the flag itself |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2680 (insert emerge-after-flag) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2681 ;; 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
|
2682 ;; 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
|
2683 ;; 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
|
2684 ;; that have to be moved. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2685 (set-marker after (1+ after)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2686 (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
|
2687 (while (and |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2688 (< n emerge-globalized-number-of-differences) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2689 (progn |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2690 (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
|
2691 before-marker (aref diff-list before-index)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2692 (= before-marker here))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2693 (set-marker before-marker (1+ before-marker)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2694 (setq after-marker (aref diff-list after-index)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2695 (if (= after-marker here) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2696 (setq after-marker (1+ after-marker))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2697 (setq n (1+ n))))))) |
583 | 2698 |
2699 ;; Unselect a difference by removing the visual flags in the buffers. | |
2700 (defun emerge-unselect-difference (n) | |
2701 (let ((diff-vector (aref emerge-difference-list n))) | |
2702 (emerge-remove-flags-in-buffer emerge-A-buffer | |
2703 (aref diff-vector 0) (aref diff-vector 1)) | |
2704 (emerge-remove-flags-in-buffer emerge-B-buffer | |
2705 (aref diff-vector 2) (aref diff-vector 3)) | |
2706 (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
|
2707 (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
|
2708 (run-hooks 'emerge-unselect-hook)) |
583 | 2709 |
2710 (defun emerge-remove-flags-in-buffer (buffer before after) | |
2711 (emerge-eval-in-buffer | |
2712 buffer | |
2713 (let ((buffer-read-only nil)) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2714 ;; remove the flags, if they're there |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2715 (goto-char (- before (1- emerge-before-flag-length))) |
583 | 2716 (if (looking-at emerge-before-flag-match) |
2717 (delete-char emerge-before-flag-length) | |
2718 ;; the flag isn't there | |
2719 (ding) | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
2720 (message "Trouble removing flag")) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2721 (goto-char (1- after)) |
583 | 2722 (if (looking-at emerge-after-flag-match) |
2723 (delete-char emerge-after-flag-length) | |
2724 ;; the flag isn't there | |
2725 (ding) | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
2726 (message "Trouble removing flag"))))) |
583 | 2727 |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2728 ;; Select a difference, removing any flags that exist now. |
583 | 2729 (defun emerge-unselect-and-select-difference (n &optional suppress-display) |
2730 (if (and (>= emerge-current-difference 0) | |
2731 (< emerge-current-difference emerge-number-of-differences)) | |
2732 (emerge-unselect-difference emerge-current-difference)) | |
2733 (if (and (>= n 0) (< n emerge-number-of-differences)) | |
2734 (progn | |
2735 (emerge-select-difference n) | |
2736 (let* ((diff-vector (aref emerge-difference-list n)) | |
2737 (selection-type (aref diff-vector 6))) | |
2738 (if (eq selection-type 'default-A) | |
2739 (aset diff-vector 6 'A) | |
2740 (if (eq selection-type 'default-B) | |
2741 (aset diff-vector 6 'B)))))) | |
2742 (setq emerge-current-difference n) | |
2743 (if (not suppress-display) | |
2744 (progn | |
2745 (emerge-recenter) | |
2746 (emerge-refresh-mode-line)))) | |
2747 | |
2748 ;; Perform tests to see whether user should be allowed to select a version | |
2749 ;; of this difference: | |
2750 ;; a valid difference has been selected; and | |
2751 ;; the difference text in the merge buffer is: | |
2752 ;; the A version (execute a-version), or | |
2753 ;; the B version (execute b-version), or | |
2754 ;; empty (execute neither-version), or | |
2755 ;; argument FORCE is true (execute neither-version) | |
2756 ;; Otherwise, signal an error. | |
2757 (defun emerge-select-version (force a-version b-version neither-version) | |
2758 (emerge-validate-difference) | |
2759 (let ((buffer-read-only nil)) | |
2760 (let* ((diff-vector | |
2761 (aref emerge-difference-list emerge-current-difference)) | |
2762 (A-begin (1+ (aref diff-vector 0))) | |
2763 (A-end (1- (aref diff-vector 1))) | |
2764 (B-begin (1+ (aref diff-vector 2))) | |
2765 (B-end (1- (aref diff-vector 3))) | |
2766 (merge-begin (1+ (aref diff-vector 4))) | |
2767 (merge-end (1- (aref diff-vector 5)))) | |
2768 (if (emerge-compare-buffers emerge-A-buffer A-begin A-end | |
2769 emerge-merge-buffer merge-begin | |
2770 merge-end) | |
2771 (funcall a-version) | |
2772 (if (emerge-compare-buffers emerge-B-buffer B-begin B-end | |
2773 emerge-merge-buffer merge-begin | |
2774 merge-end) | |
2775 (funcall b-version) | |
2776 (if (or force (= merge-begin merge-end)) | |
2777 (funcall neither-version) | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2778 (error "This difference region has been edited"))))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2779 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2780 ;; 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
|
2781 |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2782 (defun emerge-read-file-name (prompt alternative-default-dir default-file |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
2783 A-file must-match) |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
2784 ;; `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
|
2785 ;; according to context. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2786 ;; 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
|
2787 ;; 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
|
2788 ;; is set. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2789 ;; 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
|
2790 ;; 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
|
2791 ;; 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
|
2792 ;; 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
|
2793 ;; directory. (Overriding default-file.) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2794 (cond |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2795 ;; 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
|
2796 ;; if emerge-default-last-directories is set, and |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2797 ;; 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
|
2798 ;; A-file, |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2799 ;; 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
|
2800 ;; the default directory. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2801 ((and emerge-default-last-directories |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2802 A-file |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2803 alternative-default-dir |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2804 (not (string-equal alternative-default-dir |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2805 (file-name-directory A-file)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2806 (read-file-name (format "%s (default %s): " |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2807 prompt (file-name-nondirectory A-file)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2808 alternative-default-dir |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2809 (concat alternative-default-dir |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2810 (file-name-nondirectory A-file)) |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
2811 (and must-match 'confirm))) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2812 ;; If there is a default file, use it. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2813 (default-file |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2814 (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
|
2815 ;; 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
|
2816 ;; 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
|
2817 ;; Emerge as the default for this argument. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2818 (and emerge-default-last-directories |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2819 alternative-default-dir) |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
2820 default-file (and must-match 'confirm))) |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2821 (t |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2822 (read-file-name (concat prompt ": ") |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2823 ;; 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
|
2824 ;; 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
|
2825 ;; Emerge as the default for this argument. |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2826 (and emerge-default-last-directories |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
2827 alternative-default-dir) |
10179
970e59851fc5
(emerge-read-file-name): New arg must-match.
Richard M. Stallman <rms@gnu.org>
parents:
9861
diff
changeset
|
2828 nil (and must-match 'confirm))))) |
583 | 2829 |
2830 ;; Revise the mode line to display which difference we have selected | |
2831 | |
2832 (defun emerge-refresh-mode-line () | |
2833 (setq mode-line-buffer-identification | |
2834 (list (format "Emerge: %%b diff %d of %d%s" | |
2835 (1+ emerge-current-difference) | |
2836 emerge-number-of-differences | |
2837 (if (and (>= emerge-current-difference 0) | |
2838 (< emerge-current-difference | |
2839 emerge-number-of-differences)) | |
2840 (cdr (assq (aref (aref emerge-difference-list | |
2841 emerge-current-difference) | |
2842 6) | |
2843 '((A . " - A") | |
2844 (B . " - B") | |
2845 (prefer-A . " - A*") | |
2846 (prefer-B . " - B*") | |
2847 (combined . " - comb")))) | |
2848 "")))) | |
11564
26d4ff74d4ab
(emerge-fast-mode, emerge-edit-mode): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
10179
diff
changeset
|
2849 (force-mode-line-update)) |
583 | 2850 |
2851 ;; compare two regions in two buffers for containing the same text | |
2852 (defun emerge-compare-buffers (buffer-x x-begin x-end buffer-y y-begin y-end) | |
2853 ;; first check that the two regions are the same length | |
2854 (if (not (and (= (- x-end x-begin) (- y-end y-begin)))) | |
2855 nil | |
2856 (catch 'exit | |
2857 (while (< x-begin x-end) | |
2858 ;; bite off and compare no more than 1000 characters at a time | |
2859 (let* ((compare-length (min (- x-end x-begin) 1000)) | |
2860 (x-string (emerge-eval-in-buffer | |
2861 buffer-x | |
2862 (buffer-substring x-begin | |
2863 (+ x-begin compare-length)))) | |
2864 (y-string (emerge-eval-in-buffer | |
2865 buffer-y | |
2866 (buffer-substring y-begin | |
2867 (+ y-begin compare-length))))) | |
2868 (if (not (string-equal x-string y-string)) | |
2869 (throw 'exit nil) | |
2870 (setq x-begin (+ x-begin compare-length)) | |
2871 (setq y-begin (+ y-begin compare-length))))) | |
2872 t))) | |
2873 | |
2874 ;; Construct a unique buffer name. | |
2875 ;; The first one tried is prefixsuffix, then prefix<2>suffix, | |
2876 ;; prefix<3>suffix, etc. | |
2877 (defun emerge-unique-buffer-name (prefix suffix) | |
2878 (if (null (get-buffer (concat prefix suffix))) | |
2879 (concat prefix suffix) | |
2880 (let ((n 2)) | |
2881 (while (get-buffer (format "%s<%d>%s" prefix n suffix)) | |
2882 (setq n (1+ n))) | |
2883 (format "%s<%d>%s" prefix n suffix)))) | |
2884 | |
2885 ;; Verify that we have a difference selected. | |
2886 (defun emerge-validate-difference () | |
2887 (if (not (and (>= emerge-current-difference 0) | |
2888 (< emerge-current-difference emerge-number-of-differences))) | |
2889 (error "No difference selected"))) | |
2890 | |
2891 ;;; Functions for saving and restoring a batch of variables | |
2892 | |
2893 ;; These functions save (get the values of) and restore (set the values of) | |
2894 ;; a list of variables. The argument is a list of symbols (the names of | |
2895 ;; the variables). A list element can also be a list of two functions, | |
2896 ;; the first of which (when called with no arguments) gets the value, and | |
14040 | 2897 ;; the second (when called with a value as an argument) sets the value. |
583 | 2898 ;; A "function" is anything that funcall can handle as an argument. |
2899 | |
2900 (defun emerge-save-variables (vars) | |
2901 (mapcar (function (lambda (v) (if (symbolp v) | |
2902 (symbol-value v) | |
2903 (funcall (car v))))) | |
2904 vars)) | |
2905 | |
2906 (defun emerge-restore-variables (vars values) | |
2907 (while vars | |
2908 (let ((var (car vars)) | |
2909 (value (car values))) | |
2910 (if (symbolp var) | |
2911 (set var value) | |
2912 (funcall (car (cdr var)) value))) | |
2913 (setq vars (cdr vars)) | |
2914 (setq values (cdr values)))) | |
2915 | |
2916 ;; Make a temporary file that only we have access to. | |
2917 ;; PREFIX is appended to emerge-temp-file-prefix to make the filename prefix. | |
2918 (defun emerge-make-temp-file (prefix) | |
2919 (let ((f (make-temp-name (concat emerge-temp-file-prefix prefix)))) | |
2920 ;; create the file | |
2921 (write-region (point-min) (point-min) f nil 'no-message) | |
2922 (set-file-modes f emerge-temp-file-mode) | |
2923 f)) | |
2924 | |
2925 ;;; Functions that query the user before he can write out the current buffer. | |
2926 | |
2927 (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
|
2928 "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
|
2929 If answer is yes, call `write-file' to do so. See `emerge-query-and-call' |
583 | 2930 for details of the querying process." |
2931 (interactive) | |
2932 (emerge-query-and-call 'write-file)) | |
2933 | |
2934 (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
|
2935 "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
|
2936 If answer is yes, call `save-buffer' to do so. See `emerge-query-and-call' |
583 | 2937 for details of the querying process." |
2938 (interactive) | |
2939 (emerge-query-and-call 'save-buffer)) | |
2940 | |
2941 (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
|
2942 "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
|
2943 If answer is yes, call COMMAND interactively. During the call, the flags |
583 | 2944 around the current difference are removed." |
2945 (if (yes-or-no-p "Do you really write to write out this unfinished merge? ") | |
2946 ;; He really wants to do it -- unselect the difference for the duration | |
2947 (progn | |
2948 (if (and (>= emerge-current-difference 0) | |
2949 (< emerge-current-difference emerge-number-of-differences)) | |
2950 (emerge-unselect-difference emerge-current-difference)) | |
2951 ;; call-interactively takes the value of current-prefix-arg as the | |
2952 ;; prefix argument value to be passed to the command. Thus, we have | |
2953 ;; to do nothing special to make sure the prefix argument is | |
2954 ;; transmitted to the command. | |
2955 (call-interactively command) | |
2956 (if (and (>= emerge-current-difference 0) | |
2957 (< emerge-current-difference emerge-number-of-differences)) | |
2958 (progn | |
2959 (emerge-select-difference emerge-current-difference) | |
2960 (emerge-recenter)))) | |
2961 ;; He's being smart and not doing it | |
2962 (message "Not written"))) | |
2963 | |
2964 ;; Make sure the current buffer (for a file) has the same contents as the | |
2965 ;; file on disk, and attempt to remedy the situation if not. | |
2966 ;; Signal an error if we can't make them the same, or the user doesn't want | |
2967 ;; to do what is necessary to make them the same. | |
2968 (defun emerge-verify-file-buffer () | |
2969 ;; First check if the file has been modified since the buffer visited it. | |
2970 (if (verify-visited-file-modtime (current-buffer)) | |
2971 (if (buffer-modified-p) | |
2972 ;; If buffer is not obsolete and is modified, offer to save | |
2973 (if (yes-or-no-p (format "Save file %s? " buffer-file-name)) | |
2974 (save-buffer) | |
2975 (error "Buffer out of sync for file %s" buffer-file-name)) | |
2976 ;; If buffer is not obsolete and is not modified, do nothing | |
2977 nil) | |
2978 (if (buffer-modified-p) | |
2979 ;; If buffer is obsolete and is modified, give error | |
2980 (error "Buffer out of sync for file %s" buffer-file-name) | |
2981 ;; If buffer is obsolete and is not modified, offer to revert | |
2982 (if (yes-or-no-p (format "Revert file %s? " buffer-file-name)) | |
2983 (revert-buffer t t) | |
2984 (error "Buffer out of sync for file %s" buffer-file-name))))) | |
2985 | |
2986 ;; Utilities that might have value outside of Emerge. | |
2987 | |
2988 ;; Set up the mode in the current buffer to duplicate the mode in another | |
2989 ;; buffer. | |
2990 (defun emerge-copy-modes (buffer) | |
2991 ;; Set the major mode | |
2992 (funcall (emerge-eval-in-buffer buffer major-mode))) | |
2993 | |
2994 ;; Define a key, even if a prefix of it is defined | |
2995 (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
|
2996 "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
|
2997 If some prefix of KEY has a non-prefix definition, it is redefined." |
583 | 2998 ;; Find out if a prefix of key is defined |
2999 (let ((v (lookup-key keymap key))) | |
3000 ;; If so, undefine it | |
3001 (if (integerp v) | |
3002 (define-key keymap (substring key 0 v) nil))) | |
3003 ;; Now define the key | |
3004 (define-key keymap key definition)) | |
3005 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3006 ;;;;; 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
|
3007 ;;;;; as the major mode |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3008 ;;(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
|
3009 ;; "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
|
3010 ;;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
|
3011 ;;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
|
3012 ;;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
|
3013 ;;\(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
|
3014 ;;describes the minor mode." |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3015 ;; (interactive) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3016 ;; (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
|
3017 ;; (princ mode-name) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3018 ;; (princ " Mode:\n") |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3019 ;; (princ (documentation major-mode)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3020 ;; (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
|
3021 ;; (locals (buffer-local-variables))) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3022 ;; (while minor-modes |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3023 ;; (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
|
3024 ;; (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
|
3025 ;; (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
|
3026 ;; ;; 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
|
3027 ;; ;; 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
|
3028 ;; ;; definition. |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3029 ;; (if (and local-binding |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3030 ;; (cdr local-binding) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3031 ;; (fboundp minor-mode)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3032 ;; (progn |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3033 ;; (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
|
3034 ;; minor-mode indicator)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3035 ;; (princ (documentation minor-mode))))) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3036 ;; (setq minor-modes (cdr minor-modes)))) |
9861
7a43916ca395
(emerge-file-names): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9636
diff
changeset
|
3037 ;; (save-excursion |
7a43916ca395
(emerge-file-names): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9636
diff
changeset
|
3038 ;; (set-buffer standard-output) |
7a43916ca395
(emerge-file-names): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents:
9636
diff
changeset
|
3039 ;; (help-mode)) |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3040 ;; (print-help-return-message))) |
583 | 3041 |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3042 ;; 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
|
3043 ;;;; 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
|
3044 ;;(fset 'defining-kbd-macro (symbol-function 'start-kbd-macro)) |
583 | 3045 |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3046 ;; 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
|
3047 ;;;; 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
|
3048 ;;(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
|
3049 ;; "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
|
3050 ;;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
|
3051 ;;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
|
3052 ;;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
|
3053 ;; ;; 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
|
3054 ;; (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
|
3055 ;; (while maps |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3056 ;; (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
|
3057 ;; (map (cdr (car maps)))) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3058 ;; ;; examine a keymap |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3059 ;; (if (arrayp map) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3060 ;; ;; array keymap |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3061 ;; (let ((len (length map)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3062 ;; (i 0)) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3063 ;; (while (< i len) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3064 ;; (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
|
3065 ;; ;; set the shadowing definition |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3066 ;; (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
|
3067 ;; (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
|
3068 ;; (setq i (1+ i)))) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3069 ;; ;; sparse keymap |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3070 ;; (while map |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3071 ;; (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
|
3072 ;; ;; set the shadowing definition |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3073 ;; (let ((key |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3074 ;; (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
|
3075 ;; (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
|
3076 ;; (setq map (cdr map))))) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3077 ;; (setq maps (cdr maps))))) |
583 | 3078 |
3079 ;; Define a key if it (or a prefix) is not already defined in the map. | |
3080 (defun emerge-define-key-if-possible (keymap key definition) | |
3081 ;; look up the present definition of the key | |
3082 (let ((present (lookup-key keymap key))) | |
3083 (if (integerp present) | |
3084 ;; if it is "too long", look up the valid prefix | |
3085 (if (not (lookup-key keymap (substring key 0 present))) | |
3086 ;; if the prefix isn't defined, define it | |
3087 (define-key keymap key definition)) | |
3088 ;; if there is no present definition, define it | |
3089 (if (not present) | |
3090 (define-key keymap key definition))))) | |
3091 | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3092 ;; 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
|
3093 ;;(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
|
3094 ;; "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
|
3095 ;;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
|
3096 ;;\(`copy-keymap' will suffice.)" |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3097 ;; ;; 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
|
3098 ;; (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
|
3099 ;; (while maps |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3100 ;; ;; Substitute in this keymap |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3101 ;; (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
|
3102 ;; (setq maps (cdr maps))))) |
583 | 3103 |
3104 ;; Show the name of the file in the buffer. | |
3105 (defun emerge-show-file-name () | |
3106 "Displays the name of the file loaded into the current buffer. | |
3107 If the name won't fit on one line, the minibuffer is expanded to hold it, | |
3108 and the command waits for a keystroke from the user. If the keystroke is | |
3109 SPC, it is ignored; if it is anything else, it is processed as a command." | |
3110 (interactive) | |
3111 (let ((name (buffer-file-name))) | |
3112 (or name | |
3113 (setq name "Buffer has no file name.")) | |
3114 (save-window-excursion | |
3115 (select-window (minibuffer-window)) | |
3116 (erase-buffer) | |
3117 (insert name) | |
3118 (if (not (pos-visible-in-window-p)) | |
3119 (let ((echo-keystrokes 0)) | |
3120 (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
|
3121 (> (1- (screen-height)) (window-height))) |
583 | 3122 (enlarge-window 1)) |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3123 (let ((c (read-event))) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3124 (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
|
3125 (setq unread-command-events (list c))))))))) |
583 | 3126 |
3127 ;; Improved auto-save file names. | |
3128 ;; This function fixes many problems with the standard auto-save file names: | |
3129 ;; Auto-save files for non-file buffers get put in the default directory | |
3130 ;; for the buffer, whether that makes sense or not. | |
3131 ;; Auto-save files for file buffers get put in the directory of the file, | |
3132 ;; regardless of whether we can write into it or not. | |
3133 ;; Auto-save files for non-file buffers don't use the process id, so if a | |
3134 ;; user runs more than on Emacs, they can make auto-save files that overwrite | |
3135 ;; each other. | |
3136 ;; To use this function, do: | |
3137 ;; (fset 'make-auto-save-file-name | |
3138 ;; (symbol-function 'emerge-make-auto-save-file-name)) | |
3139 (defun emerge-make-auto-save-file-name () | |
3140 "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
|
3141 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
|
3142 that is checked before calling this function. |
583 | 3143 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
|
3144 See also `auto-save-file-name-p'." |
583 | 3145 (if buffer-file-name |
3146 ;; if buffer has a file, try the format <file directory>/#<file name># | |
3147 (let ((f (concat (file-name-directory buffer-file-name) | |
3148 "#" | |
3149 (file-name-nondirectory buffer-file-name) | |
3150 "#"))) | |
3151 (if (file-writable-p f) | |
3152 ;; the file is writable, so use it | |
3153 f | |
3154 ;; the file isn't writable, so use the format | |
3155 ;; ~/#&<file name>&<hash of directory># | |
3156 (concat (getenv "HOME") | |
3157 "/#&" | |
3158 (file-name-nondirectory buffer-file-name) | |
3159 "&" | |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3160 (emerge-hash-string-into-string |
583 | 3161 (file-name-directory buffer-file-name)) |
3162 "#"))) | |
3163 ;; if buffer has no file, use the format ~/#%<buffer name>%<process id># | |
3164 (expand-file-name (concat (getenv "HOME") | |
3165 "/#%" | |
3166 ;; 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
|
3167 (emerge-unslashify-name (buffer-name)) |
583 | 3168 "%" |
3169 (make-temp-name "") | |
3170 "#")))) | |
3171 | |
3172 ;; Hash a string into five characters more-or-less suitable for use in a file | |
3173 ;; 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
|
3174 (defun emerge-hash-string-into-string (s) |
583 | 3175 (let ((bins (vector 0 0 0 0 0)) |
3176 (i 0)) | |
3177 (while (< i (length s)) | |
3178 (aset bins (% i 5) (% (+ (* (aref bins (% i 5)) 35) | |
3179 (aref s i)) | |
3180 65536)) | |
3181 (setq i (1+ i))) | |
3182 (mapconcat (function (lambda (b) | |
3183 (setq b (+ (% b 93) ?!)) | |
3184 (if (>= b ?/) | |
3185 (setq b (1+ b))) | |
3186 (char-to-string b))) | |
3187 bins ""))) | |
3188 | |
3189 ;; Quote any /s in a string by replacing them with \!. | |
3190 ;; 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
|
3191 (defun emerge-unslashify-name (s) |
583 | 3192 (let ((limit 0)) |
3193 (while (string-match "[/\\]" s limit) | |
3194 (setq s (concat (substring s 0 (match-beginning 0)) | |
3195 (if (string= (substring s (match-beginning 0) | |
3196 (match-end 0)) | |
3197 "/") | |
3198 "\\!" | |
3199 "\\\\") | |
3200 (substring s (match-end 0)))) | |
3201 (setq limit (1+ (match-end 0))))) | |
3202 s) | |
3203 | |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3204 ;; 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
|
3205 ;; a diff/diff3 command. |
20597 | 3206 (defcustom 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
|
3207 "Characters that must be quoted with \\ when used in a shell command line. |
20597 | 3208 More precisely, a [...] regexp to match any one such character." |
3209 :type 'regexp | |
3210 :group 'emerge) | |
583 | 3211 |
2770
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3212 ;; 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
|
3213 (defun emerge-protect-metachars (s) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3214 (let ((limit 0)) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3215 (while (string-match emerge-metachars s limit) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3216 (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
|
3217 "\\" |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3218 (substring s (match-beginning 0)))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3219 (setq limit (1+ (match-end 0))))) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3220 s) |
6574a888b539
Install DRW's version 5.
Richard M. Stallman <rms@gnu.org>
parents:
2496
diff
changeset
|
3221 |
2771
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3222 (provide 'emerge) |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3223 |
2d2b77186415
(emerge-count-matches-string): Renamed from count-matches-string.
Richard M. Stallman <rms@gnu.org>
parents:
2770
diff
changeset
|
3224 ;;; emerge.el ends here |