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