64 |
,@forms) |
,@forms) |
65 |
(set-buffer StartBuffer)))) |
(set-buffer StartBuffer)))) |
66 |
|
|
67 |
(defmacro emerge-defvar-local (var value doc) |
(defmacro emerge-defvar-local (var value doc) |
68 |
"Defines SYMBOL as an advertised variable. |
"Defines SYMBOL as an advertised variable. |
69 |
Performs a defvar, then executes `make-variable-buffer-local' on |
Performs a defvar, then executes `make-variable-buffer-local' on |
70 |
the variable. Also sets the `preserved' property, so that |
the variable. Also sets the `preserved' property, so that |
71 |
`kill-all-local-variables' (called by major-mode setting commands) |
`kill-all-local-variables' (called by major-mode setting commands) |
72 |
won't destroy Emerge control variables." |
won't destroy Emerge control variables." |
73 |
`(progn |
`(progn |
74 |
(defvar ,var ,value ,doc) |
(defvar ,var ,value ,doc) |
127 |
;; to be provided (emerge-diff-options). The order in which the file names |
;; to be provided (emerge-diff-options). The order in which the file names |
128 |
;; are given is fixed. |
;; are given is fixed. |
129 |
;; The file names are always expanded (see expand-file-name) before being |
;; The file names are always expanded (see expand-file-name) before being |
130 |
;; passed to diff, thus they need not be invoked under a shell that |
;; passed to diff, thus they need not be invoked under a shell that |
131 |
;; understands `~'. |
;; understands `~'. |
132 |
;; The code which processes the diff/diff3 output depends on all the |
;; The code which processes the diff/diff3 output depends on all the |
133 |
;; finicky details of their output, including the somewhat strange |
;; finicky details of their output, including the somewhat strange |
400 |
;; Allow emerge-fast-keymap to be referenced indirectly |
;; Allow emerge-fast-keymap to be referenced indirectly |
401 |
(fset 'emerge-fast-keymap emerge-fast-keymap) |
(fset 'emerge-fast-keymap emerge-fast-keymap) |
402 |
;; Suppress write-file and save-buffer |
;; Suppress write-file and save-buffer |
403 |
(substitute-key-definition 'write-file 'emerge-query-write-file |
(define-key emerge-fast-keymap [remap write-file] 'emerge-query-write-file) |
404 |
emerge-fast-keymap (current-global-map)) |
(define-key emerge-fast-keymap [remap save-buffer] 'emerge-query-save-buffer) |
|
(substitute-key-definition 'save-buffer 'emerge-query-save-buffer |
|
|
emerge-fast-keymap (current-global-map)) |
|
405 |
|
|
406 |
(define-key emerge-basic-keymap [menu-bar] (make-sparse-keymap)) |
(define-key emerge-basic-keymap [menu-bar] (make-sparse-keymap)) |
407 |
|
|
578 |
(if output-file |
(if output-file |
579 |
(setq emerge-last-dir-output (file-name-directory output-file))) |
(setq emerge-last-dir-output (file-name-directory output-file))) |
580 |
;; Make sure the entire files are seen, and they reflect what is on disk |
;; Make sure the entire files are seen, and they reflect what is on disk |
581 |
(emerge-eval-in-buffer |
(emerge-eval-in-buffer |
582 |
buffer-A |
buffer-A |
583 |
(widen) |
(widen) |
584 |
(let ((temp (file-local-copy file-A))) |
(let ((temp (file-local-copy file-A))) |
842 |
;; if the A and B files are the same, ignore the difference |
;; if the A and B files are the same, ignore the difference |
843 |
(if (not (string-equal agreement "2")) |
(if (not (string-equal agreement "2")) |
844 |
(setq list |
(setq list |
845 |
(cons |
(cons |
846 |
(let (group-1 group-3 pos) |
(let (group-1 group-3 pos) |
847 |
(setq pos (point)) |
(setq pos (point)) |
848 |
(setq group-1 (emerge-get-diff3-group "1")) |
(setq group-1 (emerge-get-diff3-group "1")) |
1022 |
(emerge-files-with-ancestor-internal |
(emerge-files-with-ancestor-internal |
1023 |
file-a file-b file-anc nil |
file-a file-b file-anc nil |
1024 |
(list `(lambda () (emerge-command-exit ,file-out)))))) |
(list `(lambda () (emerge-command-exit ,file-out)))))) |
1025 |
|
|
1026 |
(defun emerge-command-exit (file-out) |
(defun emerge-command-exit (file-out) |
1027 |
(emerge-write-and-delete file-out) |
(emerge-write-and-delete file-out) |
1028 |
(kill-emacs (if emerge-prefix-argument 1 0))) |
(kill-emacs (if emerge-prefix-argument 1 0))) |
1270 |
(emerge-files (not (not file-out)) file-A file-B file-out |
(emerge-files (not (not file-out)) file-A file-B file-out |
1271 |
nil |
nil |
1272 |
;; When done, return to this buffer. |
;; When done, return to this buffer. |
1273 |
(list |
(list |
1274 |
`(lambda () |
`(lambda () |
1275 |
(switch-to-buffer ,(current-buffer)) |
(switch-to-buffer ,(current-buffer)) |
1276 |
(message "Merge done."))))) |
(message "Merge done."))))) |
1294 |
|
|
1295 |
;;;###autoload |
;;;###autoload |
1296 |
(defun emerge-merge-directories (a-dir b-dir ancestor-dir output-dir) |
(defun emerge-merge-directories (a-dir b-dir ancestor-dir output-dir) |
1297 |
(interactive |
(interactive |
1298 |
(list |
(list |
1299 |
(read-file-name "A directory: " nil nil 'confirm) |
(read-file-name "A directory: " nil nil 'confirm) |
1300 |
(read-file-name "B directory: " nil nil 'confirm) |
(read-file-name "B directory: " nil nil 'confirm) |
1430 |
(substitute-key-definition 'save-buffer |
(substitute-key-definition 'save-buffer |
1431 |
'emerge-query-save-buffer |
'emerge-query-save-buffer |
1432 |
emerge-edit-keymap) |
emerge-edit-keymap) |
1433 |
(substitute-key-definition 'write-file 'emerge-query-write-file |
(define-key emerge-edit-keymap [remap write-file] 'emerge-query-write-file) |
1434 |
emerge-edit-keymap (current-global-map)) |
(define-key emerge-edit-keymap [remap save-buffer] 'emerge-query-save-buffer) |
|
(substitute-key-definition 'save-buffer 'emerge-query-save-buffer |
|
|
emerge-edit-keymap (current-global-map)) |
|
1435 |
(use-local-map emerge-fast-keymap) |
(use-local-map emerge-fast-keymap) |
1436 |
(setq emerge-edit-mode nil) |
(setq emerge-edit-mode nil) |
1437 |
(setq emerge-fast-mode t)) |
(setq emerge-fast-mode t)) |
1539 |
;; fast access |
;; fast access |
1540 |
(setq emerge-difference-list (apply 'vector (nreverse marker-list))))) |
(setq emerge-difference-list (apply 'vector (nreverse marker-list))))) |
1541 |
|
|
1542 |
;; If we have an ancestor, select all B variants that we prefer |
;; If we have an ancestor, select all B variants that we prefer |
1543 |
(defun emerge-select-prefer-Bs () |
(defun emerge-select-prefer-Bs () |
1544 |
(let ((n 0)) |
(let ((n 0)) |
1545 |
(while (< n emerge-number-of-differences) |
(while (< n emerge-number-of-differences) |
1663 |
`C-u -' alone as argument scrolls half the height of the merge window." |
`C-u -' alone as argument scrolls half the height of the merge window." |
1664 |
(interactive "P") |
(interactive "P") |
1665 |
(emerge-operate-on-windows |
(emerge-operate-on-windows |
1666 |
'scroll-up |
'scroll-up |
1667 |
;; calculate argument to scroll-up |
;; calculate argument to scroll-up |
1668 |
;; if there is an explicit argument |
;; if there is an explicit argument |
1669 |
(if (and arg (not (equal arg '-))) |
(if (and arg (not (equal arg '-))) |
1906 |
(run-hooks 'emerge-quit-hook))) |
(run-hooks 'emerge-quit-hook))) |
1907 |
|
|
1908 |
(defun emerge-select-A (&optional force) |
(defun emerge-select-A (&optional force) |
1909 |
"Select the A variant of this difference. |
"Select the A variant of this difference. |
1910 |
Refuses to function if this difference has been edited, i.e., if it |
Refuses to function if this difference has been edited, i.e., if it |
1911 |
is neither the A nor the B variant. |
is neither the A nor the B variant. |
1912 |
A prefix argument forces the variant to be selected |
A prefix argument forces the variant to be selected |
2579 |
(if (= c ?%) |
(if (= c ?%) |
2580 |
(progn |
(progn |
2581 |
(setq i (1+ i)) |
(setq i (1+ i)) |
2582 |
(setq c |
(setq c |
2583 |
(condition-case nil |
(condition-case nil |
2584 |
(aref template i) |
(aref template i) |
2585 |
(error ?%))) |
(error ?%))) |
2586 |
(cond ((= c ?a) |
(cond ((= c ?a) |
2587 |
(insert-buffer-substring emerge-A-buffer A-begin A-end)) |
(insert-buffer-substring emerge-A-buffer A-begin A-end)) |
2588 |
((= c ?b) |
((= c ?b) |
2589 |
(insert-buffer-substring emerge-B-buffer B-begin B-end)) |
(insert-buffer-substring emerge-B-buffer B-begin B-end)) |
2590 |
((= c ?%) |
((= c ?%) |
2591 |
(insert ?%)) |
(insert ?%)) |
2592 |
(t |
(t |
2593 |
(insert c)))) |
(insert c)))) |
2848 |
(while (< x-begin x-end) |
(while (< x-begin x-end) |
2849 |
;; bite off and compare no more than 1000 characters at a time |
;; bite off and compare no more than 1000 characters at a time |
2850 |
(let* ((compare-length (min (- x-end x-begin) 1000)) |
(let* ((compare-length (min (- x-end x-begin) 1000)) |
2851 |
(x-string (emerge-eval-in-buffer |
(x-string (emerge-eval-in-buffer |
2852 |
buffer-x |
buffer-x |
2853 |
(buffer-substring x-begin |
(buffer-substring x-begin |
2854 |
(+ x-begin compare-length)))) |
(+ x-begin compare-length)))) |
2863 |
t))) |
t))) |
2864 |
|
|
2865 |
;; Construct a unique buffer name. |
;; Construct a unique buffer name. |
2866 |
;; The first one tried is prefixsuffix, then prefix<2>suffix, |
;; The first one tried is prefixsuffix, then prefix<2>suffix, |
2867 |
;; prefix<3>suffix, etc. |
;; prefix<3>suffix, etc. |
2868 |
(defun emerge-unique-buffer-name (prefix suffix) |
(defun emerge-unique-buffer-name (prefix suffix) |
2869 |
(if (null (get-buffer (concat prefix suffix))) |
(if (null (get-buffer (concat prefix suffix))) |
3106 |
(setq name "Buffer has no file name.")) |
(setq name "Buffer has no file name.")) |
3107 |
(save-window-excursion |
(save-window-excursion |
3108 |
(select-window (minibuffer-window)) |
(select-window (minibuffer-window)) |
3109 |
(erase-buffer) |
(unwind-protect |
3110 |
(insert name) |
(progn |
3111 |
(if (not (pos-visible-in-window-p)) |
(erase-buffer) |
3112 |
(let ((echo-keystrokes 0)) |
(insert name) |
3113 |
(while (and (not (pos-visible-in-window-p)) |
(if (not (pos-visible-in-window-p)) |
3114 |
(> (1- (frame-height)) (window-height))) |
(while (and (not (pos-visible-in-window-p)) |
3115 |
(enlarge-window 1)) |
(> (1- (frame-height)) (window-height))) |
3116 |
(let ((c (read-event))) |
(enlarge-window 1))) |
3117 |
|
(let* ((echo-keystrokes 0) |
3118 |
|
(c (read-event))) |
3119 |
(if (not (eq c 32)) |
(if (not (eq c 32)) |
3120 |
(setq unread-command-events (list c))))))))) |
(setq unread-command-events (list c))))) |
3121 |
|
(erase-buffer))))) |
3122 |
|
|
3123 |
;; Improved auto-save file names. |
;; Improved auto-save gfile names. |
3124 |
;; This function fixes many problems with the standard auto-save file names: |
;; This function fixes many problems with the standard auto-save file names: |
3125 |
;; Auto-save files for non-file buffers get put in the default directory |
;; Auto-save files for non-file buffers get put in the default directory |
3126 |
;; for the buffer, whether that makes sense or not. |
;; for the buffer, whether that makes sense or not. |