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