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