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