1995-03-16 22:34:51 +00:00
|
|
|
|
;;; ediff-util.el --- the core commands and utilities of ediff
|
1996-01-14 07:34:30 +00:00
|
|
|
|
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
|
;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation, Inc.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Michael Kifer <kifer@cs.sunysb.edu>
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
;; any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
1996-01-14 07:34:30 +00:00
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
|
|
|
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
;; Boston, MA 02111-1307, USA.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
2001-07-16 07:46:48 +00:00
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;;; Code:
|
1997-05-31 01:10:39 +00:00
|
|
|
|
|
|
|
|
|
(provide 'ediff-util)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
;; Compiler pacifier
|
|
|
|
|
(defvar ediff-patch-diagnostics)
|
|
|
|
|
(defvar ediff-patchbufer)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(defvar ediff-use-toolbar-p)
|
|
|
|
|
(defvar ediff-toolbar-height)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(defvar ediff-toolbar)
|
|
|
|
|
(defvar ediff-toolbar-3way)
|
|
|
|
|
(defvar bottom-toolbar)
|
|
|
|
|
(defvar bottom-toolbar-visible-p)
|
|
|
|
|
(defvar bottom-toolbar-height)
|
|
|
|
|
(defvar mark-active)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(defvar ediff-emacs-p)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
|
2001-12-24 05:50:31 +00:00
|
|
|
|
(defvar ediff-after-quit-hook-internal nil)
|
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(let ((load-path (cons (expand-file-name ".") load-path)))
|
|
|
|
|
(or (featurep 'ediff-init)
|
|
|
|
|
(load "ediff-init.el" nil nil 'nosuffix))
|
|
|
|
|
(or (featurep 'ediff-help)
|
|
|
|
|
(load "ediff-help.el" nil nil 'nosuffix))
|
|
|
|
|
(or (featurep 'ediff-mult)
|
|
|
|
|
(load "ediff-mult.el" nil nil 'nosuffix))
|
|
|
|
|
(or (featurep 'ediff-wind)
|
|
|
|
|
(load "ediff-wind.el" nil nil 'nosuffix))
|
|
|
|
|
(or (featurep 'ediff-diff)
|
|
|
|
|
(load "ediff-diff.el" nil nil 'nosuffix))
|
|
|
|
|
(or (featurep 'ediff-merg)
|
|
|
|
|
(load "ediff-merg.el" nil nil 'nosuffix))
|
|
|
|
|
(or (featurep 'ediff)
|
|
|
|
|
(load "ediff.el" nil nil 'nosuffix))
|
|
|
|
|
(or (featurep 'ediff-tbar)
|
1998-05-04 22:42:59 +00:00
|
|
|
|
ediff-emacs-p
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(load "ediff-tbar.el" 'noerror nil 'nosuffix))
|
|
|
|
|
))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; end pacifier
|
|
|
|
|
|
1998-05-04 22:42:59 +00:00
|
|
|
|
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(require 'ediff-init)
|
|
|
|
|
(require 'ediff-help)
|
|
|
|
|
(require 'ediff-mult)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(require 'ediff-wind)
|
|
|
|
|
(require 'ediff-diff)
|
|
|
|
|
(require 'ediff-merg)
|
1996-12-28 02:53:04 +00:00
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(if ediff-xemacs-p
|
1998-05-04 22:42:59 +00:00
|
|
|
|
(require 'ediff-tbar))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;;; Functions
|
|
|
|
|
|
|
|
|
|
(defun ediff-mode ()
|
1995-10-06 00:59:04 +00:00
|
|
|
|
"Ediff mode controls all operations in a single Ediff session.
|
|
|
|
|
This mode is entered through one of the following commands:
|
1995-03-16 22:34:51 +00:00
|
|
|
|
`ediff'
|
|
|
|
|
`ediff-files'
|
|
|
|
|
`ediff-buffers'
|
1996-06-22 01:54:34 +00:00
|
|
|
|
`ebuffers'
|
1995-03-16 22:34:51 +00:00
|
|
|
|
`ediff3'
|
|
|
|
|
`ediff-files3'
|
|
|
|
|
`ediff-buffers3'
|
1996-06-22 01:54:34 +00:00
|
|
|
|
`ebuffers3'
|
1995-03-16 22:34:51 +00:00
|
|
|
|
`ediff-merge'
|
|
|
|
|
`ediff-merge-files'
|
|
|
|
|
`ediff-merge-files-with-ancestor'
|
|
|
|
|
`ediff-merge-buffers'
|
|
|
|
|
`ediff-merge-buffers-with-ancestor'
|
|
|
|
|
`ediff-merge-revisions'
|
|
|
|
|
`ediff-merge-revisions-with-ancestor'
|
1995-06-05 23:43:51 +00:00
|
|
|
|
`ediff-windows-wordwise'
|
|
|
|
|
`ediff-windows-linewise'
|
|
|
|
|
`ediff-regions-wordwise'
|
|
|
|
|
`ediff-regions-linewise'
|
1995-03-16 22:34:51 +00:00
|
|
|
|
`epatch'
|
|
|
|
|
`ediff-patch-file'
|
|
|
|
|
`ediff-patch-buffer'
|
|
|
|
|
`epatch-buffer'
|
1997-07-17 19:37:07 +00:00
|
|
|
|
`erevision'
|
1995-03-16 22:34:51 +00:00
|
|
|
|
`ediff-revision'
|
|
|
|
|
|
|
|
|
|
Commands:
|
|
|
|
|
\\{ediff-mode-map}"
|
|
|
|
|
(kill-all-local-variables)
|
|
|
|
|
(setq major-mode 'ediff-mode)
|
|
|
|
|
(setq mode-name "Ediff")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-mode-hook))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Build keymaps
|
|
|
|
|
|
|
|
|
|
(ediff-defvar-local ediff-mode-map nil
|
|
|
|
|
"Local keymap used in Ediff mode.
|
|
|
|
|
This is local to each Ediff Control Panel, so they may vary from invocation
|
|
|
|
|
to invocation.")
|
|
|
|
|
|
|
|
|
|
;; Set up the keymap in the control buffer
|
|
|
|
|
(defun ediff-set-keys ()
|
|
|
|
|
"Set up Ediff keymap, if necessary."
|
|
|
|
|
(if (null ediff-mode-map)
|
|
|
|
|
(ediff-setup-keymap))
|
|
|
|
|
(use-local-map ediff-mode-map))
|
|
|
|
|
|
|
|
|
|
;; Reload Ediff keymap. For debugging only.
|
|
|
|
|
(defun ediff-reload-keymap ()
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq ediff-mode-map nil)
|
|
|
|
|
(ediff-set-keys))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-setup-keymap ()
|
|
|
|
|
"Set up the keymap used in the control buffer of Ediff."
|
|
|
|
|
(setq ediff-mode-map (make-sparse-keymap))
|
|
|
|
|
(suppress-keymap ediff-mode-map)
|
|
|
|
|
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(define-key ediff-mode-map
|
|
|
|
|
(if ediff-emacs-p [mouse-2] [button2]) 'ediff-help-for-quick-help)
|
|
|
|
|
(define-key ediff-mode-map "\C-m" 'ediff-help-for-quick-help)
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "p" 'ediff-previous-difference)
|
|
|
|
|
(define-key ediff-mode-map "\C-?" 'ediff-previous-difference)
|
|
|
|
|
(define-key ediff-mode-map [delete] 'ediff-previous-difference)
|
|
|
|
|
(define-key ediff-mode-map "\C-h" (if ediff-no-emacs-help-in-control-buffer
|
|
|
|
|
'ediff-previous-difference nil))
|
1997-09-06 04:16:05 +00:00
|
|
|
|
;; must come after C-h, or else C-h wipes out backspace's binding in XEmacs
|
|
|
|
|
(define-key ediff-mode-map [backspace] 'ediff-previous-difference)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "n" 'ediff-next-difference)
|
|
|
|
|
(define-key ediff-mode-map " " 'ediff-next-difference)
|
|
|
|
|
(define-key ediff-mode-map "j" 'ediff-jump-to-difference)
|
|
|
|
|
(define-key ediff-mode-map "g" nil)
|
|
|
|
|
(define-key ediff-mode-map "ga" 'ediff-jump-to-difference-at-point)
|
|
|
|
|
(define-key ediff-mode-map "gb" 'ediff-jump-to-difference-at-point)
|
|
|
|
|
(define-key ediff-mode-map "q" 'ediff-quit)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(define-key ediff-mode-map "D" 'ediff-show-diff-output)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "z" 'ediff-suspend)
|
|
|
|
|
(define-key ediff-mode-map "\C-l" 'ediff-recenter)
|
|
|
|
|
(define-key ediff-mode-map "|" 'ediff-toggle-split)
|
|
|
|
|
(define-key ediff-mode-map "h" 'ediff-toggle-hilit)
|
|
|
|
|
(or ediff-word-mode
|
|
|
|
|
(define-key ediff-mode-map "@" 'ediff-toggle-autorefine))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if ediff-narrow-job
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "%" 'ediff-toggle-narrow-region))
|
|
|
|
|
(define-key ediff-mode-map "~" 'ediff-swap-buffers)
|
|
|
|
|
(define-key ediff-mode-map "v" 'ediff-scroll-vertically)
|
|
|
|
|
(define-key ediff-mode-map "\C-v" 'ediff-scroll-vertically)
|
|
|
|
|
(define-key ediff-mode-map "^" 'ediff-scroll-vertically)
|
|
|
|
|
(define-key ediff-mode-map "\M-v" 'ediff-scroll-vertically)
|
|
|
|
|
(define-key ediff-mode-map "V" 'ediff-scroll-vertically)
|
|
|
|
|
(define-key ediff-mode-map "<" 'ediff-scroll-horizontally)
|
|
|
|
|
(define-key ediff-mode-map ">" 'ediff-scroll-horizontally)
|
|
|
|
|
(define-key ediff-mode-map "i" 'ediff-status-info)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(define-key ediff-mode-map "E" 'ediff-documentation)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "?" 'ediff-toggle-help)
|
|
|
|
|
(define-key ediff-mode-map "!" 'ediff-update-diffs)
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(define-key ediff-mode-map "M" 'ediff-show-current-session-meta-buffer)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(define-key ediff-mode-map "R" 'ediff-show-registry)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(or ediff-word-mode
|
|
|
|
|
(define-key ediff-mode-map "*" 'ediff-make-or-kill-fine-diffs))
|
|
|
|
|
(define-key ediff-mode-map "a" nil)
|
|
|
|
|
(define-key ediff-mode-map "b" nil)
|
|
|
|
|
(define-key ediff-mode-map "r" nil)
|
|
|
|
|
(cond (ediff-merge-job
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; Will barf if no ancestor
|
|
|
|
|
(define-key ediff-mode-map "/" 'ediff-show-ancestor)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; In merging, we allow only A->C and B->C copying.
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(define-key ediff-mode-map "a" 'ediff-copy-A-to-C)
|
|
|
|
|
(define-key ediff-mode-map "b" 'ediff-copy-B-to-C)
|
|
|
|
|
(define-key ediff-mode-map "r" 'ediff-restore-diff-in-merge-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "s" 'ediff-shrink-window-C)
|
|
|
|
|
(define-key ediff-mode-map "+" 'ediff-combine-diffs)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(define-key ediff-mode-map "$" nil)
|
|
|
|
|
(define-key ediff-mode-map "$$" 'ediff-toggle-show-clashes-only)
|
|
|
|
|
(define-key ediff-mode-map "$*" 'ediff-toggle-skip-changed-regions)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "&" 'ediff-re-merge))
|
|
|
|
|
(ediff-3way-comparison-job
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(define-key ediff-mode-map "ab" 'ediff-copy-A-to-B)
|
|
|
|
|
(define-key ediff-mode-map "ba" 'ediff-copy-B-to-A)
|
|
|
|
|
(define-key ediff-mode-map "ac" 'ediff-copy-A-to-C)
|
|
|
|
|
(define-key ediff-mode-map "bc" 'ediff-copy-B-to-C)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "c" nil)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(define-key ediff-mode-map "ca" 'ediff-copy-C-to-A)
|
|
|
|
|
(define-key ediff-mode-map "cb" 'ediff-copy-C-to-B)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "ra" 'ediff-restore-diff)
|
|
|
|
|
(define-key ediff-mode-map "rb" 'ediff-restore-diff)
|
|
|
|
|
(define-key ediff-mode-map "rc" 'ediff-restore-diff)
|
|
|
|
|
(define-key ediff-mode-map "C" 'ediff-toggle-read-only))
|
|
|
|
|
(t ; 2-way comparison
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(define-key ediff-mode-map "a" 'ediff-copy-A-to-B)
|
|
|
|
|
(define-key ediff-mode-map "b" 'ediff-copy-B-to-A)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(define-key ediff-mode-map "ra" 'ediff-restore-diff)
|
|
|
|
|
(define-key ediff-mode-map "rb" 'ediff-restore-diff))
|
|
|
|
|
) ; cond
|
|
|
|
|
(define-key ediff-mode-map "G" 'ediff-submit-report)
|
|
|
|
|
(define-key ediff-mode-map "#" nil)
|
|
|
|
|
(define-key ediff-mode-map "#h" 'ediff-toggle-regexp-match)
|
|
|
|
|
(define-key ediff-mode-map "#f" 'ediff-toggle-regexp-match)
|
|
|
|
|
(or ediff-word-mode
|
|
|
|
|
(define-key ediff-mode-map "##" 'ediff-toggle-skip-similar))
|
|
|
|
|
(define-key ediff-mode-map "o" nil)
|
|
|
|
|
(define-key ediff-mode-map "A" 'ediff-toggle-read-only)
|
|
|
|
|
(define-key ediff-mode-map "B" 'ediff-toggle-read-only)
|
|
|
|
|
(define-key ediff-mode-map "w" nil)
|
|
|
|
|
(define-key ediff-mode-map "wa" 'ediff-save-buffer)
|
|
|
|
|
(define-key ediff-mode-map "wb" 'ediff-save-buffer)
|
|
|
|
|
(define-key ediff-mode-map "wd" 'ediff-save-buffer)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(define-key ediff-mode-map "=" 'ediff-inferior-compare-regions)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(if (fboundp 'ediff-show-patch-diagnostics)
|
|
|
|
|
(define-key ediff-mode-map "P" 'ediff-show-patch-diagnostics))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(progn
|
|
|
|
|
(define-key ediff-mode-map "wc" 'ediff-save-buffer)
|
|
|
|
|
(define-key ediff-mode-map "gc" 'ediff-jump-to-difference-at-point)
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(define-key ediff-mode-map "m" 'ediff-toggle-wide-display)
|
|
|
|
|
|
|
|
|
|
;; Allow ediff-mode-map to be referenced indirectly
|
|
|
|
|
(fset 'ediff-mode-map ediff-mode-map)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-keymap-setup-hook))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Setup functions
|
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
;; Common startup entry for all Ediff functions It now returns control buffer
|
|
|
|
|
;; so other functions can do post-processing SETUP-PARAMETERS is a list of the
|
|
|
|
|
;; form ((param .val) (param . val)...) This serves a similar purpose to
|
|
|
|
|
;; STARTUP-HOOKS, but these parameters are set in the new control buffer right
|
|
|
|
|
;; after this buf is created and before any windows are set and such.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(defun ediff-setup (buffer-A file-A buffer-B file-B buffer-C file-C
|
1997-11-01 01:46:51 +00:00
|
|
|
|
startup-hooks setup-parameters
|
|
|
|
|
&optional merge-buffer-file)
|
2000-10-29 04:56:45 +00:00
|
|
|
|
(run-hooks 'ediff-before-setup-hook)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
;; ediff-convert-standard-filename puts file names in the form appropriate
|
|
|
|
|
;; for the OS at hand.
|
|
|
|
|
(setq file-A (ediff-convert-standard-filename (expand-file-name file-A)))
|
|
|
|
|
(setq file-B (ediff-convert-standard-filename (expand-file-name file-B)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (stringp file-C)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(setq file-C
|
|
|
|
|
(ediff-convert-standard-filename (expand-file-name file-C))))
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(if (stringp merge-buffer-file)
|
|
|
|
|
(progn
|
|
|
|
|
(setq merge-buffer-file
|
|
|
|
|
(ediff-convert-standard-filename
|
|
|
|
|
(expand-file-name merge-buffer-file)))
|
|
|
|
|
;; check the directory exists
|
|
|
|
|
(or (file-exists-p (file-name-directory merge-buffer-file))
|
2001-07-16 07:46:48 +00:00
|
|
|
|
(error "Directory %s given as place to save the merge doesn't exist"
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(abbreviate-file-name
|
|
|
|
|
(file-name-directory merge-buffer-file))))
|
|
|
|
|
(if (and (file-exists-p merge-buffer-file)
|
|
|
|
|
(file-directory-p merge-buffer-file))
|
|
|
|
|
(error "The merge buffer file %s must not be a directory"
|
|
|
|
|
(abbreviate-file-name merge-buffer-file)))
|
|
|
|
|
))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let* ((control-buffer-name
|
|
|
|
|
(ediff-unique-buffer-name "*Ediff Control Panel" "*"))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(control-buffer (ediff-with-current-buffer buffer-A
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(get-buffer-create control-buffer-name))))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer control-buffer
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-mode)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
|
|
|
|
|
(make-local-variable 'ediff-use-long-help-message)
|
|
|
|
|
(make-local-variable 'ediff-prefer-iconified-control-frame)
|
|
|
|
|
(make-local-variable 'ediff-split-window-function)
|
|
|
|
|
(make-local-variable 'ediff-default-variant)
|
|
|
|
|
(make-local-variable 'ediff-merge-window-share)
|
|
|
|
|
(make-local-variable 'ediff-window-setup-function)
|
|
|
|
|
(make-local-variable 'ediff-keep-variants)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; unwrap set up parameters passed as argument
|
|
|
|
|
(while setup-parameters
|
|
|
|
|
(set (car (car setup-parameters)) (cdr (car setup-parameters)))
|
|
|
|
|
(setq setup-parameters (cdr setup-parameters)))
|
|
|
|
|
|
|
|
|
|
;; set variables classifying the current ediff job
|
1997-05-31 01:10:39 +00:00
|
|
|
|
;; must come AFTER setup-parameters
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq ediff-3way-comparison-job (ediff-3way-comparison-job)
|
|
|
|
|
ediff-merge-job (ediff-merge-job)
|
|
|
|
|
ediff-merge-with-ancestor-job (ediff-merge-with-ancestor-job)
|
|
|
|
|
ediff-3way-job (ediff-3way-job)
|
|
|
|
|
ediff-diff3-job (ediff-diff3-job)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
ediff-narrow-job (ediff-narrow-job)
|
|
|
|
|
ediff-windows-job (ediff-windows-job)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
ediff-word-mode-job (ediff-word-mode-job))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
|
|
|
|
;; Don't delete variants in case of ediff-buffer-* jobs without asking.
|
|
|
|
|
;; This is because u may loose work---dangerous.
|
|
|
|
|
(if (string-match "buffer" (symbol-name ediff-job-name))
|
|
|
|
|
(setq ediff-keep-variants t))
|
|
|
|
|
|
2001-12-24 05:50:31 +00:00
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(make-local-hook 'pre-command-hook))
|
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (ediff-window-display-p)
|
2001-12-24 05:50:31 +00:00
|
|
|
|
(add-hook 'pre-command-hook 'ediff-spy-after-mouse nil 'local))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq ediff-mouse-pixel-position (mouse-pixel-position))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; adjust for merge jobs
|
|
|
|
|
(if ediff-merge-job
|
|
|
|
|
(let ((buf
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; If default variant is `combined', the right stuff is
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; inserted by ediff-do-merge
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; Note: at some point, we tried to put ancestor buffer here
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; (which is currently buffer C. This didn't work right
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; because the merge buffer will contain lossage: diff regions
|
|
|
|
|
;; in the ancestor, which correspond to revisions that agree
|
|
|
|
|
;; in both buf A and B.
|
|
|
|
|
(cond ((eq ediff-default-variant 'default-B)
|
|
|
|
|
buffer-B)
|
|
|
|
|
(t buffer-A))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(setq ediff-split-window-function
|
|
|
|
|
ediff-merge-split-window-function)
|
|
|
|
|
|
|
|
|
|
;; remember the ancestor buffer, if any
|
|
|
|
|
(setq ediff-ancestor-buffer buffer-C)
|
|
|
|
|
|
|
|
|
|
(setq buffer-C
|
|
|
|
|
(get-buffer-create
|
|
|
|
|
(ediff-unique-buffer-name "*ediff-merge" "*")))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(set-buffer buffer-C)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(insert-buffer buf)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(funcall (ediff-with-current-buffer buf major-mode))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(add-hook 'local-write-file-hooks 'ediff-set-merge-mode nil t)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq buffer-read-only nil
|
|
|
|
|
ediff-buffer-A buffer-A
|
|
|
|
|
ediff-buffer-B buffer-B
|
|
|
|
|
ediff-buffer-C buffer-C
|
|
|
|
|
ediff-control-buffer control-buffer)
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
|
|
|
|
|
|
(ediff-choose-syntax-table)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(setq ediff-control-buffer-suffix
|
|
|
|
|
(if (string-match "<[0-9]*>" control-buffer-name)
|
|
|
|
|
(substring control-buffer-name
|
|
|
|
|
(match-beginning 0) (match-end 0))
|
|
|
|
|
"")
|
|
|
|
|
ediff-control-buffer-number
|
|
|
|
|
(max
|
|
|
|
|
0
|
|
|
|
|
(1-
|
|
|
|
|
(string-to-number
|
|
|
|
|
(substring
|
|
|
|
|
ediff-control-buffer-suffix
|
|
|
|
|
(or
|
|
|
|
|
(string-match "[0-9]+" ediff-control-buffer-suffix)
|
|
|
|
|
0))))))
|
|
|
|
|
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq ediff-error-buffer
|
|
|
|
|
(get-buffer-create (ediff-unique-buffer-name "*ediff-errors" "*")))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buffer-A (ediff-strip-mode-line-format))
|
|
|
|
|
(ediff-with-current-buffer buffer-B (ediff-strip-mode-line-format))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-job
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buffer-C (ediff-strip-mode-line-format)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(if (ediff-buffer-live-p ediff-ancestor-buffer)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-ancestor-buffer
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-strip-mode-line-format)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(ediff-save-protected-variables) ; save variables to be restored on exit
|
|
|
|
|
|
|
|
|
|
;; ediff-setup-diff-regions-function must be set after setup
|
|
|
|
|
;; parameters are processed.
|
|
|
|
|
(setq ediff-setup-diff-regions-function
|
|
|
|
|
(if ediff-diff3-job
|
|
|
|
|
'ediff-setup-diff-regions3
|
|
|
|
|
'ediff-setup-diff-regions))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq ediff-wide-bounds
|
|
|
|
|
(list (ediff-make-bullet-proof-overlay
|
|
|
|
|
'(point-min) '(point-max) ediff-buffer-A)
|
|
|
|
|
(ediff-make-bullet-proof-overlay
|
|
|
|
|
'(point-min) '(point-max) ediff-buffer-B)
|
|
|
|
|
(ediff-make-bullet-proof-overlay
|
|
|
|
|
'(point-min) '(point-max) ediff-buffer-C)))
|
|
|
|
|
|
|
|
|
|
;; This has effect only on ediff-windows/regions
|
|
|
|
|
;; In all other cases, ediff-visible-region sets visibility bounds to
|
|
|
|
|
;; ediff-wide-bounds, and ediff-narrow-bounds are ignored.
|
|
|
|
|
(if ediff-start-narrowed
|
|
|
|
|
(setq ediff-visible-bounds ediff-narrow-bounds)
|
|
|
|
|
(setq ediff-visible-bounds ediff-wide-bounds))
|
|
|
|
|
|
|
|
|
|
(ediff-set-keys) ; comes after parameter setup
|
|
|
|
|
|
|
|
|
|
;; set up ediff-narrow-bounds, if not set
|
|
|
|
|
(or ediff-narrow-bounds
|
|
|
|
|
(setq ediff-narrow-bounds ediff-wide-bounds))
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
;; All these must be inside ediff-with-current-buffer control-buffer,
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; since these vars are local to control-buffer
|
|
|
|
|
;; These won't run if there are errors in diff
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-A
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-nuke-selective-display)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-prepare-buffer-hook)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(if (ediff-with-current-buffer control-buffer ediff-merge-job)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq buffer-read-only t))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; add control-buffer to the list of sessions--no longer used, but may
|
|
|
|
|
;; be used again in the future
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(or (memq control-buffer ediff-this-buffer-ediff-sessions)
|
|
|
|
|
(setq ediff-this-buffer-ediff-sessions
|
|
|
|
|
(cons control-buffer ediff-this-buffer-ediff-sessions)))
|
1997-07-17 19:37:07 +00:00
|
|
|
|
(if ediff-make-buffers-readonly-at-startup
|
|
|
|
|
(setq buffer-read-only t))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
)
|
1997-07-17 19:37:07 +00:00
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-B
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-nuke-selective-display)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-prepare-buffer-hook)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(if (ediff-with-current-buffer control-buffer ediff-merge-job)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq buffer-read-only t))
|
|
|
|
|
;; add control-buffer to the list of sessions
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(or (memq control-buffer ediff-this-buffer-ediff-sessions)
|
|
|
|
|
(setq ediff-this-buffer-ediff-sessions
|
|
|
|
|
(cons control-buffer ediff-this-buffer-ediff-sessions)))
|
1997-07-17 19:37:07 +00:00
|
|
|
|
(if ediff-make-buffers-readonly-at-startup
|
|
|
|
|
(setq buffer-read-only t))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
)
|
1997-07-17 19:37:07 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-job
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-nuke-selective-display)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-prepare-buffer-hook)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; add control-buffer to the list of sessions
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(or (memq control-buffer ediff-this-buffer-ediff-sessions)
|
|
|
|
|
(setq ediff-this-buffer-ediff-sessions
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(cons control-buffer
|
1995-10-06 00:59:04 +00:00
|
|
|
|
ediff-this-buffer-ediff-sessions)))
|
1997-07-17 19:37:07 +00:00
|
|
|
|
(if ediff-make-buffers-readonly-at-startup
|
|
|
|
|
(setq buffer-read-only t))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(if (ediff-buffer-live-p ediff-ancestor-buffer)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-ancestor-buffer
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-nuke-selective-display)
|
|
|
|
|
(setq buffer-read-only t)
|
|
|
|
|
(run-hooks 'ediff-prepare-buffer-hook)
|
|
|
|
|
(or (memq control-buffer ediff-this-buffer-ediff-sessions)
|
|
|
|
|
(setq ediff-this-buffer-ediff-sessions
|
|
|
|
|
(cons control-buffer
|
|
|
|
|
ediff-this-buffer-ediff-sessions)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
;; must come after setting up ediff-narrow-bounds AND after
|
|
|
|
|
;; nuking selective display
|
|
|
|
|
(funcall ediff-setup-diff-regions-function file-A file-B file-C)
|
|
|
|
|
(setq ediff-number-of-differences (length ediff-difference-vector-A))
|
|
|
|
|
(setq ediff-current-difference -1)
|
|
|
|
|
|
|
|
|
|
(ediff-make-current-diff-overlay 'A)
|
|
|
|
|
(ediff-make-current-diff-overlay 'B)
|
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(ediff-make-current-diff-overlay 'C))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(if ediff-merge-with-ancestor-job
|
|
|
|
|
(ediff-make-current-diff-overlay 'Ancestor))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(ediff-setup-windows buffer-A buffer-B buffer-C control-buffer)
|
|
|
|
|
|
|
|
|
|
(let ((shift-A (ediff-overlay-start
|
|
|
|
|
(ediff-get-value-according-to-buffer-type
|
|
|
|
|
'A ediff-narrow-bounds)))
|
|
|
|
|
(shift-B (ediff-overlay-start
|
|
|
|
|
(ediff-get-value-according-to-buffer-type
|
|
|
|
|
'B ediff-narrow-bounds)))
|
|
|
|
|
(shift-C (ediff-overlay-start
|
|
|
|
|
(ediff-get-value-according-to-buffer-type
|
|
|
|
|
'C ediff-narrow-bounds))))
|
|
|
|
|
;; position point in buf A
|
|
|
|
|
(save-excursion
|
|
|
|
|
(select-window ediff-window-A)
|
|
|
|
|
(goto-char shift-A))
|
|
|
|
|
;; position point in buf B
|
|
|
|
|
(save-excursion
|
|
|
|
|
(select-window ediff-window-B)
|
|
|
|
|
(goto-char shift-B))
|
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(save-excursion
|
|
|
|
|
(select-window ediff-window-C)
|
|
|
|
|
(goto-char shift-C)))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(select-window ediff-control-window)
|
|
|
|
|
(ediff-visible-region)
|
|
|
|
|
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'startup-hooks)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(ediff-arrange-autosave-in-merge-jobs merge-buffer-file)
|
1997-11-01 01:46:51 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-refresh-mode-lines)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq buffer-read-only t)
|
|
|
|
|
(setq ediff-session-registry
|
|
|
|
|
(cons control-buffer ediff-session-registry))
|
|
|
|
|
(ediff-update-registry)
|
|
|
|
|
(if (ediff-buffer-live-p ediff-meta-buffer)
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(ediff-update-meta-buffer
|
|
|
|
|
ediff-meta-buffer nil ediff-meta-session-number))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-startup-hook)
|
|
|
|
|
) ; eval in control-buffer
|
1995-06-05 23:43:51 +00:00
|
|
|
|
control-buffer))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; This function assumes that we are in the window where control buffer is
|
|
|
|
|
;; to reside.
|
|
|
|
|
(defun ediff-setup-control-buffer (ctl-buf)
|
|
|
|
|
"Set up window for control buffer."
|
|
|
|
|
(if (window-dedicated-p (selected-window))
|
|
|
|
|
(set-buffer ctl-buf) ; we are in control frame but just in case
|
|
|
|
|
(switch-to-buffer ctl-buf))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let ((window-min-height 2))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(erase-buffer)
|
|
|
|
|
(ediff-set-help-message)
|
|
|
|
|
(insert ediff-help-message)
|
|
|
|
|
(shrink-window-if-larger-than-buffer)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(or (ediff-multiframe-setup-p)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-indent-help-message))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(ediff-set-help-overlays)
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(ediff-refresh-mode-lines)
|
|
|
|
|
(setq ediff-control-window (selected-window))
|
|
|
|
|
(setq ediff-window-config-saved
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(format "%S%S%S%S%S%S%S"
|
1995-03-16 22:34:51 +00:00
|
|
|
|
ediff-control-window
|
|
|
|
|
ediff-window-A
|
|
|
|
|
ediff-window-B
|
|
|
|
|
ediff-window-C
|
1995-06-05 23:43:51 +00:00
|
|
|
|
ediff-split-window-function
|
|
|
|
|
(ediff-multiframe-setup-p)
|
|
|
|
|
ediff-wide-display-p))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
|
|
|
|
|
;; In multiframe, toolbar is set in ediff-setup-control-frame
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(if (not (ediff-multiframe-setup-p))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(ediff-make-bottom-toolbar)) ; this checks if toolbar is requested
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(skip-chars-forward ediff-whitespace)))
|
|
|
|
|
|
1997-11-01 01:46:51 +00:00
|
|
|
|
;; This executes in control buffer and sets auto-save, visited file name, etc,
|
|
|
|
|
;; in the merge buffer
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(defun ediff-arrange-autosave-in-merge-jobs (merge-buffer-file)
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(if (not ediff-merge-job)
|
|
|
|
|
()
|
|
|
|
|
(if (stringp merge-buffer-file)
|
|
|
|
|
(setq ediff-autostore-merges t
|
|
|
|
|
ediff-merge-store-file merge-buffer-file))
|
|
|
|
|
(if (stringp ediff-merge-store-file)
|
|
|
|
|
(progn
|
|
|
|
|
;; save before leaving ctl buffer
|
|
|
|
|
(setq merge-buffer-file ediff-merge-store-file)
|
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
|
|
|
|
(set-visited-file-name merge-buffer-file))))
|
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
|
|
|
|
(setq buffer-offer-save t) ; ask before killing buffer
|
|
|
|
|
;; make sure the contents is auto-saved
|
|
|
|
|
(auto-save-mode 1))
|
|
|
|
|
))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Commands for working with Ediff
|
|
|
|
|
|
|
|
|
|
(defun ediff-update-diffs ()
|
|
|
|
|
"Recompute difference regions in buffers A, B, and C.
|
|
|
|
|
Buffers are not synchronized with their respective files, so changes done
|
|
|
|
|
to these buffers are not saved at this point---the user can do this later,
|
|
|
|
|
if necessary."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
|
|
|
|
(if (and (ediff-buffer-live-p ediff-ancestor-buffer)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(not
|
|
|
|
|
(y-or-n-p
|
1999-11-01 07:16:15 +00:00
|
|
|
|
"Ancestor buffer will not be used. Recompute diffs anyway? ")))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(error "Recomputation of differences canceled"))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(let ((point-A (ediff-with-current-buffer ediff-buffer-A (point)))
|
|
|
|
|
;;(point-B (ediff-with-current-buffer ediff-buffer-B (point)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(tmp-buffer (get-buffer-create ediff-tmp-buffer))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(buf-A-file-name (buffer-file-name ediff-buffer-A))
|
|
|
|
|
(buf-B-file-name (buffer-file-name ediff-buffer-B))
|
|
|
|
|
;; (null ediff-buffer-C) is no problem, as we later check if
|
|
|
|
|
;; ediff-buffer-C is alive
|
|
|
|
|
(buf-C-file-name (buffer-file-name ediff-buffer-C))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(overl-A (ediff-get-value-according-to-buffer-type
|
|
|
|
|
'A ediff-narrow-bounds))
|
|
|
|
|
(overl-B (ediff-get-value-according-to-buffer-type
|
|
|
|
|
'B ediff-narrow-bounds))
|
|
|
|
|
(overl-C (ediff-get-value-according-to-buffer-type
|
|
|
|
|
'C ediff-narrow-bounds))
|
|
|
|
|
beg-A end-A beg-B end-B beg-C end-C
|
|
|
|
|
file-A file-B file-C)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
|
|
|
|
|
(if (stringp buf-A-file-name)
|
|
|
|
|
(setq buf-A-file-name (file-name-nondirectory buf-A-file-name)))
|
|
|
|
|
(if (stringp buf-B-file-name)
|
|
|
|
|
(setq buf-B-file-name (file-name-nondirectory buf-B-file-name)))
|
|
|
|
|
(if (stringp buf-C-file-name)
|
|
|
|
|
(setq buf-C-file-name (file-name-nondirectory buf-C-file-name)))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-unselect-and-select-difference -1)
|
|
|
|
|
|
|
|
|
|
(setq beg-A (ediff-overlay-start overl-A)
|
|
|
|
|
beg-B (ediff-overlay-start overl-B)
|
|
|
|
|
beg-C (ediff-overlay-start overl-C)
|
|
|
|
|
end-A (ediff-overlay-end overl-A)
|
|
|
|
|
end-B (ediff-overlay-end overl-B)
|
|
|
|
|
end-C (ediff-overlay-end overl-C))
|
|
|
|
|
|
|
|
|
|
(if ediff-word-mode
|
|
|
|
|
(progn
|
|
|
|
|
(ediff-wordify beg-A end-A ediff-buffer-A tmp-buffer)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq file-A (ediff-make-temp-file tmp-buffer "regA"))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-wordify beg-B end-B ediff-buffer-B tmp-buffer)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq file-B (ediff-make-temp-file tmp-buffer "regB"))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(progn
|
|
|
|
|
(ediff-wordify beg-C end-C ediff-buffer-C tmp-buffer)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq file-C (ediff-make-temp-file tmp-buffer "regC"))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
)
|
|
|
|
|
;; not word-mode
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq file-A (ediff-make-temp-file ediff-buffer-A buf-A-file-name))
|
|
|
|
|
(setq file-B (ediff-make-temp-file ediff-buffer-B buf-B-file-name))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-job
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq file-C (ediff-make-temp-file ediff-buffer-C buf-C-file-name)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(ediff-clear-diff-vector 'ediff-difference-vector-A 'fine-diffs-also)
|
|
|
|
|
(ediff-clear-diff-vector 'ediff-difference-vector-B 'fine-diffs-also)
|
|
|
|
|
(ediff-clear-diff-vector 'ediff-difference-vector-C 'fine-diffs-also)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-clear-diff-vector
|
|
|
|
|
'ediff-difference-vector-Ancestor 'fine-diffs-also)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; let them garbage collect. we can't use the ancestor after recomputing
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; the diffs.
|
|
|
|
|
(setq ediff-difference-vector-Ancestor nil
|
|
|
|
|
ediff-ancestor-buffer nil
|
|
|
|
|
ediff-state-of-merge nil)
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq ediff-killed-diffs-alist nil) ; invalidate saved killed diff regions
|
|
|
|
|
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; In case of merge job, fool it into thinking that it is just doing
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; comparison
|
|
|
|
|
(let ((ediff-setup-diff-regions-function ediff-setup-diff-regions-function)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-3way-comparison-job ediff-3way-comparison-job)
|
|
|
|
|
(ediff-merge-job ediff-merge-job)
|
|
|
|
|
(ediff-merge-with-ancestor-job ediff-merge-with-ancestor-job)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-job-name ediff-job-name))
|
|
|
|
|
(if ediff-merge-job
|
|
|
|
|
(setq ediff-setup-diff-regions-function 'ediff-setup-diff-regions3
|
1995-10-06 00:59:04 +00:00
|
|
|
|
ediff-3way-comparison-job t
|
|
|
|
|
ediff-merge-job nil
|
|
|
|
|
ediff-merge-with-ancestor-job nil
|
1995-03-16 22:34:51 +00:00
|
|
|
|
ediff-job-name 'ediff-files3))
|
|
|
|
|
(funcall ediff-setup-diff-regions-function file-A file-B file-C))
|
|
|
|
|
|
|
|
|
|
(setq ediff-number-of-differences (length ediff-difference-vector-A))
|
|
|
|
|
(delete-file file-A)
|
|
|
|
|
(delete-file file-B)
|
|
|
|
|
(if file-C
|
|
|
|
|
(delete-file file-C))
|
|
|
|
|
|
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(ediff-set-state-of-all-diffs-in-all-buffers ediff-control-buffer))
|
|
|
|
|
|
|
|
|
|
(ediff-jump-to-difference (ediff-diff-at-point 'A point-A))
|
|
|
|
|
(message "")
|
|
|
|
|
))
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; Not bound to any key---to dangerous. A user can do it if necessary.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(defun ediff-revert-buffers-then-recompute-diffs (noconfirm)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
"Revert buffers A, B and C. Then rerun Ediff on file A and file B."
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(interactive "P")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let ((bufA ediff-buffer-A)
|
|
|
|
|
(bufB ediff-buffer-B)
|
|
|
|
|
(bufC ediff-buffer-C)
|
|
|
|
|
(ctl-buf ediff-control-buffer)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(keep-variants ediff-keep-variants)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ancestor-buf ediff-ancestor-buffer)
|
|
|
|
|
(ancestor-job ediff-merge-with-ancestor-job)
|
|
|
|
|
(merge ediff-merge-job)
|
|
|
|
|
(comparison ediff-3way-comparison-job))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufA
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(revert-buffer t noconfirm))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufB
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(revert-buffer t noconfirm))
|
|
|
|
|
;; this should only be executed in a 3way comparison, not in merge
|
|
|
|
|
(if comparison
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufC
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(revert-buffer t noconfirm)))
|
|
|
|
|
(if merge
|
|
|
|
|
(progn
|
|
|
|
|
(set-buffer ctl-buf)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; the argument says whether to reverse the meaning of
|
|
|
|
|
;; ediff-keep-variants, i.e., ediff-really-quit runs here with
|
|
|
|
|
;; variants kept.
|
|
|
|
|
(ediff-really-quit (not keep-variants))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(kill-buffer bufC)
|
|
|
|
|
(if ancestor-job
|
|
|
|
|
(ediff-merge-buffers-with-ancestor bufA bufB ancestor-buf)
|
|
|
|
|
(ediff-merge-buffers bufA bufB)))
|
|
|
|
|
(ediff-update-diffs))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; optional NO-REHIGHLIGHT says to not rehighlight buffers
|
|
|
|
|
(defun ediff-recenter (&optional no-rehighlight)
|
|
|
|
|
"Bring the highlighted region of all buffers being compared into view.
|
|
|
|
|
Reestablish the default three-window display."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let (buffer-read-only)
|
|
|
|
|
(if (and (ediff-buffer-live-p ediff-buffer-A)
|
|
|
|
|
(ediff-buffer-live-p ediff-buffer-B)
|
|
|
|
|
(or (not ediff-3way-job)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-buffer-live-p ediff-buffer-C)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-setup-windows
|
|
|
|
|
ediff-buffer-A ediff-buffer-B ediff-buffer-C ediff-control-buffer)
|
|
|
|
|
(or (eq this-command 'ediff-quit)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(message ediff-KILLED-VITAL-BUFFER
|
|
|
|
|
(beep 1)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; set visibility range appropriate to this invocation of Ediff.
|
|
|
|
|
(ediff-visible-region)
|
|
|
|
|
;; raise
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if (and (ediff-window-display-p)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(symbolp this-command)
|
|
|
|
|
(symbolp last-command)
|
|
|
|
|
;; Either one of the display-changing commands
|
|
|
|
|
(or (memq this-command
|
|
|
|
|
'(ediff-recenter
|
1995-10-06 00:59:04 +00:00
|
|
|
|
ediff-dir-action ediff-registry-action
|
|
|
|
|
ediff-patch-action
|
1995-03-16 22:34:51 +00:00
|
|
|
|
ediff-toggle-wide-display ediff-toggle-multiframe))
|
|
|
|
|
;; Or one of the movement cmds and prev cmd was an Ediff cmd
|
1996-01-05 22:21:28 +00:00
|
|
|
|
;; This avoids raising frames unnecessarily.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(and (memq this-command
|
|
|
|
|
'(ediff-next-difference
|
|
|
|
|
ediff-previous-difference
|
|
|
|
|
ediff-jump-to-difference
|
|
|
|
|
ediff-jump-to-difference-at-point))
|
|
|
|
|
(not (string-match "^ediff-" (symbol-name last-command)))
|
|
|
|
|
)))
|
|
|
|
|
(progn
|
|
|
|
|
(if (window-live-p ediff-window-A)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(raise-frame (window-frame ediff-window-A)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (window-live-p ediff-window-B)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(raise-frame (window-frame ediff-window-B)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (window-live-p ediff-window-C)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(raise-frame (window-frame ediff-window-C)))))
|
|
|
|
|
(if (and (ediff-window-display-p)
|
|
|
|
|
(frame-live-p ediff-control-frame)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(not ediff-use-long-help-message)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(not (ediff-frame-iconified-p ediff-control-frame)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(raise-frame ediff-control-frame))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; Redisplay whatever buffers are showing, if there is a selected difference
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(let ((control-frame ediff-control-frame)
|
|
|
|
|
(control-buf ediff-control-buffer))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (and (ediff-buffer-live-p ediff-buffer-A)
|
|
|
|
|
(ediff-buffer-live-p ediff-buffer-B)
|
|
|
|
|
(or (not ediff-3way-job)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(ediff-buffer-live-p ediff-buffer-C)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(progn
|
|
|
|
|
(or no-rehighlight
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-select-difference ediff-current-difference))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-recenter-one-window 'A)
|
|
|
|
|
(ediff-recenter-one-window 'B)
|
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(ediff-recenter-one-window 'C))
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer control-buf
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(ediff-recenter-ancestor) ; check if ancestor is alive
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
|
|
|
|
(if (and (ediff-multiframe-setup-p)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(not ediff-use-long-help-message)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(not (ediff-frame-iconified-p ediff-control-frame)))
|
|
|
|
|
;; never grab mouse on quit in this place
|
|
|
|
|
(ediff-reset-mouse
|
|
|
|
|
control-frame
|
|
|
|
|
(eq this-command 'ediff-quit))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
|
|
|
|
|
(ediff-restore-highlighting)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer control-buf (ediff-refresh-mode-lines))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
;; this function returns to the window it was called from
|
|
|
|
|
;; (which was the control window)
|
|
|
|
|
(defun ediff-recenter-one-window (buf-type)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(if (ediff-valid-difference-p)
|
|
|
|
|
;; context must be saved before switching to windows A/B/C
|
|
|
|
|
(let* ((ctl-wind (selected-window))
|
|
|
|
|
(shift (ediff-overlay-start
|
|
|
|
|
(ediff-get-value-according-to-buffer-type
|
|
|
|
|
buf-type ediff-narrow-bounds)))
|
|
|
|
|
(job-name ediff-job-name)
|
|
|
|
|
(control-buf ediff-control-buffer)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(window-name (ediff-get-symbol-from-alist
|
|
|
|
|
buf-type ediff-window-alist))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(window (if (window-live-p (symbol-value window-name))
|
|
|
|
|
(symbol-value window-name))))
|
|
|
|
|
|
|
|
|
|
(if (and window ediff-windows-job)
|
|
|
|
|
(set-window-start window shift))
|
|
|
|
|
(if window
|
|
|
|
|
(progn
|
|
|
|
|
(select-window window)
|
|
|
|
|
(ediff-deactivate-mark)
|
|
|
|
|
(ediff-position-region
|
|
|
|
|
(ediff-get-diff-posn buf-type 'beg nil control-buf)
|
|
|
|
|
(ediff-get-diff-posn buf-type 'end nil control-buf)
|
|
|
|
|
(ediff-get-diff-posn buf-type 'beg nil control-buf)
|
|
|
|
|
job-name
|
|
|
|
|
)))
|
|
|
|
|
(select-window ctl-wind)
|
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
(defun ediff-recenter-ancestor ()
|
|
|
|
|
;; do half-hearted job by recentering the ancestor buffer, if it is alive and
|
|
|
|
|
;; visible.
|
|
|
|
|
(if (and (ediff-buffer-live-p ediff-ancestor-buffer)
|
|
|
|
|
(ediff-valid-difference-p))
|
|
|
|
|
(let ((window (ediff-get-visible-buffer-window ediff-ancestor-buffer))
|
|
|
|
|
(ctl-wind (selected-window))
|
|
|
|
|
(job-name ediff-job-name)
|
|
|
|
|
(ctl-buf ediff-control-buffer))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-ancestor-buffer
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(goto-char (ediff-get-diff-posn 'Ancestor 'beg nil ctl-buf))
|
|
|
|
|
(if window
|
|
|
|
|
(progn
|
|
|
|
|
(select-window window)
|
|
|
|
|
(ediff-position-region
|
|
|
|
|
(ediff-get-diff-posn 'Ancestor 'beg nil ctl-buf)
|
|
|
|
|
(ediff-get-diff-posn 'Ancestor 'end nil ctl-buf)
|
|
|
|
|
(ediff-get-diff-posn 'Ancestor 'beg nil ctl-buf)
|
|
|
|
|
job-name))))
|
|
|
|
|
(select-window ctl-wind)
|
|
|
|
|
)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; This will have to be refined for 3way jobs
|
|
|
|
|
(defun ediff-toggle-split ()
|
|
|
|
|
"Toggle vertical/horizontal window split.
|
|
|
|
|
Does nothing if file-A and file-B are in different frames."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let* ((wind-A (if (window-live-p ediff-window-A) ediff-window-A))
|
|
|
|
|
(wind-B (if (window-live-p ediff-window-B) ediff-window-B))
|
|
|
|
|
(wind-C (if (window-live-p ediff-window-C) ediff-window-C))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(frame-A (if wind-A (window-frame wind-A)))
|
|
|
|
|
(frame-B (if wind-B (window-frame wind-B)))
|
|
|
|
|
(frame-C (if wind-C (window-frame wind-C))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (or (eq frame-A frame-B)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(not (frame-live-p frame-A))
|
|
|
|
|
(not (frame-live-p frame-B))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-comparison-job
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(or (not (frame-live-p frame-C))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(eq frame-A frame-C) (eq frame-B frame-C))))
|
|
|
|
|
(setq ediff-split-window-function
|
|
|
|
|
(if (eq ediff-split-window-function 'split-window-vertically)
|
|
|
|
|
'split-window-horizontally
|
|
|
|
|
'split-window-vertically))
|
|
|
|
|
(message "Buffers being compared are in different frames"))
|
|
|
|
|
(ediff-recenter 'no-rehighlight)))
|
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-hilit ()
|
|
|
|
|
"Switch between highlighting using ASCII flags and highlighting using faces.
|
|
|
|
|
On a dumb terminal, switches between ASCII highlighting and no highlighting."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (not (ediff-has-face-support-p))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (eq ediff-highlighting-style 'ascii)
|
|
|
|
|
(progn
|
|
|
|
|
(message "ASCII highlighting flags removed")
|
|
|
|
|
(ediff-unselect-and-select-difference ediff-current-difference
|
|
|
|
|
'unselect-only)
|
|
|
|
|
(setq ediff-highlighting-style 'off))
|
|
|
|
|
(ediff-unselect-and-select-difference ediff-current-difference
|
|
|
|
|
'select-only))
|
|
|
|
|
(ediff-unselect-and-select-difference ediff-current-difference
|
|
|
|
|
'unselect-only)
|
|
|
|
|
;; cycle through highlighting
|
|
|
|
|
(cond ((and ediff-use-faces ediff-highlight-all-diffs)
|
|
|
|
|
(message "Unhighlighting unselected difference regions")
|
|
|
|
|
(setq ediff-highlight-all-diffs nil))
|
|
|
|
|
(ediff-use-faces
|
|
|
|
|
(message "Highlighting with ASCII flags")
|
|
|
|
|
(setq ediff-use-faces nil))
|
|
|
|
|
(t
|
|
|
|
|
(message "Re-highlighting all difference regions")
|
|
|
|
|
(setq ediff-use-faces t
|
|
|
|
|
ediff-highlight-all-diffs t)))
|
|
|
|
|
|
|
|
|
|
(if (and ediff-use-faces ediff-highlight-all-diffs)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(ediff-paint-background-regions)
|
|
|
|
|
(ediff-paint-background-regions 'unhighlight))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(ediff-unselect-and-select-difference
|
|
|
|
|
ediff-current-difference 'select-only))
|
|
|
|
|
)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-autorefine ()
|
|
|
|
|
"Toggle auto-refine mode."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-word-mode
|
|
|
|
|
(error "No fine differences in this mode"))
|
|
|
|
|
(cond ((eq ediff-auto-refine 'nix)
|
|
|
|
|
(setq ediff-auto-refine 'on)
|
|
|
|
|
(ediff-make-fine-diffs ediff-current-difference 'noforce)
|
|
|
|
|
(message "Auto-refining is ON"))
|
|
|
|
|
((eq ediff-auto-refine 'on)
|
|
|
|
|
(message "Auto-refining is OFF")
|
|
|
|
|
(setq ediff-auto-refine 'off))
|
|
|
|
|
(t ;; nix 'em
|
|
|
|
|
(ediff-set-fine-diff-properties ediff-current-difference 'default)
|
|
|
|
|
(message "Refinements are HIDDEN")
|
|
|
|
|
(setq ediff-auto-refine 'nix))
|
|
|
|
|
))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-show-ancestor ()
|
|
|
|
|
"Show the ancestor buffer in a suitable window."
|
|
|
|
|
(interactive)
|
|
|
|
|
(ediff-recenter)
|
|
|
|
|
(or (ediff-buffer-live-p ediff-ancestor-buffer)
|
|
|
|
|
(if ediff-merge-with-ancestor-job
|
|
|
|
|
(error "Lost connection to ancestor buffer...sorry")
|
|
|
|
|
(error "Not merging with ancestor")))
|
|
|
|
|
(let (wind)
|
|
|
|
|
(cond ((setq wind (ediff-get-visible-buffer-window ediff-ancestor-buffer))
|
|
|
|
|
(raise-frame (window-frame wind)))
|
|
|
|
|
(t (set-window-buffer ediff-window-C ediff-ancestor-buffer)))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-make-or-kill-fine-diffs (arg)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
"Compute fine diffs. With negative prefix arg, kill fine diffs.
|
2000-10-29 04:56:45 +00:00
|
|
|
|
In both cases, operates on the current difference region."
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(interactive "P")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(cond ((eq arg '-)
|
|
|
|
|
(ediff-clear-fine-differences ediff-current-difference))
|
|
|
|
|
((and (numberp arg) (< arg 0))
|
|
|
|
|
(ediff-clear-fine-differences ediff-current-difference))
|
|
|
|
|
(t (ediff-make-fine-diffs))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-help ()
|
|
|
|
|
"Toggle short/long help message."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let (buffer-read-only)
|
|
|
|
|
(erase-buffer)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(setq ediff-use-long-help-message (not ediff-use-long-help-message))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-set-help-message))
|
|
|
|
|
;; remember the icon status of the control frame when the user requested
|
|
|
|
|
;; full control message
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (and ediff-use-long-help-message (ediff-multiframe-setup-p))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq ediff-prefer-iconified-control-frame
|
|
|
|
|
(ediff-frame-iconified-p ediff-control-frame)))
|
|
|
|
|
|
|
|
|
|
(setq ediff-window-config-saved "") ; force redisplay
|
|
|
|
|
(ediff-recenter 'no-rehighlight))
|
|
|
|
|
|
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; If BUF, this is the buffer to toggle, not current buffer.
|
|
|
|
|
(defun ediff-toggle-read-only (&optional buf)
|
|
|
|
|
"Toggle read-only in current buffer.
|
|
|
|
|
If buffer is under version control and locked, check it out first.
|
|
|
|
|
If optional argument BUF is specified, toggle read-only in that buffer instead
|
|
|
|
|
of the current buffer."
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(let ((ctl-buf (if (null buf) (current-buffer)))
|
|
|
|
|
(buf-type (ediff-char-to-buftype last-command-char)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(or buf (ediff-recenter))
|
|
|
|
|
(or buf
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(setq buf (ediff-get-buffer buf-type)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buf ; eval in buf A/B/C
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let* ((file (buffer-file-name buf))
|
|
|
|
|
(file-writable (and file
|
|
|
|
|
(file-exists-p file)
|
|
|
|
|
(file-writable-p file)))
|
|
|
|
|
(toggle-ro-cmd (cond (ediff-toggle-read-only-function)
|
|
|
|
|
((ediff-file-checked-out-p file)
|
|
|
|
|
'toggle-read-only)
|
|
|
|
|
(file-writable 'toggle-read-only)
|
|
|
|
|
(t (key-binding "\C-x\C-q")))))
|
|
|
|
|
;; If the file is checked in, make sure we don't make buffer modifiable
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; without warning the user. The user can fool our checks by making the
|
|
|
|
|
;; buffer non-RO without checking the file out. We regard this as a
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; user problem.
|
|
|
|
|
(if (and (ediff-file-checked-in-p file)
|
|
|
|
|
;; If ctl-buf is null, this means we called this
|
|
|
|
|
;; non-interactively, in which case don't ask questions
|
|
|
|
|
ctl-buf)
|
|
|
|
|
(cond ((not buffer-read-only)
|
|
|
|
|
(setq toggle-ro-cmd 'toggle-read-only))
|
|
|
|
|
((and (or (beep 1) t) ; always beep
|
|
|
|
|
(y-or-n-p
|
|
|
|
|
(format
|
1999-11-01 07:16:15 +00:00
|
|
|
|
"File %s is under version control. Check it out? "
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-abbreviate-file-name file))))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; if we checked the file out, we should also change the
|
|
|
|
|
;; original state of buffer-read-only to nil. If we don't
|
|
|
|
|
;; do this, the mode line will show %%, since the file was
|
|
|
|
|
;; RO before ediff started, so the user will think the file
|
|
|
|
|
;; is checked in.
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ctl-buf
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-change-saved-variable
|
1996-02-16 06:36:35 +00:00
|
|
|
|
'buffer-read-only nil buf-type)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(t
|
|
|
|
|
(setq toggle-ro-cmd 'toggle-read-only)
|
|
|
|
|
(beep 1) (beep 1)
|
|
|
|
|
(message
|
1996-12-28 02:53:04 +00:00
|
|
|
|
"Boy, this is risky! Don't modify this file...")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(sit-for 3)))) ; let the user see the warning
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if (and toggle-ro-cmd
|
|
|
|
|
(string-match "toggle-read-only" (symbol-name toggle-ro-cmd)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-window-excursion
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(select-window (ediff-get-visible-buffer-window buf))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(command-execute toggle-ro-cmd)))
|
|
|
|
|
(error "Don't know how to toggle read-only in buffer %S" buf))
|
|
|
|
|
|
|
|
|
|
;; Check if we made the current buffer updatable, but its file is RO.
|
|
|
|
|
;; Signal a warning in this case.
|
|
|
|
|
(if (and file (not buffer-read-only)
|
|
|
|
|
(eq this-command 'ediff-toggle-read-only)
|
|
|
|
|
(file-exists-p file)
|
|
|
|
|
(not (file-writable-p file)))
|
|
|
|
|
(message "Warning: file %s is read-only"
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-abbreviate-file-name file) (beep 1)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
))))
|
|
|
|
|
|
1996-12-28 02:53:04 +00:00
|
|
|
|
;; checkout if visited file is checked in
|
|
|
|
|
(defun ediff-maybe-checkout (buf)
|
1998-05-04 22:42:59 +00:00
|
|
|
|
(let ((file (expand-file-name (buffer-file-name buf)))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(checkout-function (key-binding "\C-x\C-q")))
|
|
|
|
|
(if (and (ediff-file-checked-in-p file)
|
|
|
|
|
(or (beep 1) t)
|
|
|
|
|
(y-or-n-p
|
|
|
|
|
(format
|
1999-11-01 07:16:15 +00:00
|
|
|
|
"File %s is under version control. Check it out? "
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(ediff-abbreviate-file-name file))))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buf
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(command-execute checkout-function)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; This is a simple-minded check for whether a file is under version control.
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; If file,v exists but file doesn't, this file is considered to be not checked
|
|
|
|
|
;; in and not checked out for the purpose of patching (since patch won't be
|
|
|
|
|
;; able to read such a file anyway).
|
|
|
|
|
;; FILE is a string representing file name
|
1998-05-04 22:42:59 +00:00
|
|
|
|
;;(defun ediff-file-under-version-control (file)
|
|
|
|
|
;; (let* ((filedir (file-name-directory file))
|
|
|
|
|
;; (file-nondir (file-name-nondirectory file))
|
|
|
|
|
;; (trial (concat file-nondir ",v"))
|
|
|
|
|
;; (full-trial (concat filedir trial))
|
|
|
|
|
;; (full-rcs-trial (concat filedir "RCS/" trial)))
|
|
|
|
|
;; (and (stringp file)
|
|
|
|
|
;; (file-exists-p file)
|
|
|
|
|
;; (or
|
|
|
|
|
;; (and
|
|
|
|
|
;; (file-exists-p full-trial)
|
|
|
|
|
;; ;; in FAT FS, `file,v' and `file' may turn out to be the same!
|
|
|
|
|
;; ;; don't be fooled by this!
|
|
|
|
|
;; (not (equal (file-attributes file)
|
|
|
|
|
;; (file-attributes full-trial))))
|
|
|
|
|
;; ;; check if a version is in RCS/ directory
|
|
|
|
|
;; (file-exists-p full-rcs-trial)))
|
|
|
|
|
;; ))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defsubst ediff-file-checked-out-p (file)
|
|
|
|
|
(or (not (featurep 'vc-hooks))
|
|
|
|
|
(and (vc-backend file)
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
|
(if (fboundp 'vc-state)
|
|
|
|
|
(or (memq (vc-state file) '(edited needs-merge))
|
|
|
|
|
(stringp (vc-state file)))
|
|
|
|
|
;; XEmacs has no vc-state
|
|
|
|
|
(vc-locking-user file))
|
|
|
|
|
)))
|
2000-11-22 12:54:21 +00:00
|
|
|
|
|
1998-05-04 22:42:59 +00:00
|
|
|
|
(defsubst ediff-file-checked-in-p (file)
|
|
|
|
|
(and (featurep 'vc-hooks)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; CVS files are considered not checked in
|
|
|
|
|
(not (memq (vc-backend file) '(nil CVS)))
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
|
(if (fboundp 'vc-state)
|
|
|
|
|
(progn
|
|
|
|
|
(not (memq (vc-state file) '(edited needs-merge)))
|
|
|
|
|
(not (stringp (vc-state file))))
|
|
|
|
|
;; XEmacs has no vc-state
|
|
|
|
|
(not (vc-locking-user file)))
|
|
|
|
|
))
|
1998-05-04 22:42:59 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-file-compressed-p (file)
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(require 'jka-compr)
|
|
|
|
|
(error))
|
|
|
|
|
(if (featurep 'jka-compr)
|
|
|
|
|
(string-match (jka-compr-build-file-regexp) file)))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-swap-buffers ()
|
|
|
|
|
"Rotate the display of buffers A, B, and C."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (and (window-live-p ediff-window-A) (window-live-p ediff-window-B))
|
|
|
|
|
(let ((buf ediff-buffer-A)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(values ediff-buffer-values-orig-A)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(diff-vec ediff-difference-vector-A)
|
|
|
|
|
(hide-regexp ediff-regexp-hide-A)
|
|
|
|
|
(focus-regexp ediff-regexp-focus-A)
|
|
|
|
|
(wide-visibility-p (eq ediff-visible-bounds ediff-wide-bounds))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(overlay (if (ediff-has-face-support-p)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
ediff-current-diff-overlay-A)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-comparison-job
|
|
|
|
|
(progn
|
|
|
|
|
(set-window-buffer ediff-window-A ediff-buffer-C)
|
|
|
|
|
(set-window-buffer ediff-window-B ediff-buffer-A)
|
|
|
|
|
(set-window-buffer ediff-window-C ediff-buffer-B)
|
|
|
|
|
)
|
|
|
|
|
(set-window-buffer ediff-window-A ediff-buffer-B)
|
|
|
|
|
(set-window-buffer ediff-window-B ediff-buffer-A))
|
|
|
|
|
;; swap diff buffers
|
|
|
|
|
(if ediff-3way-comparison-job
|
|
|
|
|
(setq ediff-buffer-A ediff-buffer-C
|
|
|
|
|
ediff-buffer-C ediff-buffer-B
|
|
|
|
|
ediff-buffer-B buf)
|
|
|
|
|
(setq ediff-buffer-A ediff-buffer-B
|
|
|
|
|
ediff-buffer-B buf))
|
|
|
|
|
|
|
|
|
|
;; swap saved buffer characteristics
|
|
|
|
|
(if ediff-3way-comparison-job
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(setq ediff-buffer-values-orig-A ediff-buffer-values-orig-C
|
|
|
|
|
ediff-buffer-values-orig-C ediff-buffer-values-orig-B
|
|
|
|
|
ediff-buffer-values-orig-B values)
|
|
|
|
|
(setq ediff-buffer-values-orig-A ediff-buffer-values-orig-B
|
|
|
|
|
ediff-buffer-values-orig-B values))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; swap diff vectors
|
|
|
|
|
(if ediff-3way-comparison-job
|
|
|
|
|
(setq ediff-difference-vector-A ediff-difference-vector-C
|
|
|
|
|
ediff-difference-vector-C ediff-difference-vector-B
|
|
|
|
|
ediff-difference-vector-B diff-vec)
|
|
|
|
|
(setq ediff-difference-vector-A ediff-difference-vector-B
|
|
|
|
|
ediff-difference-vector-B diff-vec))
|
|
|
|
|
|
|
|
|
|
;; swap hide/focus regexp
|
|
|
|
|
(if ediff-3way-comparison-job
|
|
|
|
|
(setq ediff-regexp-hide-A ediff-regexp-hide-C
|
|
|
|
|
ediff-regexp-hide-C ediff-regexp-hide-B
|
|
|
|
|
ediff-regexp-hide-B hide-regexp
|
|
|
|
|
ediff-regexp-focus-A ediff-regexp-focus-C
|
|
|
|
|
ediff-regexp-focus-C ediff-regexp-focus-B
|
|
|
|
|
ediff-regexp-focus-B focus-regexp)
|
|
|
|
|
(setq ediff-regexp-hide-A ediff-regexp-hide-B
|
|
|
|
|
ediff-regexp-hide-B hide-regexp
|
|
|
|
|
ediff-regexp-focus-A ediff-regexp-focus-B
|
|
|
|
|
ediff-regexp-focus-B focus-regexp))
|
|
|
|
|
|
|
|
|
|
;; The following is needed for XEmacs, since there one can't move
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; overlay to another buffer. In Emacs, this swap is redundant.
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (ediff-has-face-support-p)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-comparison-job
|
|
|
|
|
(setq ediff-current-diff-overlay-A ediff-current-diff-overlay-C
|
|
|
|
|
ediff-current-diff-overlay-C ediff-current-diff-overlay-B
|
|
|
|
|
ediff-current-diff-overlay-B overlay)
|
|
|
|
|
(setq ediff-current-diff-overlay-A ediff-current-diff-overlay-B
|
|
|
|
|
ediff-current-diff-overlay-B overlay)))
|
|
|
|
|
|
|
|
|
|
;; swap wide bounds
|
|
|
|
|
(setq ediff-wide-bounds
|
|
|
|
|
(cond (ediff-3way-comparison-job
|
|
|
|
|
(list (nth 2 ediff-wide-bounds)
|
|
|
|
|
(nth 0 ediff-wide-bounds)
|
|
|
|
|
(nth 1 ediff-wide-bounds)))
|
|
|
|
|
(ediff-3way-job
|
|
|
|
|
(list (nth 1 ediff-wide-bounds)
|
|
|
|
|
(nth 0 ediff-wide-bounds)
|
|
|
|
|
(nth 2 ediff-wide-bounds)))
|
|
|
|
|
(t
|
|
|
|
|
(list (nth 1 ediff-wide-bounds)
|
|
|
|
|
(nth 0 ediff-wide-bounds)))))
|
|
|
|
|
;; swap narrow bounds
|
|
|
|
|
(setq ediff-narrow-bounds
|
|
|
|
|
(cond (ediff-3way-comparison-job
|
|
|
|
|
(list (nth 2 ediff-narrow-bounds)
|
|
|
|
|
(nth 0 ediff-narrow-bounds)
|
|
|
|
|
(nth 1 ediff-narrow-bounds)))
|
|
|
|
|
(ediff-3way-job
|
|
|
|
|
(list (nth 1 ediff-narrow-bounds)
|
|
|
|
|
(nth 0 ediff-narrow-bounds)
|
|
|
|
|
(nth 2 ediff-narrow-bounds)))
|
|
|
|
|
(t
|
|
|
|
|
(list (nth 1 ediff-narrow-bounds)
|
|
|
|
|
(nth 0 ediff-narrow-bounds)))))
|
|
|
|
|
(if wide-visibility-p
|
|
|
|
|
(setq ediff-visible-bounds ediff-wide-bounds)
|
|
|
|
|
(setq ediff-visible-bounds ediff-narrow-bounds))
|
|
|
|
|
))
|
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(ediff-set-state-of-all-diffs-in-all-buffers ediff-control-buffer))
|
|
|
|
|
(ediff-recenter 'no-rehighlight)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-wide-display ()
|
|
|
|
|
"Toggle wide/regular display.
|
|
|
|
|
This is especially useful when comparing buffers side-by-side."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(or (ediff-window-display-p)
|
|
|
|
|
(error "%sEmacs is not running as a window application"
|
|
|
|
|
(if ediff-emacs-p "" "X")))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-recenter 'no-rehighlight) ; make sure buffs are displayed in windows
|
|
|
|
|
(let ((ctl-buf ediff-control-buffer))
|
|
|
|
|
(setq ediff-wide-display-p (not ediff-wide-display-p))
|
|
|
|
|
(if (not ediff-wide-display-p)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ctl-buf
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(modify-frame-parameters
|
1995-03-16 22:34:51 +00:00
|
|
|
|
ediff-wide-display-frame ediff-wide-display-orig-parameters)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;;(sit-for (if ediff-xemacs-p 0.4 0))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; restore control buf, since ctl window may have been deleted
|
|
|
|
|
;; during resizing
|
|
|
|
|
(set-buffer ctl-buf)
|
|
|
|
|
(setq ediff-wide-display-orig-parameters nil
|
|
|
|
|
ediff-window-B nil) ; force update of window config
|
|
|
|
|
(ediff-recenter 'no-rehighlight))
|
|
|
|
|
(funcall ediff-make-wide-display-function)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;;(sit-for (if ediff-xemacs-p 0.4 0))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ctl-buf
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq ediff-window-B nil) ; force update of window config
|
|
|
|
|
(ediff-recenter 'no-rehighlight)))))
|
|
|
|
|
|
1996-12-28 02:53:04 +00:00
|
|
|
|
;;;###autoload
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(defun ediff-toggle-multiframe ()
|
1997-05-31 01:10:39 +00:00
|
|
|
|
"Switch from multiframe display to single-frame display and back.
|
|
|
|
|
To change the default, set the variable `ediff-window-setup-function',
|
1996-06-22 01:54:34 +00:00
|
|
|
|
which see."
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(interactive)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(let (window-setup-func)
|
|
|
|
|
(or (ediff-window-display-p)
|
|
|
|
|
(error "%sEmacs is not running as a window application"
|
|
|
|
|
(if ediff-emacs-p "" "X")))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(cond ((eq ediff-window-setup-function 'ediff-setup-windows-multiframe)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(setq window-setup-func 'ediff-setup-windows-plain))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
((eq ediff-window-setup-function 'ediff-setup-windows-plain)
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(if (ediff-in-control-buffer-p)
|
|
|
|
|
(ediff-kill-bottom-toolbar))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(setq window-setup-func 'ediff-setup-windows-multiframe)))
|
|
|
|
|
|
|
|
|
|
;; change default
|
|
|
|
|
(setq-default ediff-window-setup-function window-setup-func)
|
|
|
|
|
;; change in all active ediff sessions
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(mapcar (lambda(buf) (ediff-with-current-buffer buf
|
|
|
|
|
(setq ediff-window-setup-function window-setup-func
|
|
|
|
|
ediff-window-B nil)))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
ediff-session-registry)
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(if (ediff-in-control-buffer-p)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(ediff-recenter 'no-rehighlight))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun ediff-toggle-use-toolbar ()
|
|
|
|
|
"Enable or disable Ediff toolbar.
|
|
|
|
|
Works only in versions of Emacs that support toolbars.
|
|
|
|
|
To change the default, set the variable `ediff-use-toolbar-p', which see."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (featurep 'ediff-tbar)
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(progn
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(or (ediff-window-display-p)
|
|
|
|
|
(error "%sEmacs is not running as a window application"
|
|
|
|
|
(if ediff-emacs-p "" "X")))
|
|
|
|
|
(if (ediff-use-toolbar-p)
|
|
|
|
|
(ediff-kill-bottom-toolbar))
|
|
|
|
|
;; do this only after killing the toolbar
|
|
|
|
|
(setq ediff-use-toolbar-p (not ediff-use-toolbar-p))
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(mapcar (lambda(buf)
|
|
|
|
|
(ediff-with-current-buffer buf
|
|
|
|
|
;; force redisplay
|
|
|
|
|
(setq ediff-window-config-saved "")
|
|
|
|
|
))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
ediff-session-registry)
|
|
|
|
|
(if (ediff-in-control-buffer-p)
|
|
|
|
|
(ediff-recenter 'no-rehighlight)))))
|
|
|
|
|
|
1996-12-28 02:53:04 +00:00
|
|
|
|
|
|
|
|
|
;; if was using toolbar, kill it
|
|
|
|
|
(defun ediff-kill-bottom-toolbar ()
|
|
|
|
|
;; Using ctl-buffer or ediff-control-window for LOCALE does not
|
|
|
|
|
;; work properly in XEmacs 19.14: we have to use
|
|
|
|
|
;;(selected-frame).
|
|
|
|
|
;; The problem with this is that any previous bottom-toolbar
|
|
|
|
|
;; will not re-appear after our cleanup here. Is there a way
|
|
|
|
|
;; to do "push" and "pop" toolbars ? --marcpa
|
|
|
|
|
(if (ediff-use-toolbar-p)
|
|
|
|
|
(progn
|
|
|
|
|
(set-specifier bottom-toolbar (list (selected-frame) nil))
|
|
|
|
|
(set-specifier bottom-toolbar-visible-p (list (selected-frame) nil)))))
|
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
;; If wants to use toolbar, make it.
|
|
|
|
|
;; If not, zero the toolbar for XEmacs.
|
|
|
|
|
;; Do nothing for Emacs.
|
|
|
|
|
(defun ediff-make-bottom-toolbar (&optional frame)
|
|
|
|
|
(if (ediff-window-display-p)
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(progn
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(setq frame (or frame (selected-frame)))
|
|
|
|
|
(cond ((ediff-use-toolbar-p) ; this checks for XEmacs
|
|
|
|
|
(set-specifier
|
|
|
|
|
bottom-toolbar
|
|
|
|
|
(list frame (if (ediff-3way-comparison-job)
|
|
|
|
|
ediff-toolbar-3way ediff-toolbar)))
|
|
|
|
|
(set-specifier bottom-toolbar-visible-p (list frame t))
|
|
|
|
|
(set-specifier bottom-toolbar-height
|
|
|
|
|
(list frame ediff-toolbar-height)))
|
1998-05-04 22:42:59 +00:00
|
|
|
|
((ediff-has-toolbar-support-p)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(set-specifier bottom-toolbar-height (list frame 0)))
|
|
|
|
|
))
|
|
|
|
|
))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; Merging
|
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-show-clashes-only ()
|
1999-11-01 07:16:15 +00:00
|
|
|
|
"Toggle the mode that shows only the merge regions where both variants differ from the ancestor."
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (not ediff-merge-with-ancestor-job)
|
|
|
|
|
(error "This command makes sense only when merging with an ancestor"))
|
|
|
|
|
(setq ediff-show-clashes-only (not ediff-show-clashes-only))
|
|
|
|
|
(if ediff-show-clashes-only
|
|
|
|
|
(message "Focus on regions where both buffers differ from the ancestor")
|
|
|
|
|
(message "Canceling focus on regions where changes clash")))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-skip-changed-regions ()
|
|
|
|
|
"Toggle the mode that skips the merge regions that differ from the default."
|
|
|
|
|
(interactive)
|
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
|
|
|
|
(setq ediff-skip-merge-regions-that-differ-from-default
|
|
|
|
|
(not ediff-skip-merge-regions-that-differ-from-default))
|
|
|
|
|
(if ediff-skip-merge-regions-that-differ-from-default
|
|
|
|
|
(message "Skipping regions that differ from default setting")
|
|
|
|
|
(message "Showing regions that differ from default setting")))
|
|
|
|
|
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; Widening/narrowing
|
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-narrow-region ()
|
|
|
|
|
"Toggle narrowing in buffers A, B, and C.
|
|
|
|
|
Used in ediff-windows/regions only."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if (eq ediff-buffer-A ediff-buffer-B)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(error ediff-NO-DIFFERENCES))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (eq ediff-visible-bounds ediff-wide-bounds)
|
|
|
|
|
(setq ediff-visible-bounds ediff-narrow-bounds)
|
|
|
|
|
(setq ediff-visible-bounds ediff-wide-bounds))
|
|
|
|
|
(ediff-recenter 'no-rehighlight))
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; Narrow bufs A/B/C to ediff-visible-bounds. If this is currently set to
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; ediff-wide-bounds, then this actually widens.
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; This function does nothing if job-name is not
|
|
|
|
|
;; ediff-regions-wordwise/linewise or ediff-windows-wordwise/linewise.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; Does nothing if buffer-A = buffer-B since we can't narrow
|
|
|
|
|
;; to two different regions in one buffer.
|
|
|
|
|
(defun ediff-visible-region ()
|
|
|
|
|
(if (or (eq ediff-buffer-A ediff-buffer-B)
|
|
|
|
|
(eq ediff-buffer-A ediff-buffer-C)
|
|
|
|
|
(eq ediff-buffer-C ediff-buffer-B))
|
|
|
|
|
()
|
|
|
|
|
;; If ediff-*-regions/windows, ediff-visible-bounds is already set
|
|
|
|
|
;; Otherwise, always use full range.
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if (not ediff-narrow-job)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq ediff-visible-bounds ediff-wide-bounds))
|
|
|
|
|
(let ((overl-A (ediff-get-value-according-to-buffer-type
|
|
|
|
|
'A ediff-visible-bounds))
|
|
|
|
|
(overl-B (ediff-get-value-according-to-buffer-type
|
|
|
|
|
'B ediff-visible-bounds))
|
|
|
|
|
(overl-C (ediff-get-value-according-to-buffer-type
|
|
|
|
|
'C ediff-visible-bounds))
|
|
|
|
|
)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-A
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(if (ediff-overlay-buffer overl-A)
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-overlay-start overl-A) (ediff-overlay-end overl-A))))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-B
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(if (ediff-overlay-buffer overl-B)
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-overlay-start overl-B) (ediff-overlay-end overl-B))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(if (and ediff-3way-job (ediff-overlay-buffer overl-C))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-overlay-start overl-C) (ediff-overlay-end overl-C))))
|
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Window scrolling operations
|
|
|
|
|
|
|
|
|
|
;; Performs some operation on the two file windows (if they are showing).
|
|
|
|
|
;; Traps all errors on the operation in windows A/B/C.
|
|
|
|
|
;; Usually, errors come from scrolling off the
|
|
|
|
|
;; beginning or end of the buffer, and this gives error messages.
|
|
|
|
|
(defun ediff-operate-on-windows (operation arg)
|
|
|
|
|
|
|
|
|
|
;; make sure windows aren't dead
|
|
|
|
|
(if (not (and (window-live-p ediff-window-A) (window-live-p ediff-window-B)))
|
|
|
|
|
(ediff-recenter 'no-rehighlight))
|
|
|
|
|
(if (not (and (ediff-buffer-live-p ediff-buffer-A)
|
|
|
|
|
(ediff-buffer-live-p ediff-buffer-B)
|
|
|
|
|
(or (not ediff-3way-job) ediff-buffer-C)
|
|
|
|
|
))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(error ediff-KILLED-VITAL-BUFFER))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(let* ((wind (selected-window))
|
|
|
|
|
(wind-A ediff-window-A)
|
|
|
|
|
(wind-B ediff-window-B)
|
|
|
|
|
(wind-C ediff-window-C)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(coefA (ediff-get-region-size-coefficient 'A operation))
|
|
|
|
|
(coefB (ediff-get-region-size-coefficient 'B operation))
|
|
|
|
|
(three-way ediff-3way-job)
|
|
|
|
|
(coefC (if three-way
|
|
|
|
|
(ediff-get-region-size-coefficient 'C operation))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(select-window wind-A)
|
|
|
|
|
(condition-case nil
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(funcall operation (round (* coefA arg)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(error))
|
|
|
|
|
(select-window wind-B)
|
|
|
|
|
(condition-case nil
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(funcall operation (round (* coefB arg)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(error))
|
|
|
|
|
(if three-way
|
|
|
|
|
(progn
|
|
|
|
|
(select-window wind-C)
|
|
|
|
|
(condition-case nil
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(funcall operation (round (* coefC arg)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(error))))
|
|
|
|
|
(select-window wind)))
|
|
|
|
|
|
|
|
|
|
(defun ediff-scroll-vertically (&optional arg)
|
|
|
|
|
"Vertically scroll buffers A, B \(and C if appropriate\).
|
|
|
|
|
With optional argument ARG, scroll ARG lines; otherwise scroll by nearly
|
1996-02-16 06:36:35 +00:00
|
|
|
|
the one half of the height of window-A."
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(interactive "P")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; make sure windows aren't dead
|
|
|
|
|
(if (not (and (window-live-p ediff-window-A) (window-live-p ediff-window-B)))
|
|
|
|
|
(ediff-recenter 'no-rehighlight))
|
|
|
|
|
(if (not (and (ediff-buffer-live-p ediff-buffer-A)
|
|
|
|
|
(ediff-buffer-live-p ediff-buffer-B)
|
|
|
|
|
(or (not ediff-3way-job)
|
|
|
|
|
(ediff-buffer-live-p ediff-buffer-C))
|
|
|
|
|
))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(error ediff-KILLED-VITAL-BUFFER))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(ediff-operate-on-windows
|
|
|
|
|
(if (memq last-command-char '(?v ?\C-v))
|
|
|
|
|
'scroll-up
|
|
|
|
|
'scroll-down)
|
|
|
|
|
;; calculate argument to scroll-up/down
|
|
|
|
|
;; if there is an explicit argument
|
|
|
|
|
(if (and arg (not (equal arg '-)))
|
|
|
|
|
;; use it
|
|
|
|
|
(prefix-numeric-value arg)
|
|
|
|
|
;; if not, see if we can determine a default amount (the window height)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(let (default-amount)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq default-amount
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(- (/ (min (window-height ediff-window-A)
|
|
|
|
|
(window-height ediff-window-B)
|
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(window-height ediff-window-C)
|
|
|
|
|
500)) ; some large number
|
|
|
|
|
2)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
1 next-screen-context-lines))
|
|
|
|
|
;; window found
|
|
|
|
|
(if arg
|
|
|
|
|
;; C-u as argument means half of default amount
|
|
|
|
|
(/ default-amount 2)
|
|
|
|
|
;; no argument means default amount
|
|
|
|
|
default-amount)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-scroll-horizontally (&optional arg)
|
|
|
|
|
"Horizontally scroll buffers A, B \(and C if appropriate\).
|
|
|
|
|
If an argument is given, that is how many columns are scrolled, else nearly
|
|
|
|
|
the width of the A/B/C windows."
|
|
|
|
|
(interactive "P")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; make sure windows aren't dead
|
|
|
|
|
(if (not (and (window-live-p ediff-window-A) (window-live-p ediff-window-B)))
|
|
|
|
|
(ediff-recenter 'no-rehighlight))
|
|
|
|
|
(if (not (and (ediff-buffer-live-p ediff-buffer-A)
|
|
|
|
|
(ediff-buffer-live-p ediff-buffer-B)
|
|
|
|
|
(or (not ediff-3way-job)
|
|
|
|
|
(ediff-buffer-live-p ediff-buffer-C))
|
|
|
|
|
))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(error ediff-KILLED-VITAL-BUFFER))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(ediff-operate-on-windows
|
2001-03-01 14:52:03 +00:00
|
|
|
|
;; Arrange for scroll-left and scroll-right being called
|
|
|
|
|
;; interactively so that they set the window's min_hscroll.
|
|
|
|
|
;; Otherwise, automatic hscrolling will undo the effect of
|
|
|
|
|
;; hscrolling.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (= last-command-char ?<)
|
2001-03-01 14:52:03 +00:00
|
|
|
|
(lambda (arg)
|
|
|
|
|
(let ((prefix-arg arg))
|
|
|
|
|
(call-interactively 'scroll-left)))
|
|
|
|
|
(lambda (arg)
|
|
|
|
|
(let ((prefix-arg arg))
|
|
|
|
|
(call-interactively 'scroll-right))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; calculate argument to scroll-left/right
|
|
|
|
|
;; if there is an explicit argument
|
|
|
|
|
(if (and arg (not (equal arg '-)))
|
|
|
|
|
;; use it
|
|
|
|
|
(prefix-numeric-value arg)
|
|
|
|
|
;; if not, see if we can determine a default amount
|
|
|
|
|
;; (half the window width)
|
|
|
|
|
(if (null ediff-control-window)
|
|
|
|
|
;; no control window, use nil
|
|
|
|
|
nil
|
|
|
|
|
(let ((default-amount
|
|
|
|
|
(- (/ (min (window-width ediff-window-A)
|
|
|
|
|
(window-width ediff-window-B)
|
|
|
|
|
(if ediff-3way-comparison-job
|
|
|
|
|
(window-width ediff-window-C)
|
|
|
|
|
500) ; some large number
|
|
|
|
|
)
|
|
|
|
|
2)
|
|
|
|
|
3)))
|
|
|
|
|
;; window found
|
|
|
|
|
(if arg
|
|
|
|
|
;; C-u as argument means half of default amount
|
|
|
|
|
(/ default-amount 2)
|
|
|
|
|
;; no argument means default amount
|
|
|
|
|
default-amount))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;BEG, END show the region to be positioned.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;;JOB-NAME holds ediff-job-name. The ediff-windows job positions regions
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;;differently.
|
|
|
|
|
(defun ediff-position-region (beg end pos job-name)
|
|
|
|
|
(if (> end (point-max))
|
|
|
|
|
(setq end (point-max)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if ediff-windows-job
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (pos-visible-in-window-p end)
|
|
|
|
|
() ; do nothing, wind is already positioned
|
|
|
|
|
;; at this point, windows are positioned at the beginning of the
|
|
|
|
|
;; file regions (not diff-regions) being compared.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(move-to-window-line (- (window-height) 2))
|
|
|
|
|
(let ((amount (+ 2 (count-lines (point) end))))
|
|
|
|
|
(scroll-up amount))))
|
|
|
|
|
(set-window-start (selected-window) beg)
|
|
|
|
|
(if (pos-visible-in-window-p end)
|
|
|
|
|
;; Determine the number of lines that the region occupies
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let ((lines 0)
|
|
|
|
|
(prev-point 0))
|
|
|
|
|
(while ( and (> end (progn
|
|
|
|
|
(move-to-window-line lines)
|
|
|
|
|
(point)))
|
|
|
|
|
;; `end' may be beyond the window bottom, so check
|
1996-01-05 22:21:28 +00:00
|
|
|
|
;; that we are making progress
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(< prev-point (point)))
|
|
|
|
|
(setq prev-point (point))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq lines (1+ lines)))
|
|
|
|
|
;; And position the beginning on the right line
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(recenter (/ (1+ (max (- (1- (window-height (selected-window)))
|
|
|
|
|
lines)
|
|
|
|
|
1)
|
|
|
|
|
)
|
|
|
|
|
2))))
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
))
|
|
|
|
|
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; get number of lines from window start to region end
|
|
|
|
|
(defun ediff-get-lines-to-region-end (buf-type &optional n ctl-buf)
|
|
|
|
|
(or n (setq n ediff-current-difference))
|
|
|
|
|
(or ctl-buf (setq ctl-buf ediff-control-buffer))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ctl-buf
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(let* ((buf (ediff-get-buffer buf-type))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(wind (eval (ediff-get-symbol-from-alist
|
|
|
|
|
buf-type ediff-window-alist)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(beg (window-start wind))
|
|
|
|
|
(end (ediff-get-diff-posn buf-type 'end))
|
|
|
|
|
lines)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buf
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(if (< beg end)
|
|
|
|
|
(setq lines (count-lines beg end))
|
|
|
|
|
(setq lines 0))
|
|
|
|
|
lines
|
|
|
|
|
))))
|
|
|
|
|
|
1998-05-04 22:42:59 +00:00
|
|
|
|
;; Calculate the number of lines from window end to the start of diff region
|
|
|
|
|
(defun ediff-get-lines-to-region-start (buf-type &optional diff-num ctl-buf)
|
|
|
|
|
(or diff-num (setq diff-num ediff-current-difference))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(or ctl-buf (setq ctl-buf ediff-control-buffer))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ctl-buf
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(let* ((buf (ediff-get-buffer buf-type))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(wind (eval (ediff-get-symbol-from-alist
|
|
|
|
|
buf-type ediff-window-alist)))
|
1998-05-04 22:42:59 +00:00
|
|
|
|
(end (or (window-end wind) (window-end wind t)))
|
|
|
|
|
(beg (ediff-get-diff-posn buf-type 'beg diff-num)))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buf
|
1998-05-04 22:42:59 +00:00
|
|
|
|
(if (< beg end)
|
|
|
|
|
(count-lines (max beg (point-min)) (min end (point-max))) 0))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; region size coefficient is a coefficient by which to adjust scrolling
|
|
|
|
|
;; up/down of the window displaying buffer of type BUFTYPE.
|
|
|
|
|
;; The purpose of this coefficient is to make the windows scroll in sync, so
|
|
|
|
|
;; that it won't happen that one diff region is scrolled off while the other is
|
|
|
|
|
;; still seen.
|
|
|
|
|
;;
|
|
|
|
|
;; If the difference region is invalid, the coefficient is 1
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(defun ediff-get-region-size-coefficient (buf-type op &optional n ctl-buf)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer (or ctl-buf ediff-control-buffer)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(if (ediff-valid-difference-p n)
|
|
|
|
|
(let* ((func (cond ((eq op 'scroll-down)
|
|
|
|
|
'ediff-get-lines-to-region-start)
|
|
|
|
|
((eq op 'scroll-up)
|
|
|
|
|
'ediff-get-lines-to-region-end)
|
|
|
|
|
(t '(lambda (a b c) 0))))
|
|
|
|
|
(max-lines (max (funcall func 'A n ctl-buf)
|
|
|
|
|
(funcall func 'B n ctl-buf)
|
|
|
|
|
(if (ediff-buffer-live-p ediff-buffer-C)
|
|
|
|
|
(funcall func 'C n ctl-buf)
|
|
|
|
|
0))))
|
|
|
|
|
;; this covers the horizontal coefficient as well:
|
|
|
|
|
;; if max-lines = 0 then coef = 1
|
|
|
|
|
(if (> max-lines 0)
|
|
|
|
|
(/ (+ (funcall func buf-type n ctl-buf) 0.0)
|
|
|
|
|
(+ max-lines 0.0))
|
|
|
|
|
1))
|
|
|
|
|
1)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-next-difference (&optional arg)
|
|
|
|
|
"Advance to the next difference.
|
1996-06-22 01:54:34 +00:00
|
|
|
|
With a prefix argument, go forward that many differences."
|
|
|
|
|
(interactive "p")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (< ediff-current-difference ediff-number-of-differences)
|
|
|
|
|
(let ((n (min ediff-number-of-differences
|
1998-08-14 04:12:01 +00:00
|
|
|
|
(+ ediff-current-difference (or arg 1))))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
non-clash-skip skip-changed regexp-skip)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(ediff-visible-region)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(or (>= n ediff-number-of-differences)
|
|
|
|
|
(setq regexp-skip (funcall ediff-skip-diff-region-function n))
|
1997-09-30 01:13:53 +00:00
|
|
|
|
;; this won't exec if regexp-skip is t
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(setq non-clash-skip (ediff-merge-region-is-non-clash n)
|
|
|
|
|
skip-changed
|
|
|
|
|
(ediff-skip-merge-region-if-changed-from-default-p n))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-install-fine-diff-if-necessary n))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; Skip loop
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(while (and (< n ediff-number-of-differences)
|
|
|
|
|
(or
|
|
|
|
|
;; regexp skip
|
|
|
|
|
regexp-skip
|
|
|
|
|
;; skip clashes, if necessary
|
1997-09-30 01:13:53 +00:00
|
|
|
|
non-clash-skip
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; skip processed regions
|
|
|
|
|
skip-changed
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; skip difference regions that differ in white space
|
|
|
|
|
(and ediff-ignore-similar-regions
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(or (eq (ediff-no-fine-diffs-p n) t)
|
|
|
|
|
(and (ediff-merge-job)
|
|
|
|
|
(eq (ediff-no-fine-diffs-p n) 'C)))
|
|
|
|
|
)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq n (1+ n))
|
|
|
|
|
(if (= 0 (mod n 20))
|
|
|
|
|
(message "Skipped over region %d and counting ..." n))
|
|
|
|
|
(or (>= n ediff-number-of-differences)
|
|
|
|
|
(setq regexp-skip (funcall ediff-skip-diff-region-function n))
|
1997-09-30 01:13:53 +00:00
|
|
|
|
;; this won't exec if regexp-skip is t
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(setq non-clash-skip (ediff-merge-region-is-non-clash n)
|
|
|
|
|
skip-changed
|
|
|
|
|
(ediff-skip-merge-region-if-changed-from-default-p n))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-install-fine-diff-if-necessary n))
|
|
|
|
|
)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(message "")
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-unselect-and-select-difference n)
|
|
|
|
|
) ; let
|
|
|
|
|
(ediff-visible-region)
|
|
|
|
|
(error "At end of the difference list")))
|
|
|
|
|
|
|
|
|
|
(defun ediff-previous-difference (&optional arg)
|
|
|
|
|
"Go to the previous difference.
|
|
|
|
|
With a prefix argument, go back that many differences."
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(interactive "p")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (> ediff-current-difference -1)
|
1998-08-14 04:12:01 +00:00
|
|
|
|
(let ((n (max -1 (- ediff-current-difference (or arg 1))))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
non-clash-skip skip-changed regexp-skip)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(ediff-visible-region)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(or (< n 0)
|
|
|
|
|
(setq regexp-skip (funcall ediff-skip-diff-region-function n))
|
1997-09-30 01:13:53 +00:00
|
|
|
|
;; this won't exec if regexp-skip is t
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(setq non-clash-skip (ediff-merge-region-is-non-clash n)
|
|
|
|
|
skip-changed
|
|
|
|
|
(ediff-skip-merge-region-if-changed-from-default-p n))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-install-fine-diff-if-necessary n))
|
|
|
|
|
(while (and (> n -1)
|
|
|
|
|
(or
|
|
|
|
|
;; regexp skip
|
|
|
|
|
regexp-skip
|
|
|
|
|
;; skip clashes, if necessary
|
1997-09-30 01:13:53 +00:00
|
|
|
|
non-clash-skip
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; skipp changed regions
|
|
|
|
|
skip-changed
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; skip difference regions that differ in white space
|
|
|
|
|
(and ediff-ignore-similar-regions
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(or (eq (ediff-no-fine-diffs-p n) t)
|
|
|
|
|
(and (ediff-merge-job)
|
|
|
|
|
(eq (ediff-no-fine-diffs-p n) 'C)))
|
|
|
|
|
)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (= 0 (mod (1+ n) 20))
|
|
|
|
|
(message "Skipped over region %d and counting ..." (1+ n)))
|
|
|
|
|
(setq n (1- n))
|
|
|
|
|
(or (< n 0)
|
|
|
|
|
(setq regexp-skip (funcall ediff-skip-diff-region-function n))
|
1997-09-30 01:13:53 +00:00
|
|
|
|
;; this won't exec if regexp-skip is t
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(setq non-clash-skip (ediff-merge-region-is-non-clash n)
|
|
|
|
|
skip-changed
|
|
|
|
|
(ediff-skip-merge-region-if-changed-from-default-p n))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-install-fine-diff-if-necessary n))
|
|
|
|
|
)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(message "")
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-unselect-and-select-difference n)
|
|
|
|
|
) ; let
|
|
|
|
|
(ediff-visible-region)
|
|
|
|
|
(error "At beginning of the difference list")))
|
|
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; The diff number is as perceived by the user (i.e., 1+ the internal
|
|
|
|
|
;; representation)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(defun ediff-jump-to-difference (difference-number)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
"Go to the difference specified as a prefix argument.
|
|
|
|
|
If the prefix is negative, count differences from the end."
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(interactive "p")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(setq difference-number
|
|
|
|
|
(cond ((< difference-number 0)
|
|
|
|
|
(+ ediff-number-of-differences difference-number))
|
|
|
|
|
((> difference-number 0) (1- difference-number))
|
|
|
|
|
(t -1)))
|
|
|
|
|
;; -1 is allowed by ediff-unselect-and-select-difference --- it is the
|
|
|
|
|
;; position before the first one.
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if (and (>= difference-number -1)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(<= difference-number ediff-number-of-differences))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-unselect-and-select-difference difference-number)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(error ediff-BAD-DIFF-NUMBER
|
|
|
|
|
this-command (1+ difference-number) ediff-number-of-differences)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(defun ediff-jump-to-difference-at-point (arg)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
"Go to difference closest to the point in buffer A, B, or C.
|
1996-06-22 01:54:34 +00:00
|
|
|
|
The buffer depends on last command character \(a, b, or c\) that invoked this
|
1999-11-01 07:16:15 +00:00
|
|
|
|
command. For instance, if the command was `ga' then the point value in buffer
|
|
|
|
|
A is used.
|
1996-06-22 01:54:34 +00:00
|
|
|
|
With a prefix argument, synchronize all files around the current point position
|
|
|
|
|
in the specified buffer."
|
|
|
|
|
(interactive "P")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(let* ((buf-type (ediff-char-to-buftype last-command-char))
|
|
|
|
|
(buffer (ediff-get-buffer buf-type))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(pt (ediff-with-current-buffer buffer (point)))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(diff-no (ediff-diff-at-point buf-type nil (if arg 'after)))
|
|
|
|
|
(past-last-diff (< ediff-number-of-differences diff-no))
|
|
|
|
|
(beg (if past-last-diff
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buffer (point-max))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(ediff-get-diff-posn buf-type 'beg (1- diff-no))))
|
|
|
|
|
ctl-wind wind-A wind-B wind-C
|
|
|
|
|
shift)
|
|
|
|
|
(if past-last-diff
|
|
|
|
|
(ediff-jump-to-difference -1)
|
|
|
|
|
(ediff-jump-to-difference diff-no))
|
|
|
|
|
(setq ctl-wind (selected-window)
|
|
|
|
|
wind-A ediff-window-A
|
|
|
|
|
wind-B ediff-window-B
|
|
|
|
|
wind-C ediff-window-C)
|
|
|
|
|
(if arg
|
|
|
|
|
(progn
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buffer
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(setq shift (- beg pt)))
|
|
|
|
|
(select-window wind-A)
|
|
|
|
|
(if past-last-diff (goto-char (point-max)))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(backward-char shift) ; noerror, if beginning of buffer
|
|
|
|
|
(error))
|
|
|
|
|
(recenter)
|
|
|
|
|
(select-window wind-B)
|
|
|
|
|
(if past-last-diff (goto-char (point-max)))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(backward-char shift) ; noerror, if beginning of buffer
|
|
|
|
|
(error))
|
|
|
|
|
(recenter)
|
|
|
|
|
(if (window-live-p wind-C)
|
|
|
|
|
(progn
|
|
|
|
|
(select-window wind-C)
|
|
|
|
|
(if past-last-diff (goto-char (point-max)))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(backward-char shift) ; noerror, if beginning of buffer
|
|
|
|
|
(error))
|
|
|
|
|
(recenter)
|
|
|
|
|
))
|
|
|
|
|
(select-window ctl-wind)
|
|
|
|
|
))
|
|
|
|
|
))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; find region most related to the current point position (or POS, if given)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; returns diff number as seen by the user (i.e., 1+ the internal
|
|
|
|
|
;; representation)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; The optional argument WHICH-DIFF can be `after' or `before'. If `after',
|
|
|
|
|
;; find the diff after the point. If `before', find the diff before the
|
|
|
|
|
;; point. If the point is inside a diff, return that diff.
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(defun ediff-diff-at-point (buf-type &optional pos which-diff)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let ((buffer (ediff-get-buffer buf-type))
|
|
|
|
|
(ctl-buffer ediff-control-buffer)
|
|
|
|
|
(max-dif-num (1- ediff-number-of-differences))
|
|
|
|
|
(diff-no -1)
|
|
|
|
|
(prev-beg 0)
|
|
|
|
|
(prev-end 0)
|
|
|
|
|
(beg 0)
|
|
|
|
|
(end 0))
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buffer
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq pos (or pos (point)))
|
|
|
|
|
(while (and (or (< pos prev-beg) (> pos beg))
|
|
|
|
|
(< diff-no max-dif-num))
|
|
|
|
|
(setq diff-no (1+ diff-no))
|
|
|
|
|
(setq prev-beg beg
|
|
|
|
|
prev-end end)
|
|
|
|
|
(setq beg (ediff-get-diff-posn buf-type 'beg diff-no ctl-buffer)
|
|
|
|
|
end (ediff-get-diff-posn buf-type 'end diff-no ctl-buffer))
|
|
|
|
|
)
|
|
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; boost diff-no by 1, if past the last diff region
|
|
|
|
|
(if (and (memq which-diff '(after before))
|
|
|
|
|
(> pos beg) (= diff-no max-dif-num))
|
|
|
|
|
(setq diff-no (1+ diff-no)))
|
|
|
|
|
|
|
|
|
|
(cond ((eq which-diff 'after) (1+ diff-no))
|
|
|
|
|
((eq which-diff 'before) diff-no)
|
|
|
|
|
((< (abs (count-lines pos (max 1 prev-end)))
|
|
|
|
|
(abs (count-lines pos (max 1 beg))))
|
|
|
|
|
diff-no) ; choose prev difference
|
|
|
|
|
(t
|
|
|
|
|
(1+ diff-no))) ; choose next difference
|
1995-03-16 22:34:51 +00:00
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Copying diffs.
|
|
|
|
|
|
|
|
|
|
(defun ediff-diff-to-diff (arg &optional keys)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
"Copy buffer-X'th difference region to buffer Y \(X,Y are A, B, or C\).
|
|
|
|
|
If numerical prefix argument, copy the difference specified in the arg.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
Otherwise, copy the difference given by `ediff-current-difference'.
|
|
|
|
|
This command assumes it is bound to a 2-character key sequence, `ab', `ba',
|
|
|
|
|
`ac', etc., which is used to determine the types of buffers to be used for
|
1999-11-01 07:16:15 +00:00
|
|
|
|
copying difference regions. The first character in the sequence specifies
|
1995-03-16 22:34:51 +00:00
|
|
|
|
the source buffer and the second specifies the target.
|
|
|
|
|
|
|
|
|
|
If the second optional argument, a 2-character string, is given, use it to
|
|
|
|
|
determine the source and the target buffers instead of the command keys."
|
|
|
|
|
(interactive "P")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(or keys (setq keys (this-command-keys)))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(if (eq arg '-) (setq arg -1)) ; translate neg arg to -1
|
|
|
|
|
(if (numberp arg) (ediff-jump-to-difference arg))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let* ((key1 (aref keys 0))
|
|
|
|
|
(key2 (aref keys 1))
|
|
|
|
|
(char1 (if (and ediff-xemacs-p (eventp key1)) (event-key key1) key1))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(char2 (if (and ediff-xemacs-p (eventp key1)) (event-key key2) key2))
|
|
|
|
|
ediff-verbose-p)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-copy-diff ediff-current-difference
|
|
|
|
|
(ediff-char-to-buftype char1)
|
|
|
|
|
(ediff-char-to-buftype char2))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; recenter with rehighlighting, but no messages
|
|
|
|
|
(ediff-recenter)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(defun ediff-copy-A-to-B (arg)
|
|
|
|
|
"Copy ARGth difference region from buffer A to B.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
ARG is a prefix argument. If nil, copy the current difference region."
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-diff-to-diff arg "ab"))
|
|
|
|
|
|
|
|
|
|
(defun ediff-copy-B-to-A (arg)
|
|
|
|
|
"Copy ARGth difference region from buffer B to A.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
ARG is a prefix argument. If nil, copy the current difference region."
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-diff-to-diff arg "ba"))
|
|
|
|
|
|
|
|
|
|
(defun ediff-copy-A-to-C (arg)
|
|
|
|
|
"Copy ARGth difference region from buffer A to buffer C.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
ARG is a prefix argument. If nil, copy the current difference region."
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-diff-to-diff arg "ac"))
|
|
|
|
|
|
|
|
|
|
(defun ediff-copy-B-to-C (arg)
|
|
|
|
|
"Copy ARGth difference region from buffer B to buffer C.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
ARG is a prefix argument. If nil, copy the current difference region."
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-diff-to-diff arg "bc"))
|
|
|
|
|
|
|
|
|
|
(defun ediff-copy-C-to-B (arg)
|
|
|
|
|
"Copy ARGth difference region from buffer C to B.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
ARG is a prefix argument. If nil, copy the current difference region."
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-diff-to-diff arg "cb"))
|
|
|
|
|
|
|
|
|
|
(defun ediff-copy-C-to-A (arg)
|
|
|
|
|
"Copy ARGth difference region from buffer C to A.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
ARG is a prefix argument. If nil, copy the current difference region."
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-diff-to-diff arg "ca"))
|
|
|
|
|
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; Copy diff N from FROM-BUF-TYPE \(given as A, B or C\) to TO-BUF-TYPE.
|
|
|
|
|
;; If optional DO-NOT-SAVE is non-nil, do not save the old value of the
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; target diff. This is used in merging, when constructing the merged
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; version.
|
|
|
|
|
(defun ediff-copy-diff (n from-buf-type to-buf-type
|
|
|
|
|
&optional batch-invocation reg-to-copy)
|
|
|
|
|
(let* ((to-buf (ediff-get-buffer to-buf-type))
|
|
|
|
|
;;(from-buf (if (not reg-to-copy) (ediff-get-buffer from-buf-type)))
|
|
|
|
|
(ctrl-buf ediff-control-buffer)
|
|
|
|
|
(saved-p t)
|
|
|
|
|
(three-way ediff-3way-job)
|
|
|
|
|
messg
|
|
|
|
|
ediff-verbose-p
|
|
|
|
|
reg-to-delete reg-to-delete-beg reg-to-delete-end)
|
|
|
|
|
|
|
|
|
|
(setq reg-to-delete-beg
|
|
|
|
|
(ediff-get-diff-posn to-buf-type 'beg n ctrl-buf))
|
|
|
|
|
(setq reg-to-delete-end
|
|
|
|
|
(ediff-get-diff-posn to-buf-type 'end n ctrl-buf))
|
|
|
|
|
|
|
|
|
|
(if reg-to-copy
|
|
|
|
|
(setq from-buf-type nil)
|
|
|
|
|
(setq reg-to-copy (ediff-get-region-contents n from-buf-type ctrl-buf)))
|
|
|
|
|
|
|
|
|
|
(setq reg-to-delete (ediff-get-region-contents
|
|
|
|
|
n to-buf-type ctrl-buf
|
|
|
|
|
reg-to-delete-beg reg-to-delete-end))
|
|
|
|
|
|
|
|
|
|
(if (string= reg-to-delete reg-to-copy)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(setq saved-p nil) ; don't copy identical buffers
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; seems ok to copy
|
|
|
|
|
(if (or batch-invocation (ediff-test-save-region n to-buf-type))
|
|
|
|
|
(condition-case conds
|
|
|
|
|
(progn
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer to-buf
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; to prevent flags from interfering if buffer is writable
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let ((inhibit-read-only (null buffer-read-only)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(goto-char reg-to-delete-end)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(insert reg-to-copy)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (> reg-to-delete-end reg-to-delete-beg)
|
|
|
|
|
(kill-region reg-to-delete-beg reg-to-delete-end))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
(or batch-invocation
|
|
|
|
|
(setq
|
|
|
|
|
messg
|
|
|
|
|
(ediff-save-diff-region n to-buf-type reg-to-delete))))
|
|
|
|
|
(error (message "ediff-copy-diff: %s %s"
|
|
|
|
|
(car conds)
|
|
|
|
|
(mapconcat 'prin1-to-string (cdr conds) " "))
|
|
|
|
|
(beep 1)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(sit-for 2) ; let the user see the error msg
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq saved-p nil)
|
|
|
|
|
)))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
;; adjust state of difference in case 3-way and diff was copied ok
|
|
|
|
|
(if (and saved-p three-way)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-set-state-of-diff-in-all-buffers n ctrl-buf))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(if batch-invocation
|
|
|
|
|
(ediff-clear-fine-differences n)
|
|
|
|
|
;; If diff3 job, we should recompute fine diffs so we clear them
|
|
|
|
|
;; before reinserting flags (and thus before ediff-recenter).
|
|
|
|
|
(if (and saved-p three-way)
|
|
|
|
|
(ediff-clear-fine-differences n))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
|
|
|
|
|
(ediff-refresh-mode-lines)
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; For diff2 jobs, don't recompute fine diffs, since we know there
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; aren't any. So we clear diffs after ediff-recenter.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (and saved-p (not three-way))
|
|
|
|
|
(ediff-clear-fine-differences n))
|
|
|
|
|
;; Make sure that the message about saving and how to restore is seen
|
|
|
|
|
;; by the user
|
|
|
|
|
(message messg))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
;; Save Nth diff of buffer BUF-TYPE \(A, B, or C\).
|
|
|
|
|
;; That is to say, the Nth diff on the `ediff-killed-diffs-alist'. REG
|
|
|
|
|
;; is the region to save. It is redundant here, but is passed anyway, for
|
|
|
|
|
;; convenience.
|
|
|
|
|
(defun ediff-save-diff-region (n buf-type reg)
|
|
|
|
|
(let* ((n-th-diff-saved (assoc n ediff-killed-diffs-alist))
|
|
|
|
|
(buf (ediff-get-buffer buf-type))
|
|
|
|
|
(this-buf-n-th-diff-saved (assoc buf (cdr n-th-diff-saved))))
|
|
|
|
|
|
|
|
|
|
(if this-buf-n-th-diff-saved
|
|
|
|
|
;; either nothing saved for n-th diff and buffer or we OK'ed
|
|
|
|
|
;; overriding
|
|
|
|
|
(setcdr this-buf-n-th-diff-saved reg)
|
|
|
|
|
(if n-th-diff-saved ;; n-th diff saved, but for another buffer
|
|
|
|
|
(nconc n-th-diff-saved (list (cons buf reg)))
|
|
|
|
|
(setq ediff-killed-diffs-alist ;; create record for n-th diff
|
|
|
|
|
(cons (list n (cons buf reg))
|
|
|
|
|
ediff-killed-diffs-alist))))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(message "Saving old diff region #%d of buffer %S. To recover, type `r%s'"
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(1+ n) buf-type
|
|
|
|
|
(if ediff-merge-job
|
|
|
|
|
"" (downcase (symbol-name buf-type))))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
;; Test if saving Nth difference region of buffer BUF-TYPE is possible.
|
|
|
|
|
(defun ediff-test-save-region (n buf-type)
|
|
|
|
|
(let* ((n-th-diff-saved (assoc n ediff-killed-diffs-alist))
|
|
|
|
|
(buf (ediff-get-buffer buf-type))
|
|
|
|
|
(this-buf-n-th-diff-saved (assoc buf (cdr n-th-diff-saved))))
|
|
|
|
|
|
|
|
|
|
(if this-buf-n-th-diff-saved
|
|
|
|
|
(if (yes-or-no-p
|
|
|
|
|
(format
|
1999-11-01 07:16:15 +00:00
|
|
|
|
"You've previously copied diff region %d to buffer %S. Confirm "
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(1+ n) buf-type))
|
|
|
|
|
t
|
|
|
|
|
(error "Quit"))
|
|
|
|
|
t)))
|
|
|
|
|
|
|
|
|
|
(defun ediff-pop-diff (n buf-type)
|
|
|
|
|
"Pop last killed Nth diff region from buffer BUF-TYPE."
|
|
|
|
|
(let* ((n-th-record (assoc n ediff-killed-diffs-alist))
|
|
|
|
|
(buf (ediff-get-buffer buf-type))
|
|
|
|
|
(saved-rec (assoc buf (cdr n-th-record)))
|
|
|
|
|
(three-way ediff-3way-job)
|
|
|
|
|
(ctl-buf ediff-control-buffer)
|
|
|
|
|
ediff-verbose-p
|
|
|
|
|
saved-diff reg-beg reg-end recovered)
|
|
|
|
|
|
|
|
|
|
(if (cdr saved-rec)
|
|
|
|
|
(setq saved-diff (cdr saved-rec))
|
|
|
|
|
(if (> ediff-number-of-differences 0)
|
|
|
|
|
(error "Nothing saved for diff %d in buffer %S" (1+ n) buf-type)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(error ediff-NO-DIFFERENCES)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(setq reg-beg (ediff-get-diff-posn buf-type 'beg n ediff-control-buffer))
|
|
|
|
|
(setq reg-end (ediff-get-diff-posn buf-type 'end n ediff-control-buffer))
|
|
|
|
|
|
|
|
|
|
(condition-case conds
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buf
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let ((inhibit-read-only (null buffer-read-only)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(goto-char reg-end)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(insert saved-diff)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (> reg-end reg-beg)
|
|
|
|
|
(kill-region reg-beg reg-end))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(setq recovered t)
|
|
|
|
|
))
|
|
|
|
|
(error (message "ediff-pop-diff: %s %s"
|
|
|
|
|
(car conds)
|
|
|
|
|
(mapconcat 'prin1-to-string (cdr conds) " "))
|
|
|
|
|
(beep 1)))
|
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; Clearing fine diffs is necessary for
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; ediff-unselect-and-select-difference to properly recompute them. We
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; can't rely on ediff-copy-diff to clear this vector, as the user might
|
|
|
|
|
;; have modified diff regions after copying and, thus, may have recomputed
|
|
|
|
|
;; fine diffs.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if recovered
|
|
|
|
|
(ediff-clear-fine-differences n))
|
|
|
|
|
|
|
|
|
|
;; adjust state of difference
|
|
|
|
|
(if (and three-way recovered)
|
|
|
|
|
(ediff-set-state-of-diff-in-all-buffers n ctl-buf))
|
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-refresh-mode-lines)
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if recovered
|
|
|
|
|
(progn
|
|
|
|
|
(setq n-th-record (delq saved-rec n-th-record))
|
|
|
|
|
(message "Diff region %d in buffer %S restored" (1+ n) buf-type)
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(defun ediff-restore-diff (arg &optional key)
|
|
|
|
|
"Restore ARGth diff from `ediff-killed-diffs-alist'.
|
1996-02-16 06:36:35 +00:00
|
|
|
|
ARG is a prefix argument. If ARG is nil, restore the current-difference.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
If the second optional argument, a character, is given, use it to
|
|
|
|
|
determine the target buffer instead of last-command-char"
|
|
|
|
|
(interactive "P")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (numberp arg)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-jump-to-difference arg))
|
|
|
|
|
(ediff-pop-diff ediff-current-difference
|
|
|
|
|
(ediff-char-to-buftype (or key last-command-char)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;; recenter with rehighlighting, but no messages
|
|
|
|
|
(let (ediff-verbose-p)
|
|
|
|
|
(ediff-recenter)))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-restore-diff-in-merge-buffer (arg)
|
|
|
|
|
"Restore ARGth diff in the merge buffer.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
ARG is a prefix argument. If nil, restore the current diff."
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-restore-diff arg ?c))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-regexp-match ()
|
|
|
|
|
"Toggle between focusing and hiding of difference regions that match
|
|
|
|
|
a regular expression typed in by the user."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let ((regexp-A "")
|
|
|
|
|
(regexp-B "")
|
|
|
|
|
(regexp-C "")
|
|
|
|
|
msg-connective alt-msg-connective alt-connective)
|
|
|
|
|
(cond
|
|
|
|
|
((or (and (eq ediff-skip-diff-region-function
|
1996-06-22 01:54:34 +00:00
|
|
|
|
ediff-focus-on-regexp-matches-function)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(eq last-command-char ?f))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(and (eq ediff-skip-diff-region-function
|
|
|
|
|
ediff-hide-regexp-matches-function)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(eq last-command-char ?h)))
|
|
|
|
|
(message "Selective browsing by regexp turned off")
|
|
|
|
|
(setq ediff-skip-diff-region-function 'ediff-show-all-diffs))
|
|
|
|
|
((eq last-command-char ?h)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq ediff-skip-diff-region-function ediff-hide-regexp-matches-function
|
1995-03-16 22:34:51 +00:00
|
|
|
|
regexp-A
|
|
|
|
|
(read-string
|
|
|
|
|
(format
|
|
|
|
|
"Ignore A-regions matching this regexp (default \"%s\"): "
|
|
|
|
|
ediff-regexp-hide-A))
|
|
|
|
|
regexp-B
|
|
|
|
|
(read-string
|
|
|
|
|
(format
|
|
|
|
|
"Ignore B-regions matching this regexp (default \"%s\"): "
|
|
|
|
|
ediff-regexp-hide-B)))
|
|
|
|
|
(if ediff-3way-comparison-job
|
|
|
|
|
(setq regexp-C
|
|
|
|
|
(read-string
|
|
|
|
|
(format
|
|
|
|
|
"Ignore C-regions matching this regexp (default \"%s\"): "
|
|
|
|
|
ediff-regexp-hide-C))))
|
|
|
|
|
(if (eq ediff-hide-regexp-connective 'and)
|
|
|
|
|
(setq msg-connective "BOTH"
|
|
|
|
|
alt-msg-connective "ONE OF"
|
|
|
|
|
alt-connective 'or)
|
|
|
|
|
(setq msg-connective "ONE OF"
|
|
|
|
|
alt-msg-connective "BOTH"
|
|
|
|
|
alt-connective 'and))
|
|
|
|
|
(if (y-or-n-p
|
|
|
|
|
(format
|
1995-10-06 00:59:04 +00:00
|
|
|
|
"Ignore regions that match %s regexps, OK? "
|
1995-03-16 22:34:51 +00:00
|
|
|
|
msg-connective alt-msg-connective))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(message "Will ignore regions that match %s regexps" msg-connective)
|
|
|
|
|
(setq ediff-hide-regexp-connective alt-connective)
|
|
|
|
|
(message "Will ignore regions that match %s regexps"
|
|
|
|
|
alt-msg-connective))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(or (string= regexp-A "") (setq ediff-regexp-hide-A regexp-A))
|
|
|
|
|
(or (string= regexp-B "") (setq ediff-regexp-hide-B regexp-B))
|
|
|
|
|
(or (string= regexp-C "") (setq ediff-regexp-hide-C regexp-C)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
((eq last-command-char ?f)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq ediff-skip-diff-region-function
|
|
|
|
|
ediff-focus-on-regexp-matches-function
|
1995-03-16 22:34:51 +00:00
|
|
|
|
regexp-A
|
|
|
|
|
(read-string
|
|
|
|
|
(format
|
|
|
|
|
"Focus on A-regions matching this regexp (default \"%s\"): "
|
|
|
|
|
ediff-regexp-focus-A))
|
|
|
|
|
regexp-B
|
|
|
|
|
(read-string
|
|
|
|
|
(format
|
|
|
|
|
"Focus on B-regions matching this regexp (default \"%s\"): "
|
|
|
|
|
ediff-regexp-focus-B)))
|
|
|
|
|
(if ediff-3way-comparison-job
|
|
|
|
|
(setq regexp-C
|
|
|
|
|
(read-string
|
|
|
|
|
(format
|
|
|
|
|
"Focus on C-regions matching this regexp (default \"%s\"): "
|
|
|
|
|
ediff-regexp-focus-C))))
|
|
|
|
|
(if (eq ediff-focus-regexp-connective 'and)
|
|
|
|
|
(setq msg-connective "BOTH"
|
|
|
|
|
alt-msg-connective "ONE OF"
|
|
|
|
|
alt-connective 'or)
|
|
|
|
|
(setq msg-connective "ONE OF"
|
|
|
|
|
alt-msg-connective "BOTH"
|
|
|
|
|
alt-connective 'and))
|
|
|
|
|
(if (y-or-n-p
|
|
|
|
|
(format
|
1995-10-06 00:59:04 +00:00
|
|
|
|
"Focus on regions that match %s regexps, OK? "
|
1995-03-16 22:34:51 +00:00
|
|
|
|
msg-connective alt-msg-connective))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(message "Will focus on regions that match %s regexps"
|
|
|
|
|
msg-connective)
|
|
|
|
|
(setq ediff-focus-regexp-connective alt-connective)
|
|
|
|
|
(message "Will focus on regions that match %s regexps"
|
|
|
|
|
alt-msg-connective))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(or (string= regexp-A "") (setq ediff-regexp-focus-A regexp-A))
|
|
|
|
|
(or (string= regexp-B "") (setq ediff-regexp-focus-B regexp-B))
|
|
|
|
|
(or (string= regexp-C "") (setq ediff-regexp-focus-C regexp-C))))))
|
|
|
|
|
|
|
|
|
|
(defun ediff-toggle-skip-similar ()
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (not (eq ediff-auto-refine 'on))
|
|
|
|
|
(error
|
|
|
|
|
"Can't skip over whitespace regions: first turn auto-refining on"))
|
|
|
|
|
(setq ediff-ignore-similar-regions (not ediff-ignore-similar-regions))
|
|
|
|
|
(if ediff-ignore-similar-regions
|
|
|
|
|
(message
|
|
|
|
|
"Skipping regions that differ only in white space & line breaks")
|
|
|
|
|
(message "Skipping over white-space differences turned off")))
|
|
|
|
|
|
|
|
|
|
(defun ediff-focus-on-regexp-matches (n)
|
|
|
|
|
"Focus on diffs that match regexp `ediff-regexp-focus-A/B'.
|
|
|
|
|
Regions to be ignored according to this function are those where
|
|
|
|
|
buf A region doesn't match `ediff-regexp-focus-A' and buf B region
|
|
|
|
|
doesn't match `ediff-regexp-focus-B'.
|
|
|
|
|
This function returns nil if the region number N (specified as
|
|
|
|
|
an argument) is not to be ignored and t if region N is to be ignored.
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
N is a region number used by Ediff internally. It is 1 less
|
1995-03-16 22:34:51 +00:00
|
|
|
|
the number seen by the user."
|
|
|
|
|
(if (ediff-valid-difference-p n)
|
|
|
|
|
(let* ((ctl-buf ediff-control-buffer)
|
|
|
|
|
(regex-A ediff-regexp-focus-A)
|
|
|
|
|
(regex-B ediff-regexp-focus-B)
|
|
|
|
|
(regex-C ediff-regexp-focus-C)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(reg-A-match (ediff-with-current-buffer ediff-buffer-A
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-get-diff-posn 'A 'beg n ctl-buf)
|
|
|
|
|
(ediff-get-diff-posn 'A 'end n ctl-buf))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(re-search-forward regex-A nil t))))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(reg-B-match (ediff-with-current-buffer ediff-buffer-B
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-get-diff-posn 'B 'beg n ctl-buf)
|
|
|
|
|
(ediff-get-diff-posn 'B 'end n ctl-buf))
|
|
|
|
|
(re-search-forward regex-B nil t))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(reg-C-match (if ediff-3way-comparison-job
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-get-diff-posn 'C 'beg n ctl-buf)
|
|
|
|
|
(ediff-get-diff-posn 'C 'end n ctl-buf))
|
|
|
|
|
(re-search-forward regex-C nil t))))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(not (eval (if ediff-3way-comparison-job
|
|
|
|
|
(list ediff-focus-regexp-connective
|
|
|
|
|
reg-A-match reg-B-match reg-C-match)
|
|
|
|
|
(list ediff-focus-regexp-connective
|
|
|
|
|
reg-A-match reg-B-match))))
|
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
(defun ediff-hide-regexp-matches (n)
|
|
|
|
|
"Hide diffs that match regexp `ediff-regexp-hide-A/B/C'.
|
|
|
|
|
Regions to be ignored are those where buf A region matches
|
|
|
|
|
`ediff-regexp-hide-A' and buf B region matches `ediff-regexp-hide-B'.
|
|
|
|
|
This function returns nil if the region number N (specified as
|
|
|
|
|
an argument) is not to be ignored and t if region N is to be ignored.
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
N is a region number used by Ediff internally. It is 1 less
|
1995-03-16 22:34:51 +00:00
|
|
|
|
the number seen by the user."
|
|
|
|
|
(if (ediff-valid-difference-p n)
|
|
|
|
|
(let* ((ctl-buf ediff-control-buffer)
|
|
|
|
|
(regex-A ediff-regexp-hide-A)
|
|
|
|
|
(regex-B ediff-regexp-hide-B)
|
|
|
|
|
(regex-C ediff-regexp-hide-C)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(reg-A-match (ediff-with-current-buffer ediff-buffer-A
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-get-diff-posn 'A 'beg n ctl-buf)
|
|
|
|
|
(ediff-get-diff-posn 'A 'end n ctl-buf))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(re-search-forward regex-A nil t))))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(reg-B-match (ediff-with-current-buffer ediff-buffer-B
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-get-diff-posn 'B 'beg n ctl-buf)
|
|
|
|
|
(ediff-get-diff-posn 'B 'end n ctl-buf))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(re-search-forward regex-B nil t))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(reg-C-match (if ediff-3way-comparison-job
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region
|
|
|
|
|
(ediff-get-diff-posn 'C 'beg n ctl-buf)
|
|
|
|
|
(ediff-get-diff-posn 'C 'end n ctl-buf))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(re-search-forward regex-C nil t))))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(eval (if ediff-3way-comparison-job
|
|
|
|
|
(list ediff-hide-regexp-connective
|
|
|
|
|
reg-A-match reg-B-match reg-C-match)
|
|
|
|
|
(list ediff-hide-regexp-connective reg-A-match reg-B-match)))
|
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Quitting, suspending, etc.
|
|
|
|
|
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(defun ediff-quit (reverse-default-keep-variants)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
"Finish an Ediff session and exit Ediff.
|
|
|
|
|
Unselects the selected difference, if any, restores the read-only and modified
|
|
|
|
|
flags of the compared file buffers, kills Ediff buffers for this session
|
1995-10-06 00:59:04 +00:00
|
|
|
|
\(but not buffers A, B, C\).
|
|
|
|
|
|
|
|
|
|
If `ediff-keep-variants' is nil, the user will be asked whether the buffers
|
|
|
|
|
containing the variants should be removed \(if they haven't been modified\).
|
1999-11-01 07:16:15 +00:00
|
|
|
|
If it is t, they will be preserved unconditionally. A prefix argument,
|
1995-10-06 00:59:04 +00:00
|
|
|
|
temporarily reverses the meaning of this variable."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(let ((ctl-buf (current-buffer)))
|
|
|
|
|
(if (y-or-n-p (format "Quit this Ediff session%s? "
|
|
|
|
|
(if (ediff-buffer-live-p ediff-meta-buffer)
|
|
|
|
|
" & show containing session group" "")))
|
|
|
|
|
(progn
|
|
|
|
|
(message "")
|
|
|
|
|
(set-buffer ctl-buf)
|
|
|
|
|
(ediff-really-quit reverse-default-keep-variants))
|
|
|
|
|
(message ""))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Perform the quit operations.
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(defun ediff-really-quit (reverse-default-keep-variants)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-unhighlight-diffs-totally)
|
|
|
|
|
(ediff-clear-diff-vector 'ediff-difference-vector-A 'fine-diffs-also)
|
|
|
|
|
(ediff-clear-diff-vector 'ediff-difference-vector-B 'fine-diffs-also)
|
|
|
|
|
(ediff-clear-diff-vector 'ediff-difference-vector-C 'fine-diffs-also)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-clear-diff-vector 'ediff-difference-vector-Ancestor 'fine-diffs-also)
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-delete-temp-files)
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; Restore visibility range. This affects only ediff-*-regions/windows.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; Since for other job names ediff-visible-region sets
|
|
|
|
|
;; ediff-visible-bounds to ediff-wide-bounds, the settings below are
|
|
|
|
|
;; ignored for such jobs.
|
|
|
|
|
(if ediff-quit-widened
|
|
|
|
|
(setq ediff-visible-bounds ediff-wide-bounds)
|
|
|
|
|
(setq ediff-visible-bounds ediff-narrow-bounds))
|
|
|
|
|
|
|
|
|
|
;; Apply selective display to narrow or widen
|
|
|
|
|
(ediff-visible-region)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(mapcar (lambda (overl)
|
|
|
|
|
(if (ediff-overlayp overl)
|
|
|
|
|
(ediff-delete-overlay overl)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
ediff-wide-bounds)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(mapcar (lambda (overl)
|
|
|
|
|
(if (ediff-overlayp overl)
|
|
|
|
|
(ediff-delete-overlay overl)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
ediff-narrow-bounds)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; restore buffer mode line id's in buffer-A/B/C
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(let ((control-buffer ediff-control-buffer)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(meta-buffer ediff-meta-buffer)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(after-quit-hook-internal ediff-after-quit-hook-internal)
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(session-number ediff-meta-session-number)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
;; suitable working frame
|
|
|
|
|
(warp-frame (if (and (ediff-window-display-p) (eq ediff-grab-mouse t))
|
|
|
|
|
(cond ((window-live-p ediff-window-A)
|
|
|
|
|
(window-frame ediff-window-A))
|
|
|
|
|
((window-live-p ediff-window-B)
|
|
|
|
|
(window-frame ediff-window-B))
|
|
|
|
|
(t (next-frame))))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(condition-case nil
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-A
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq ediff-this-buffer-ediff-sessions
|
|
|
|
|
(delq control-buffer ediff-this-buffer-ediff-sessions))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(kill-local-variable 'mode-line-buffer-identification)
|
|
|
|
|
(kill-local-variable 'mode-line-format)
|
|
|
|
|
)
|
|
|
|
|
(error))
|
|
|
|
|
|
|
|
|
|
(condition-case nil
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-B
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq ediff-this-buffer-ediff-sessions
|
|
|
|
|
(delq control-buffer ediff-this-buffer-ediff-sessions))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(kill-local-variable 'mode-line-buffer-identification)
|
|
|
|
|
(kill-local-variable 'mode-line-format)
|
|
|
|
|
)
|
|
|
|
|
(error))
|
|
|
|
|
|
|
|
|
|
(condition-case nil
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq ediff-this-buffer-ediff-sessions
|
|
|
|
|
(delq control-buffer ediff-this-buffer-ediff-sessions))
|
|
|
|
|
(kill-local-variable 'mode-line-buffer-identification)
|
|
|
|
|
(kill-local-variable 'mode-line-format)
|
|
|
|
|
)
|
|
|
|
|
(error))
|
|
|
|
|
|
|
|
|
|
(condition-case nil
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-ancestor-buffer
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(setq ediff-this-buffer-ediff-sessions
|
|
|
|
|
(delq control-buffer ediff-this-buffer-ediff-sessions))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(kill-local-variable 'mode-line-buffer-identification)
|
|
|
|
|
(kill-local-variable 'mode-line-format)
|
|
|
|
|
)
|
|
|
|
|
(error))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
|
|
|
|
(setq ediff-session-registry
|
|
|
|
|
(delq ediff-control-buffer ediff-session-registry))
|
|
|
|
|
(ediff-update-registry)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; restore state of buffers to what it was before ediff
|
|
|
|
|
(ediff-restore-protected-variables)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
|
|
|
|
|
;; If the user interrupts (canceling saving the merge buffer), continue
|
|
|
|
|
;; normally.
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(if (ediff-merge-job)
|
|
|
|
|
(run-hooks 'ediff-quit-merge-hook))
|
|
|
|
|
(quit))
|
|
|
|
|
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-cleanup-hook)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
|
|
|
|
|
;; now kill buffers A/B/C, if requested
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(let ((ediff-keep-variants ediff-keep-variants))
|
|
|
|
|
(if reverse-default-keep-variants
|
|
|
|
|
(setq ediff-keep-variants (not ediff-keep-variants)))
|
|
|
|
|
(or ediff-keep-variants (ediff-janitor 'ask)))
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; one hook here is ediff-cleanup-mess, which kills the control buffer and
|
|
|
|
|
;; other auxiliary buffers. we made it into a hook to let the users do their
|
|
|
|
|
;; own cleanup, if needed.
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-quit-hook)
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(ediff-update-meta-buffer meta-buffer nil session-number)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
|
|
|
|
|
;; warp mouse into a working window
|
|
|
|
|
(setq warp-frame ; if mouse is over a reasonable frame, use it
|
1997-09-11 16:08:19 +00:00
|
|
|
|
(cond ((ediff-good-frame-under-mouse))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(t warp-frame)))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(if (and (ediff-window-display-p) (frame-live-p warp-frame) ediff-grab-mouse)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(set-mouse-position (if ediff-emacs-p
|
|
|
|
|
warp-frame
|
|
|
|
|
(frame-selected-window warp-frame))
|
|
|
|
|
2 1))
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(run-hooks 'after-quit-hook-internal)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
))
|
1997-09-11 16:08:19 +00:00
|
|
|
|
|
|
|
|
|
;; Returns frame under mouse, if this frame is not a minibuffer
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; frame. Otherwise: nil
|
1997-09-11 16:08:19 +00:00
|
|
|
|
(defun ediff-good-frame-under-mouse ()
|
|
|
|
|
(let ((frame-or-win (car (mouse-position)))
|
|
|
|
|
(buf-name "")
|
|
|
|
|
frame obj-ok)
|
|
|
|
|
(setq obj-ok
|
|
|
|
|
(if ediff-emacs-p
|
|
|
|
|
(frame-live-p frame-or-win)
|
|
|
|
|
(window-live-p frame-or-win)))
|
|
|
|
|
(if obj-ok
|
|
|
|
|
(setq frame (if ediff-emacs-p frame-or-win (window-frame frame-or-win))
|
|
|
|
|
buf-name
|
|
|
|
|
(buffer-name (window-buffer (frame-selected-window frame)))))
|
|
|
|
|
(if (string-match "Minibuf" buf-name)
|
|
|
|
|
nil
|
|
|
|
|
frame)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-delete-temp-files ()
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(if (and (stringp ediff-temp-file-A) (file-exists-p ediff-temp-file-A))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(delete-file ediff-temp-file-A))
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(if (and (stringp ediff-temp-file-B) (file-exists-p ediff-temp-file-B))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(delete-file ediff-temp-file-B))
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(if (and (stringp ediff-temp-file-C) (file-exists-p ediff-temp-file-C))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(delete-file ediff-temp-file-C)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Kill control buffer, other auxiliary Ediff buffers.
|
|
|
|
|
;; Leave one of the frames split between buffers A/B/C
|
|
|
|
|
(defun ediff-cleanup-mess ()
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(let* ((buff-A ediff-buffer-A)
|
|
|
|
|
(buff-B ediff-buffer-B)
|
|
|
|
|
(buff-C ediff-buffer-C)
|
|
|
|
|
(ctl-buf ediff-control-buffer)
|
|
|
|
|
(ctl-frame ediff-control-frame)
|
|
|
|
|
(three-way-job ediff-3way-job)
|
|
|
|
|
(main-frame (cond ((window-live-p ediff-window-A)
|
|
|
|
|
(window-frame ediff-window-A))
|
|
|
|
|
((window-live-p ediff-window-B)
|
|
|
|
|
(window-frame ediff-window-B)))))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-kill-buffer-carefully ediff-diff-buffer)
|
|
|
|
|
(ediff-kill-buffer-carefully ediff-custom-diff-buffer)
|
|
|
|
|
(ediff-kill-buffer-carefully ediff-fine-diff-buffer)
|
|
|
|
|
(ediff-kill-buffer-carefully ediff-tmp-buffer)
|
|
|
|
|
(ediff-kill-buffer-carefully ediff-error-buffer)
|
|
|
|
|
(ediff-kill-buffer-carefully ediff-msg-buffer)
|
|
|
|
|
(ediff-kill-buffer-carefully ediff-debug-buffer)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(if (boundp 'ediff-patch-diagnostics)
|
|
|
|
|
(ediff-kill-buffer-carefully ediff-patch-diagnostics))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if (and (ediff-window-display-p) (frame-live-p ctl-frame))
|
|
|
|
|
(delete-frame ctl-frame))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
;; Hide bottom toolbar. --marcpa
|
|
|
|
|
(if (not (ediff-multiframe-setup-p))
|
|
|
|
|
(ediff-kill-bottom-toolbar))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-kill-buffer-carefully ctl-buf)
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(if (frame-live-p main-frame)
|
|
|
|
|
(progn
|
|
|
|
|
(select-frame main-frame)
|
|
|
|
|
(delete-other-windows)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; display only if not visible
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(or (ediff-get-visible-buffer-window buff-B)
|
|
|
|
|
(switch-to-buffer buff-B))
|
|
|
|
|
(error))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(or (ediff-get-visible-buffer-window buff-A)
|
|
|
|
|
(progn
|
|
|
|
|
(if (ediff-get-visible-buffer-window buff-B)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(funcall ediff-split-window-function))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(switch-to-buffer buff-A)))
|
|
|
|
|
(error))
|
|
|
|
|
(if three-way-job
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(or (ediff-get-visible-buffer-window buff-C)
|
|
|
|
|
(progn
|
|
|
|
|
(if (or (ediff-get-visible-buffer-window buff-A)
|
|
|
|
|
(ediff-get-visible-buffer-window buff-B))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(funcall ediff-split-window-function))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(switch-to-buffer buff-C)
|
|
|
|
|
(balance-windows)))
|
|
|
|
|
(error)))
|
|
|
|
|
(message "")
|
|
|
|
|
))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(defun ediff-janitor (&optional ask)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
"Kill buffers A, B, and, possibly, C, if these buffers aren't modified.
|
|
|
|
|
In merge jobs, buffer C is never deleted.
|
|
|
|
|
However, the side effect of cleaning up may be that you cannot compare the same
|
|
|
|
|
buffer in two separate Ediff sessions: quitting one of them will delete this
|
|
|
|
|
buffer in another session as well."
|
|
|
|
|
(or (not (ediff-buffer-live-p ediff-buffer-A))
|
|
|
|
|
(buffer-modified-p ediff-buffer-A)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(and ask
|
|
|
|
|
(not (y-or-n-p (format "Kill buffer A [%s]? "
|
|
|
|
|
(buffer-name ediff-buffer-A)))))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-kill-buffer-carefully ediff-buffer-A))
|
|
|
|
|
(or (not (ediff-buffer-live-p ediff-buffer-B))
|
|
|
|
|
(buffer-modified-p ediff-buffer-B)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(and ask
|
|
|
|
|
(not (y-or-n-p (format "Kill buffer B [%s]? "
|
|
|
|
|
(buffer-name ediff-buffer-B)))))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-kill-buffer-carefully ediff-buffer-B))
|
|
|
|
|
(if ediff-merge-job ; don't del buf C if merging--del ancestor buf instead
|
|
|
|
|
(or (not (ediff-buffer-live-p ediff-ancestor-buffer))
|
|
|
|
|
(buffer-modified-p ediff-ancestor-buffer)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(and ask
|
|
|
|
|
(not (y-or-n-p (format "Kill the ancestor buffer [%s]? "
|
|
|
|
|
(buffer-name ediff-ancestor-buffer)))))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-kill-buffer-carefully ediff-ancestor-buffer))
|
|
|
|
|
(or (not (ediff-buffer-live-p ediff-buffer-C))
|
|
|
|
|
(buffer-modified-p ediff-buffer-C)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(and ask (not (y-or-n-p (format "Kill buffer C [%s]? "
|
|
|
|
|
(buffer-name ediff-buffer-C)))))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-kill-buffer-carefully ediff-buffer-C))))
|
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(defun ediff-maybe-save-and-delete-merge (&optional save-and-continue)
|
1996-09-20 01:10:05 +00:00
|
|
|
|
"Default hook to run on quitting a merge job.
|
1997-05-31 01:10:39 +00:00
|
|
|
|
This can also be used to save merge buffer in the middle of an Ediff session.
|
|
|
|
|
|
|
|
|
|
If the optional SAVE-AND-CONTINUE argument is non-nil, save merge buffer and
|
1999-11-01 07:16:15 +00:00
|
|
|
|
continue. Otherwise:
|
1996-09-20 01:10:05 +00:00
|
|
|
|
If `ediff-autostore-merges' is nil, this does nothing.
|
|
|
|
|
If it is t, it saves the merge buffer in the file `ediff-merge-store-file'
|
1999-11-01 07:16:15 +00:00
|
|
|
|
or asks the user, if the latter is nil. It then asks the user whether to
|
1996-09-20 01:10:05 +00:00
|
|
|
|
delete the merge buffer.
|
|
|
|
|
If `ediff-autostore-merges' is neither nil nor t, the merge buffer is saved
|
|
|
|
|
only if this merge job is part of a group, i.e., was invoked from within
|
|
|
|
|
`ediff-merge-directories', `ediff-merge-directory-revisions', and such."
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(let ((merge-store-file ediff-merge-store-file)
|
|
|
|
|
(ediff-autostore-merges ; fake ediff-autostore-merges, if necessary
|
|
|
|
|
(if save-and-continue t ediff-autostore-merges)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(if ediff-autostore-merges
|
|
|
|
|
(cond ((stringp ediff-merge-store-file)
|
|
|
|
|
;; store, ask to delete
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(ediff-write-merge-buffer-and-maybe-kill
|
|
|
|
|
ediff-buffer-C merge-store-file 'show-file save-and-continue))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
((eq ediff-autostore-merges t)
|
|
|
|
|
;; ask for file name
|
|
|
|
|
(setq merge-store-file
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(read-file-name "Save the merge buffer in file: "))
|
|
|
|
|
(ediff-write-merge-buffer-and-maybe-kill
|
|
|
|
|
ediff-buffer-C merge-store-file nil save-and-continue))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
((and (ediff-buffer-live-p ediff-meta-buffer)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-meta-buffer
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(ediff-merge-metajob)))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; The parent metajob passed nil as the autostore file.
|
|
|
|
|
nil)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
))
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; write merge buffer. If the optional argument save-and-continue is non-nil,
|
1997-05-31 01:10:39 +00:00
|
|
|
|
;; then don't kill the merge buffer
|
|
|
|
|
(defun ediff-write-merge-buffer-and-maybe-kill (buf file
|
|
|
|
|
&optional
|
|
|
|
|
show-file save-and-continue)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buf
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(if (or (not (file-exists-p file))
|
|
|
|
|
(y-or-n-p (format "File %s exists, overwrite? " file)))
|
|
|
|
|
(progn
|
|
|
|
|
(write-region (point-min) (point-max) file)
|
|
|
|
|
(if show-file
|
|
|
|
|
(progn
|
|
|
|
|
(message "Merge buffer saved in: %s" file)
|
1997-11-01 01:46:51 +00:00
|
|
|
|
(set-buffer-modified-p nil)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(sit-for 3)))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(if (and
|
|
|
|
|
(not save-and-continue)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(y-or-n-p "Merge buffer saved. Now kill the buffer? "))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(ediff-kill-buffer-carefully buf))))))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; The default way of suspending Ediff.
|
|
|
|
|
;; Buries Ediff buffers, kills all windows.
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(defun ediff-default-suspend-function ()
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let* ((buf-A ediff-buffer-A)
|
|
|
|
|
(buf-B ediff-buffer-B)
|
|
|
|
|
(buf-C ediff-buffer-C)
|
|
|
|
|
(buf-A-wind (ediff-get-visible-buffer-window buf-A))
|
|
|
|
|
(buf-B-wind (ediff-get-visible-buffer-window buf-B))
|
|
|
|
|
(buf-C-wind (ediff-get-visible-buffer-window buf-C))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(buf-patch (if (boundp 'ediff-patchbufer) ediff-patchbufer nil))
|
|
|
|
|
(buf-patch-diag (if (boundp 'ediff-patch-diagnostics)
|
|
|
|
|
ediff-patch-diagnostics nil))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(buf-err ediff-error-buffer)
|
|
|
|
|
(buf-diff ediff-diff-buffer)
|
|
|
|
|
(buf-custom-diff ediff-custom-diff-buffer)
|
|
|
|
|
(buf-fine-diff ediff-fine-diff-buffer))
|
|
|
|
|
|
|
|
|
|
;; hide the control panel
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
|
|
|
|
|
(iconify-frame ediff-control-frame)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(bury-buffer))
|
|
|
|
|
(if buf-err (bury-buffer buf-err))
|
|
|
|
|
(if buf-diff (bury-buffer buf-diff))
|
|
|
|
|
(if buf-custom-diff (bury-buffer buf-custom-diff))
|
|
|
|
|
(if buf-fine-diff (bury-buffer buf-fine-diff))
|
|
|
|
|
(if buf-patch (bury-buffer buf-patch))
|
|
|
|
|
(if buf-patch-diag (bury-buffer buf-patch-diag))
|
|
|
|
|
(if (window-live-p buf-A-wind)
|
|
|
|
|
(progn
|
|
|
|
|
(select-window buf-A-wind)
|
|
|
|
|
(delete-other-windows)
|
|
|
|
|
(bury-buffer))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(if (ediff-buffer-live-p buf-A)
|
|
|
|
|
(progn
|
|
|
|
|
(set-buffer buf-A)
|
|
|
|
|
(bury-buffer))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (window-live-p buf-B-wind)
|
|
|
|
|
(progn
|
|
|
|
|
(select-window buf-B-wind)
|
|
|
|
|
(delete-other-windows)
|
|
|
|
|
(bury-buffer))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(if (ediff-buffer-live-p buf-B)
|
|
|
|
|
(progn
|
|
|
|
|
(set-buffer buf-B)
|
|
|
|
|
(bury-buffer))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (window-live-p buf-C-wind)
|
|
|
|
|
(progn
|
|
|
|
|
(select-window buf-C-wind)
|
|
|
|
|
(delete-other-windows)
|
|
|
|
|
(bury-buffer))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(if (ediff-buffer-live-p buf-C)
|
|
|
|
|
(progn
|
|
|
|
|
(set-buffer buf-C)
|
|
|
|
|
(bury-buffer))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-suspend ()
|
|
|
|
|
"Suspend Ediff.
|
|
|
|
|
To resume, switch to the appropriate `Ediff Control Panel'
|
|
|
|
|
buffer and then type \\[ediff-recenter]. Ediff will automatically set
|
|
|
|
|
up an appropriate window config."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
|
|
|
|
(run-hooks 'ediff-suspend-hook)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(message
|
1995-10-06 00:59:04 +00:00
|
|
|
|
"To resume, type M-x eregistry and select the desired Ediff session"))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-status-info ()
|
|
|
|
|
"Show the names of the buffers or files being operated on by Ediff.
|
|
|
|
|
Hit \\[ediff-recenter] to reset the windows afterward."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(ediff-skip-unsuitable-frames))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(with-output-to-temp-buffer ediff-msg-buffer
|
2000-11-10 22:35:35 +00:00
|
|
|
|
(ediff-with-current-buffer standard-output
|
|
|
|
|
(fundamental-mode))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(raise-frame (selected-frame))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(princ (ediff-version))
|
|
|
|
|
(princ "\n\n")
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-A
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if buffer-file-name
|
|
|
|
|
(princ
|
|
|
|
|
(format "File A = %S\n" buffer-file-name))
|
|
|
|
|
(princ
|
|
|
|
|
(format "Buffer A = %S\n" (buffer-name)))))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-B
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if buffer-file-name
|
|
|
|
|
(princ
|
|
|
|
|
(format "File B = %S\n" buffer-file-name))
|
|
|
|
|
(princ
|
|
|
|
|
(format "Buffer B = %S\n" (buffer-name)))))
|
|
|
|
|
(if ediff-3way-job
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if buffer-file-name
|
|
|
|
|
(princ
|
|
|
|
|
(format "File C = %S\n" buffer-file-name))
|
|
|
|
|
(princ
|
|
|
|
|
(format "Buffer C = %S\n" (buffer-name))))))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(princ (format "Customized diff output %s\n"
|
|
|
|
|
(if (ediff-buffer-live-p ediff-custom-diff-buffer)
|
|
|
|
|
(concat "\tin buffer "
|
|
|
|
|
(buffer-name ediff-custom-diff-buffer))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
" is not available")))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(princ (format "Plain diff output %s\n"
|
|
|
|
|
(if (ediff-buffer-live-p ediff-diff-buffer)
|
|
|
|
|
(concat "\tin buffer "
|
|
|
|
|
(buffer-name ediff-diff-buffer))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
" is not available")))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(let* ((A-line (ediff-with-current-buffer ediff-buffer-A
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(1+ (count-lines (point-min) (point)))))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(B-line (ediff-with-current-buffer ediff-buffer-B
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(1+ (count-lines (point-min) (point)))))
|
|
|
|
|
C-line)
|
|
|
|
|
(princ (format "\Buffer A's point is on line %d\n" A-line))
|
|
|
|
|
(princ (format "Buffer B's point is on line %d\n" B-line))
|
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(progn
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(setq C-line (ediff-with-current-buffer ediff-buffer-C
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(1+ (count-lines (point-min) (point)))))
|
|
|
|
|
(princ (format "Buffer C's point is on line %d\n" C-line)))))
|
|
|
|
|
|
|
|
|
|
(princ (format "\nCurrent difference number = %S\n"
|
|
|
|
|
(cond ((< ediff-current-difference 0) 'start)
|
|
|
|
|
((>= ediff-current-difference
|
|
|
|
|
ediff-number-of-differences) 'end)
|
|
|
|
|
(t (1+ ediff-current-difference)))))
|
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(princ
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(format "\n%s regions that differ in white space & line breaks only"
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if ediff-ignore-similar-regions
|
1997-05-31 01:10:39 +00:00
|
|
|
|
"Ignoring" "Showing")))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (and ediff-merge-job ediff-show-clashes-only)
|
|
|
|
|
(princ
|
|
|
|
|
"\nFocusing on regions where both buffers differ from the ancestor"))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(if (and ediff-skip-merge-regions-that-differ-from-default ediff-merge-job)
|
|
|
|
|
(princ
|
|
|
|
|
"\nSkipping merge regions that differ from default setting"))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(cond ((eq ediff-skip-diff-region-function 'ediff-show-all-diffs)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(princ "\nSelective browsing by regexp is off\n"))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
((eq ediff-skip-diff-region-function
|
|
|
|
|
ediff-hide-regexp-matches-function)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(princ
|
|
|
|
|
"\nIgnoring regions that match")
|
|
|
|
|
(princ
|
|
|
|
|
(format
|
|
|
|
|
"\n\t regexp `%s' in buffer A %S\n\t regexp `%s' in buffer B\n"
|
|
|
|
|
ediff-regexp-hide-A ediff-hide-regexp-connective
|
|
|
|
|
ediff-regexp-hide-B)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
((eq ediff-skip-diff-region-function
|
|
|
|
|
ediff-focus-on-regexp-matches-function)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(princ
|
|
|
|
|
"\nFocusing on regions that match")
|
|
|
|
|
(princ
|
|
|
|
|
(format
|
|
|
|
|
"\n\t regexp `%s' in buffer A %S\n\t regexp `%s' in buffer B\n"
|
|
|
|
|
ediff-regexp-focus-A ediff-focus-regexp-connective
|
|
|
|
|
ediff-regexp-focus-B)))
|
|
|
|
|
(t (princ "\nSelective browsing via a user-defined method.\n")))
|
|
|
|
|
|
|
|
|
|
(princ
|
|
|
|
|
(format "\nBugs/suggestions: type `%s' while in Ediff Control Panel."
|
|
|
|
|
(substitute-command-keys "\\[ediff-submit-report]")))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
) ; with output
|
|
|
|
|
(if (frame-live-p ediff-control-frame)
|
|
|
|
|
(ediff-reset-mouse ediff-control-frame))
|
|
|
|
|
(if (window-live-p ediff-control-window)
|
|
|
|
|
(select-window ediff-control-window)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Support routines
|
|
|
|
|
|
|
|
|
|
;; Select a difference by placing the ASCII flags around the appropriate
|
|
|
|
|
;; group of lines in the A, B buffers
|
|
|
|
|
;; This may have to be modified for buffer C, when it will be supported.
|
|
|
|
|
(defun ediff-select-difference (n)
|
|
|
|
|
(if (and (ediff-buffer-live-p ediff-buffer-A)
|
|
|
|
|
(ediff-buffer-live-p ediff-buffer-B)
|
|
|
|
|
(ediff-valid-difference-p n))
|
|
|
|
|
(progn
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(if (and (ediff-has-face-support-p) ediff-use-faces)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(progn
|
|
|
|
|
(ediff-highlight-diff n)
|
|
|
|
|
(setq ediff-highlighting-style 'face))
|
|
|
|
|
(setq ediff-highlighting-style 'ascii)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-place-flags-in-buffer
|
|
|
|
|
'A ediff-buffer-A ediff-control-buffer n)
|
|
|
|
|
(ediff-place-flags-in-buffer
|
|
|
|
|
'B ediff-buffer-B ediff-control-buffer n)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-job
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-place-flags-in-buffer
|
|
|
|
|
'C ediff-buffer-C ediff-control-buffer n))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(if (ediff-buffer-live-p ediff-ancestor-buffer)
|
|
|
|
|
(ediff-place-flags-in-buffer
|
|
|
|
|
'Ancestor ediff-ancestor-buffer
|
|
|
|
|
ediff-control-buffer n))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(ediff-install-fine-diff-if-necessary n)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-select-hook))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Unselect a difference by removing the ASCII flags in the buffers.
|
|
|
|
|
;; This may have to be modified for buffer C, when it will be supported.
|
|
|
|
|
(defun ediff-unselect-difference (n)
|
|
|
|
|
(if (ediff-valid-difference-p n)
|
|
|
|
|
(progn
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(cond ((and (ediff-has-face-support-p) ediff-use-faces)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-unhighlight-diff))
|
|
|
|
|
((eq ediff-highlighting-style 'ascii)
|
|
|
|
|
(ediff-remove-flags-from-buffer
|
|
|
|
|
ediff-buffer-A
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-get-diff-overlay n 'A))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-remove-flags-from-buffer
|
|
|
|
|
ediff-buffer-B
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-get-diff-overlay n 'B))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-3way-job
|
|
|
|
|
(ediff-remove-flags-from-buffer
|
|
|
|
|
ediff-buffer-C
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-get-diff-overlay n 'C)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(if (ediff-buffer-live-p ediff-ancestor-buffer)
|
|
|
|
|
(ediff-remove-flags-from-buffer
|
|
|
|
|
ediff-ancestor-buffer
|
|
|
|
|
(ediff-get-diff-overlay n 'Ancestor)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
(setq ediff-highlighting-style nil)
|
|
|
|
|
|
|
|
|
|
;; unhighlight fine diffs
|
|
|
|
|
(ediff-set-fine-diff-properties ediff-current-difference 'default)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-unselect-hook))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Unselects prev diff and selects a new one, if FLAG has value other than
|
|
|
|
|
;; 'select-only or 'unselect-only. If FLAG is 'select-only, the
|
|
|
|
|
;; next difference is selected, but the current selection is not
|
|
|
|
|
;; unselected. If FLAG is 'unselect-only then the current selection is
|
|
|
|
|
;; unselected, but the next one is not selected. If NO-RECENTER is non-nil,
|
|
|
|
|
;; don't recenter buffers after selecting/unselecting.
|
|
|
|
|
(defun ediff-unselect-and-select-difference (n &optional flag no-recenter)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let ((ediff-current-difference n))
|
|
|
|
|
(or no-recenter
|
|
|
|
|
(ediff-recenter 'no-rehighlight)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let ((control-buf ediff-control-buffer))
|
|
|
|
|
(unwind-protect
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(progn
|
|
|
|
|
(or (eq flag 'select-only)
|
|
|
|
|
(ediff-unselect-difference ediff-current-difference))
|
|
|
|
|
|
|
|
|
|
(or (eq flag 'unselect-only)
|
|
|
|
|
(ediff-select-difference n))
|
|
|
|
|
(setq ediff-current-difference n)
|
|
|
|
|
) ; end protected section
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer control-buf (ediff-refresh-mode-lines))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; This is adapted from a similar function in `emerge.el'.
|
|
|
|
|
;; PROMPT should not have a trailing ': ', so that it can be modified
|
|
|
|
|
;; according to context.
|
|
|
|
|
;; If DEFAULT-FILE is set, it should be used as the default value.
|
|
|
|
|
;; If DEFAULT-DIR is non-nil, use it as the default directory.
|
|
|
|
|
;; Otherwise, use the value of Emacs' variable `default-directory.'
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(defun ediff-read-file-name (prompt default-dir default-file)
|
|
|
|
|
;; hack default-dir if it is not set
|
|
|
|
|
(setq default-dir
|
|
|
|
|
(file-name-as-directory
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-abbreviate-file-name
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(expand-file-name (or default-dir
|
|
|
|
|
(and default-file
|
|
|
|
|
(file-name-directory default-file))
|
|
|
|
|
default-directory)))))
|
|
|
|
|
|
|
|
|
|
;; strip the directory from default-file
|
|
|
|
|
(if default-file
|
|
|
|
|
(setq default-file (file-name-nondirectory default-file)))
|
|
|
|
|
(if (string= default-file "")
|
|
|
|
|
(setq default-file nil))
|
|
|
|
|
|
|
|
|
|
(let (f)
|
|
|
|
|
(setq f (expand-file-name
|
|
|
|
|
(read-file-name
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(format "%s%s "
|
1995-03-16 22:34:51 +00:00
|
|
|
|
prompt
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(cond (default-file
|
|
|
|
|
(concat " (default " default-file "):"))
|
|
|
|
|
(t (concat " (default " default-dir "):"))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
default-dir
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(or default-file default-dir)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
t ; must match, no-confirm
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if default-file (file-name-directory default-file))
|
|
|
|
|
)
|
|
|
|
|
default-dir
|
|
|
|
|
))
|
|
|
|
|
;; If user enters a directory name, expand the default file in that
|
|
|
|
|
;; directory. This allows the user to enter a directory name for the
|
|
|
|
|
;; B-file and diff against the default-file in that directory instead
|
|
|
|
|
;; of a DIRED listing!
|
|
|
|
|
(if (and (file-directory-p f) default-file)
|
|
|
|
|
(setq f (expand-file-name
|
|
|
|
|
(file-name-nondirectory default-file) f)))
|
|
|
|
|
f))
|
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
;; If PREFIX is given, then it is used as a prefix for the temp file
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; name. Otherwise, `ediff' is used. If FILE is given, use this
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; file and don't create a new one.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; In MS-DOS, make sure the prefix isn't too long, or else
|
1998-11-10 11:26:34 +00:00
|
|
|
|
;; `make-temp-name' isn't guaranteed to return a unique filename.
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; Also, save buffer from START to END in the file.
|
|
|
|
|
;; START defaults to (point-min), END to (point-max)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(defun ediff-make-temp-file (buff &optional prefix given-file start end)
|
1998-11-10 11:26:34 +00:00
|
|
|
|
(let* ((p (ediff-convert-standard-filename (or prefix "ediff")))
|
|
|
|
|
(short-p p)
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
|
(coding-system-for-write ediff-coding-system-for-write)
|
1998-11-10 11:26:34 +00:00
|
|
|
|
f short-f)
|
|
|
|
|
(if (and (fboundp 'msdos-long-file-names)
|
|
|
|
|
(not (msdos-long-file-names))
|
|
|
|
|
(> (length p) 2))
|
|
|
|
|
(setq short-p (substring p 0 2)))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(setq f (concat ediff-temp-file-prefix p)
|
1998-11-10 11:26:34 +00:00
|
|
|
|
short-f (concat ediff-temp-file-prefix short-p)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
f (cond (given-file)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
((find-file-name-handler f 'find-file-noselect)
|
|
|
|
|
;; to thwart file handlers in write-region, e.g., if file
|
|
|
|
|
;; name ends with .Z or .gz
|
|
|
|
|
;; This is needed so that patches produced by ediff will
|
|
|
|
|
;; have more meaningful names
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(ediff-make-empty-tmp-file short-f))
|
|
|
|
|
(prefix
|
|
|
|
|
;; Prefix is most often the same as the file name for the
|
|
|
|
|
;; variant. Here we are trying to use the original file
|
|
|
|
|
;; name but in the temp directory.
|
|
|
|
|
(ediff-make-empty-tmp-file f 'keep-name))
|
|
|
|
|
(t
|
|
|
|
|
;; If don't care about name, add some random stuff
|
|
|
|
|
;; to proposed file name.
|
|
|
|
|
(ediff-make-empty-tmp-file short-f))))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; create the file
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buff
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(write-region (if start start (point-min))
|
|
|
|
|
(if end end (point-max))
|
|
|
|
|
f
|
|
|
|
|
nil ; don't append---erase
|
|
|
|
|
'no-message)
|
|
|
|
|
(set-file-modes f ediff-temp-file-mode)
|
1998-11-10 11:26:34 +00:00
|
|
|
|
(expand-file-name f))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; Create a temporary file.
|
|
|
|
|
;; The returned file name (created by appending some random characters at the
|
|
|
|
|
;; end of PROPOSED-NAME is guaranteed to point to a newly created empty file.
|
|
|
|
|
;; This is a replacement for make-temp-name, which eliminates a security hole.
|
|
|
|
|
;; If KEEP-PROPOSED-NAME isn't nil, try to keep PROPOSED-NAME, unless such file
|
|
|
|
|
;; already exists.
|
|
|
|
|
;; It is a modified version of make-temp-file in emacs 20.5
|
|
|
|
|
(defun ediff-make-empty-tmp-file (proposed-name &optional keep-proposed-name)
|
|
|
|
|
(let ((file proposed-name))
|
|
|
|
|
(while (condition-case ()
|
|
|
|
|
(progn
|
|
|
|
|
(if (or (file-exists-p file) (not keep-proposed-name))
|
|
|
|
|
(setq file (make-temp-name proposed-name)))
|
|
|
|
|
(write-region "" nil file nil 'silent nil 'excl)
|
|
|
|
|
nil)
|
|
|
|
|
(file-already-exists t))
|
|
|
|
|
;; the file was somehow created by someone else between
|
|
|
|
|
;; `make-temp-name' and `write-region', let's try again.
|
|
|
|
|
nil)
|
|
|
|
|
file))
|
|
|
|
|
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; Quote metacharacters (using \) when executing diff in Unix, but not in
|
|
|
|
|
;; EMX OS/2
|
1995-10-06 00:59:04 +00:00
|
|
|
|
;;(defun ediff-protect-metachars (str)
|
|
|
|
|
;; (or (memq system-type '(emx vax-vms axp-vms))
|
|
|
|
|
;; (let ((limit 0))
|
|
|
|
|
;; (while (string-match ediff-metachars str limit)
|
|
|
|
|
;; (setq str (concat (substring str 0 (match-beginning 0))
|
|
|
|
|
;; "\\"
|
|
|
|
|
;; (substring str (match-beginning 0))))
|
|
|
|
|
;; (setq limit (1+ (match-end 0))))))
|
|
|
|
|
;; str)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; Make sure the current buffer (for a file) has the same contents as the
|
|
|
|
|
;; file on disk, and attempt to remedy the situation if not.
|
|
|
|
|
;; Signal an error if we can't make them the same, or the user doesn't want
|
|
|
|
|
;; to do what is necessary to make them the same.
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; Also, Ediff always offers to revert obsolete buffers, whether they
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; are modified or not.
|
|
|
|
|
(defun ediff-verify-file-buffer (&optional file-magic)
|
|
|
|
|
;; First check if the file has been modified since the buffer visited it.
|
|
|
|
|
(if (verify-visited-file-modtime (current-buffer))
|
|
|
|
|
(if (buffer-modified-p)
|
|
|
|
|
;; If buffer is not obsolete and is modified, offer to save
|
|
|
|
|
(if (yes-or-no-p
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(format "Buffer out of sync with visited file. Save file %s? "
|
1995-03-16 22:34:51 +00:00
|
|
|
|
buffer-file-name))
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(condition-case nil
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(save-buffer)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(error
|
|
|
|
|
(beep)
|
|
|
|
|
(message "Couldn't save %s" buffer-file-name)))
|
|
|
|
|
(error "Buffer is out of sync for file %s" buffer-file-name))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; If buffer is not obsolete and is not modified, do nothing
|
|
|
|
|
nil)
|
|
|
|
|
;; If buffer is obsolete, offer to revert
|
|
|
|
|
(if (yes-or-no-p
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(format "Buffer is out of sync with visited file. REVERT file %s? "
|
1995-03-16 22:34:51 +00:00
|
|
|
|
buffer-file-name))
|
|
|
|
|
(progn
|
|
|
|
|
(if file-magic
|
|
|
|
|
(erase-buffer))
|
|
|
|
|
(revert-buffer t t))
|
|
|
|
|
(error "Buffer out of sync for file %s" buffer-file-name))))
|
|
|
|
|
|
|
|
|
|
|
1997-09-06 04:16:05 +00:00
|
|
|
|
(defun ediff-filename-magic-p (file)
|
|
|
|
|
(or (ediff-file-compressed-p file)
|
|
|
|
|
(ediff-file-remote-p file)))
|
|
|
|
|
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(defun ediff-save-buffer (arg)
|
|
|
|
|
"Safe way of saving buffers A, B, C, and the diff output.
|
|
|
|
|
`wa' saves buffer A, `wb' saves buffer B, `wc' saves buffer C,
|
1995-10-06 00:59:04 +00:00
|
|
|
|
and `wd' saves the diff output.
|
|
|
|
|
|
|
|
|
|
With prefix argument, `wd' saves plain diff output.
|
|
|
|
|
Without an argument, it saves customized diff argument, if available
|
|
|
|
|
\(and plain output, if customized output was not generated\)."
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(interactive "P")
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
|
|
|
|
(ediff-compute-custom-diffs-maybe)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(cond ((memq last-command-char '(?a ?b ?c))
|
|
|
|
|
(ediff-get-buffer
|
|
|
|
|
(ediff-char-to-buftype last-command-char)))
|
|
|
|
|
((eq last-command-char ?d)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(message "Saving diff output ...")
|
|
|
|
|
(sit-for 1) ; let the user see the message
|
|
|
|
|
(cond ((and arg (ediff-buffer-live-p ediff-diff-buffer))
|
|
|
|
|
ediff-diff-buffer)
|
|
|
|
|
((ediff-buffer-live-p ediff-custom-diff-buffer)
|
|
|
|
|
ediff-custom-diff-buffer)
|
|
|
|
|
((ediff-buffer-live-p ediff-diff-buffer)
|
|
|
|
|
ediff-diff-buffer)
|
|
|
|
|
(t (error "Output from `diff' not found"))))
|
|
|
|
|
)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(save-buffer)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-compute-custom-diffs-maybe ()
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(let ((buf-A-file-name (buffer-file-name ediff-buffer-A))
|
|
|
|
|
(buf-B-file-name (buffer-file-name ediff-buffer-B))
|
|
|
|
|
file-A file-B)
|
|
|
|
|
(if (stringp buf-A-file-name)
|
|
|
|
|
(setq buf-A-file-name (file-name-nondirectory buf-A-file-name)))
|
|
|
|
|
(if (stringp buf-B-file-name)
|
|
|
|
|
(setq buf-B-file-name (file-name-nondirectory buf-B-file-name)))
|
|
|
|
|
(setq file-A (ediff-make-temp-file ediff-buffer-A buf-A-file-name)
|
|
|
|
|
file-B (ediff-make-temp-file ediff-buffer-B buf-B-file-name))
|
|
|
|
|
|
|
|
|
|
(or (ediff-buffer-live-p ediff-custom-diff-buffer)
|
|
|
|
|
(setq ediff-custom-diff-buffer
|
|
|
|
|
(get-buffer-create
|
|
|
|
|
(ediff-unique-buffer-name "*ediff-custom-diff" "*"))))
|
|
|
|
|
(ediff-exec-process
|
|
|
|
|
ediff-custom-diff-program ediff-custom-diff-buffer 'synchronize
|
|
|
|
|
ediff-custom-diff-options file-A file-B)
|
2001-02-12 08:47:13 +00:00
|
|
|
|
;; put the diff file in diff-mode, if it is available
|
|
|
|
|
(if (fboundp 'diff-mode)
|
|
|
|
|
(with-current-buffer ediff-custom-diff-buffer
|
|
|
|
|
(diff-mode)))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(delete-file file-A)
|
|
|
|
|
(delete-file file-B)
|
|
|
|
|
))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-show-diff-output (arg)
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
|
|
|
|
(ediff-compute-custom-diffs-maybe)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(ediff-skip-unsuitable-frames ' ok-unsplittable))
|
|
|
|
|
(let ((buf (cond ((and arg (ediff-buffer-live-p ediff-diff-buffer))
|
|
|
|
|
ediff-diff-buffer)
|
|
|
|
|
((ediff-buffer-live-p ediff-custom-diff-buffer)
|
|
|
|
|
ediff-custom-diff-buffer)
|
|
|
|
|
((ediff-buffer-live-p ediff-diff-buffer)
|
|
|
|
|
ediff-diff-buffer)
|
|
|
|
|
(t
|
|
|
|
|
(beep)
|
|
|
|
|
(message "Output from `diff' not found")
|
|
|
|
|
nil))))
|
|
|
|
|
(if buf
|
|
|
|
|
(progn
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buf
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(goto-char (point-min)))
|
|
|
|
|
(switch-to-buffer buf)
|
|
|
|
|
(raise-frame (selected-frame)))))
|
|
|
|
|
(if (frame-live-p ediff-control-frame)
|
|
|
|
|
(ediff-reset-mouse ediff-control-frame))
|
|
|
|
|
(if (window-live-p ediff-control-window)
|
|
|
|
|
(select-window ediff-control-window)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-inferior-compare-regions ()
|
|
|
|
|
"Compare regions in an active Ediff session.
|
|
|
|
|
Like ediff-regions-linewise but is called from under an active Ediff session on
|
|
|
|
|
the files that belong to that session.
|
|
|
|
|
|
|
|
|
|
After quitting the session invoked via this function, type C-l to the parent
|
|
|
|
|
Ediff Control Panel to restore highlighting."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((answer "")
|
|
|
|
|
(possibilities (list ?A ?B ?C))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(zmacs-regions t)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(ctl-buf (current-buffer))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
quit-now
|
1996-09-20 01:10:05 +00:00
|
|
|
|
begA begB endA endB bufA bufB)
|
|
|
|
|
|
|
|
|
|
(cond ((ediff-merge-job)
|
|
|
|
|
(setq bufB ediff-buffer-C)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(while (cond ((eq answer ?A)
|
|
|
|
|
(setq bufA ediff-buffer-A
|
|
|
|
|
possibilities '(?B))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
nil)
|
1997-05-31 01:10:39 +00:00
|
|
|
|
((eq answer ?B)
|
|
|
|
|
(setq bufA ediff-buffer-B
|
|
|
|
|
possibilities '(?A))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
nil)
|
|
|
|
|
((equal answer ""))
|
|
|
|
|
(t (beep 1)
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(message "Valid values are A or B")
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(sit-for 2)
|
|
|
|
|
t))
|
|
|
|
|
(let ((cursor-in-echo-area t))
|
|
|
|
|
(message "Which buffer to compare to the merge buffer (A/B)? ")
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(setq answer (capitalize (read-char-exclusive))))))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
|
|
|
|
|
((ediff-3way-comparison-job)
|
|
|
|
|
(while (cond ((memq answer possibilities)
|
|
|
|
|
(setq possibilities (delq answer possibilities))
|
|
|
|
|
(setq bufA
|
|
|
|
|
(eval
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-get-symbol-from-alist
|
|
|
|
|
answer ediff-buffer-alist)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
nil)
|
|
|
|
|
((equal answer ""))
|
|
|
|
|
(t (beep 1)
|
|
|
|
|
(message
|
1996-12-28 02:53:04 +00:00
|
|
|
|
"Valid values are %s"
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(mapconcat 'char-to-string possibilities " or "))
|
|
|
|
|
(sit-for 2)
|
|
|
|
|
t))
|
|
|
|
|
(let ((cursor-in-echo-area t))
|
|
|
|
|
(message "Enter the 1st buffer you want to compare (%s): "
|
|
|
|
|
(mapconcat 'char-to-string possibilities "/"))
|
|
|
|
|
(setq answer (capitalize (read-char-exclusive)))))
|
|
|
|
|
(setq answer "") ; silence error msg
|
|
|
|
|
(while (cond ((memq answer possibilities)
|
|
|
|
|
(setq possibilities (delq answer possibilities))
|
|
|
|
|
(setq bufB
|
|
|
|
|
(eval
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-get-symbol-from-alist
|
|
|
|
|
answer ediff-buffer-alist)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
nil)
|
|
|
|
|
((equal answer ""))
|
|
|
|
|
(t (beep 1)
|
|
|
|
|
(message
|
1996-12-28 02:53:04 +00:00
|
|
|
|
"Valid values are %s"
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(mapconcat 'char-to-string possibilities " or "))
|
|
|
|
|
(sit-for 2)
|
|
|
|
|
t))
|
|
|
|
|
(let ((cursor-in-echo-area t))
|
|
|
|
|
(message "Enter the 2nd buffer you want to compare (%s): "
|
|
|
|
|
(mapconcat 'char-to-string possibilities "/"))
|
|
|
|
|
(setq answer (capitalize (read-char-exclusive))))))
|
|
|
|
|
(t ; 2way comparison
|
|
|
|
|
(setq bufA ediff-buffer-A
|
1997-05-31 01:10:39 +00:00
|
|
|
|
bufB ediff-buffer-B
|
|
|
|
|
possibilities nil)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufA
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(or (mark t)
|
|
|
|
|
(error "You forgot to specify a region in buffer %s" (buffer-name)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(setq begA (region-beginning)
|
|
|
|
|
endA (region-end))
|
|
|
|
|
(goto-char begA)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq begA (point))
|
|
|
|
|
(goto-char endA)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(or (eobp) (forward-char)) ; include the newline char
|
|
|
|
|
(setq endA (point)))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufB
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(or (mark t)
|
|
|
|
|
(error "You forgot to specify a region in buffer %s" (buffer-name)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(setq begB (region-beginning)
|
|
|
|
|
endB (region-end))
|
|
|
|
|
(goto-char begB)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq begB (point))
|
|
|
|
|
(goto-char endB)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(or (eobp) (forward-char)) ; include the newline char
|
|
|
|
|
(setq endB (point)))
|
|
|
|
|
|
|
|
|
|
(ediff-unselect-and-select-difference
|
|
|
|
|
ediff-current-difference 'unselect-only)
|
|
|
|
|
(ediff-paint-background-regions 'unhighlight)
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufA
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(goto-char begA)
|
|
|
|
|
(set-mark endA)
|
|
|
|
|
(narrow-to-region begA endA)
|
|
|
|
|
;; (ediff-activate-mark)
|
|
|
|
|
)
|
|
|
|
|
;; (sit-for 0)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufB
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(goto-char begB)
|
|
|
|
|
(set-mark endB)
|
|
|
|
|
(narrow-to-region begB endB)
|
|
|
|
|
;; (ediff-activate-mark)
|
|
|
|
|
)
|
|
|
|
|
;; (sit-for 0)
|
|
|
|
|
|
1997-05-31 01:10:39 +00:00
|
|
|
|
;; At this point, possibilities contains either the window char A/B/C
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; that was not selected, or it is nil. We delete the window that is not
|
1997-05-31 01:10:39 +00:00
|
|
|
|
;; selected.
|
|
|
|
|
(if possibilities
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ctl-buf
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(let* ((wind-to-delete (eval
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-get-symbol-from-alist
|
|
|
|
|
(car possibilities)
|
|
|
|
|
ediff-window-alist)))
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(frame (window-frame wind-to-delete)))
|
|
|
|
|
(delete-window wind-to-delete)
|
|
|
|
|
(select-frame frame)
|
|
|
|
|
(balance-windows))))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(or (y-or-n-p
|
1999-11-01 07:16:15 +00:00
|
|
|
|
"Please check regions selected for comparison. Continue? ")
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(setq quit-now t))
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufA
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(widen))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer bufB
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(widen))
|
|
|
|
|
(if quit-now
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ctl-buf
|
1997-05-31 01:10:39 +00:00
|
|
|
|
(ediff-recenter)
|
|
|
|
|
(sit-for 0)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(error "All right. Make up your mind and come back...")))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(ediff-regions-internal
|
|
|
|
|
bufA begA endA bufB begB endB
|
1997-05-31 01:10:39 +00:00
|
|
|
|
nil ; setup-hook
|
1996-09-20 01:10:05 +00:00
|
|
|
|
'ediff-regions-linewise ; job name
|
1997-05-31 01:10:39 +00:00
|
|
|
|
nil ; no word mode
|
|
|
|
|
;; setup param to pass to ediff-setup
|
|
|
|
|
(list (cons 'ediff-split-window-function ediff-split-window-function)))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(defun ediff-remove-flags-from-buffer (buffer overlay)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buffer
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(ediff-overlay-put overlay 'begin-glyph nil)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-overlay-put overlay 'before-string nil))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(ediff-overlay-put overlay 'end-glyph nil)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-overlay-put overlay 'after-string nil))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buffer
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-place-flags-in-buffer1 buf-type ctl-buffer diff)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-place-flags-in-buffer1 (buf-type ctl-buffer diff-no)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(let* ((curr-overl (ediff-with-current-buffer ctl-buffer
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-get-diff-overlay diff-no buf-type)))
|
|
|
|
|
(before (ediff-get-diff-posn buf-type 'beg diff-no ctl-buffer))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
after beg-of-line flag)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; insert flag before the difference
|
|
|
|
|
(goto-char before)
|
|
|
|
|
(setq beg-of-line (bolp))
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(setq flag (ediff-with-current-buffer ctl-buffer
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if (eq ediff-highlighting-style 'ascii)
|
|
|
|
|
(if beg-of-line
|
|
|
|
|
ediff-before-flag-bol ediff-before-flag-mol))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; insert the flag itself
|
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(ediff-overlay-put curr-overl 'begin-glyph flag)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-overlay-put curr-overl 'before-string flag))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; insert the flag after the difference
|
|
|
|
|
;; `after' must be set here, after the before-flag was inserted
|
|
|
|
|
(setq after (ediff-get-diff-posn buf-type 'end diff-no ctl-buffer))
|
|
|
|
|
(goto-char after)
|
|
|
|
|
(setq beg-of-line (bolp))
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(setq flag (ediff-with-current-buffer ctl-buffer
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(if (eq ediff-highlighting-style 'ascii)
|
|
|
|
|
(if beg-of-line
|
|
|
|
|
ediff-after-flag-eol ediff-after-flag-mol))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; insert the flag itself
|
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(ediff-overlay-put curr-overl 'end-glyph flag)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-overlay-put curr-overl 'after-string flag))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; Returns positions of difference sectors in the BUF-TYPE buffer.
|
|
|
|
|
;; BUF-TYPE should be a symbol -- `A', `B', or `C'.
|
|
|
|
|
;; POS is either `beg' or `end'--it specifies whether you want the position at
|
|
|
|
|
;; the beginning of a difference or at the end.
|
|
|
|
|
;;
|
|
|
|
|
;; The optional argument N says which difference (default:
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; `ediff-current-difference'). N is the internal difference number (1- what
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; the user sees). The optional argument CONTROL-BUF says
|
|
|
|
|
;; which control buffer is in effect in case it is not the current
|
|
|
|
|
;; buffer.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(defun ediff-get-diff-posn (buf-type pos &optional n control-buf)
|
|
|
|
|
(let (diff-overlay)
|
|
|
|
|
(or control-buf
|
|
|
|
|
(setq control-buf (current-buffer)))
|
|
|
|
|
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer control-buf
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(or n (setq n ediff-current-difference))
|
|
|
|
|
(if (or (< n 0) (>= n ediff-number-of-differences))
|
|
|
|
|
(if (> ediff-number-of-differences 0)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
(error ediff-BAD-DIFF-NUMBER
|
|
|
|
|
this-command (1+ n) ediff-number-of-differences)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(error ediff-NO-DIFFERENCES)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(setq diff-overlay (ediff-get-diff-overlay n buf-type)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(if (not (ediff-buffer-live-p (ediff-overlay-buffer diff-overlay)))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(error ediff-KILLED-VITAL-BUFFER))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(if (eq pos 'beg)
|
|
|
|
|
(ediff-overlay-start diff-overlay)
|
|
|
|
|
(ediff-overlay-end diff-overlay))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
1996-09-20 01:10:05 +00:00
|
|
|
|
;; Restore highlighting to what it should be according to ediff-use-faces,
|
|
|
|
|
;; ediff-highlighting-style, and ediff-highlight-all-diffs variables.
|
|
|
|
|
(defun ediff-restore-highlighting (&optional ctl-buf)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer (or ctl-buf (current-buffer))
|
1996-09-20 01:10:05 +00:00
|
|
|
|
(if (and (ediff-has-face-support-p)
|
|
|
|
|
ediff-use-faces
|
|
|
|
|
ediff-highlight-all-diffs)
|
|
|
|
|
(ediff-paint-background-regions))
|
|
|
|
|
(ediff-select-difference ediff-current-difference)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; null out difference overlays so they won't slow down future
|
|
|
|
|
;; editing operations
|
|
|
|
|
;; VEC is either a difference vector or a fine-diff vector
|
|
|
|
|
(defun ediff-clear-diff-vector (vec-var &optional fine-diffs-also)
|
|
|
|
|
(if (vectorp (symbol-value vec-var))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(mapcar (lambda (elt)
|
|
|
|
|
(ediff-delete-overlay
|
|
|
|
|
(ediff-get-diff-overlay-from-diff-record elt))
|
|
|
|
|
(if fine-diffs-also
|
|
|
|
|
(ediff-clear-fine-diff-vector elt))
|
|
|
|
|
)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(symbol-value vec-var)))
|
|
|
|
|
;; allow them to be garbage collected
|
|
|
|
|
(set vec-var nil))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Misc
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; In Emacs, this just makes overlay. In the future, when Emacs will start
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; supporting sticky overlays, this function will make a sticky overlay.
|
|
|
|
|
;; BEG and END are expressions telling where overlay starts.
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; If they are numbers or buffers, then all is well. Otherwise, they must
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; be expressions to be evaluated in buffer BUF in order to get the overlay
|
|
|
|
|
;; bounds.
|
|
|
|
|
;; If BUFF is not a live buffer, then return nil; otherwise, return the
|
|
|
|
|
;; newly created overlay.
|
|
|
|
|
(defun ediff-make-bullet-proof-overlay (beg end buff)
|
|
|
|
|
(if (ediff-buffer-live-p buff)
|
|
|
|
|
(let (overl)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buff
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(or (number-or-marker-p beg)
|
|
|
|
|
(setq beg (eval beg)))
|
|
|
|
|
(or (number-or-marker-p end)
|
|
|
|
|
(setq end (eval end)))
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(setq overl
|
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(make-extent beg end buff)
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; advance front and rear of the overlay
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(make-overlay beg end buff nil 'rear-advance)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; never detach
|
|
|
|
|
(ediff-overlay-put
|
|
|
|
|
overl (if ediff-emacs-p 'evaporate 'detachable) nil)
|
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-compile,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
(viper-get-ex-address-subr): convert registers to char data type.
* viper-util.el (viper-int-to-char,viper-char-equal): new
functions.
(viper-memq-char): use viper-int-to-char.
(viper-file-checked-in-p): use vc-locking-user, if vc doesn't have
vc-locking-state.
(viper-read-key): use viper-read-key-sequence.
* viper.el (viper-major-mode-modifier-list): added
inferior-emacs-lisp-mode.
(this-major-mode-requires-vi-state): new function that uses simple
heuristics to decide if vi state is appropriate.
(set-viper-state-in-major-mode): use this-major-mode-requires-vi-state.
(viper-non-hook-settings): don't advise read-key-sequence.
(viper-read-key-sequence): new function that replaces the
previously used advice to read-key-sequence.
* viper-cmd.el (viper-test-com-defun,viper-exec-change,
viper-exec-Change,viper-execute-com,viper-insert,viper-append,
viper-Append,viper-Insert,viper-open-line,viper-Open-line,
viper-open-line-at-point,viper-substitute,viper-overwrite,
viper-replace-char-subr,viper-forward-word,viper-forward-Word):
got rid of the negative character hack.
(viper-escape-to-state,viper-replace-state-exit-cmd):
use viper-read-key-sequence.
(viper-envelop-ESC-key): no need for ad-get-orig-definition.
(viper-minibuffer-standard-hook,viper-read-string-with-history):
don't override existing minibuffer-setup-hook.
(viper-mark-point,viper-goto-mark-subr,viper-brac-function):
convert registers to char data type.
(viper-autoindent): use viper-indent-line.
* viper-keym.el: use viper-exec-key-in-emacs.
* viper.texi: Added credits, new commands, like :make.
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
(ediff-file-checked-out-p,ediff-file-checked-in-p): check if
vc-state is available.
(ediff-make-temp-file): use ediff-coding-system-for-write.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
(ediff-coding-system-for-read): from ediff-diff.el
(ediff-coding-system-for-write): new variable.
(ediff-highest-priority): fixed the bug having to do with disappearing
overlays.
(ediff-file-remote-p): use file-remote-p, if available.
(ediff-listable-file): new function.
(ediff-file-attributes): use ediff-listable-file.
* ediff-mult.el (ediff-meta-insert-file-info1): use
ediff-listable-file.
* ediff-ptch.el (ediff-prompt-for-patch-file): use
ediff-coding-system-for-read.
(ediff-patch-file-internal): use ediff-coding-system-for-write.
* ediff-diff.el (ediff-coding-system-for-read): moved to ediff-init.el.
(ediff-match-diff3-line,ediff-get-diff3-group): improved pattern.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* ediff.texi: added clarifications, acknowledgements.
2001-07-21 05:28:24 +00:00
|
|
|
|
;; make overlay open-ended
|
1996-06-22 01:54:34 +00:00
|
|
|
|
;; In emacs, it is made open ended at creation time
|
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(progn
|
|
|
|
|
(ediff-overlay-put overl 'start-open nil)
|
|
|
|
|
(ediff-overlay-put overl 'end-open nil)))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-overlay-put overl 'ediff-diff-num 0)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
overl))))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; Like other-buffer, but prefers visible buffers and ignores temporary or
|
|
|
|
|
;; other insignificant buffers (those beginning with "^[ *]").
|
|
|
|
|
;; Gets one arg--buffer name or a list of buffer names (it won't return
|
|
|
|
|
;; these buffers).
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; EXCL-BUFF-LIST is an exclusion list.
|
|
|
|
|
(defun ediff-other-buffer (excl-buff-lst)
|
|
|
|
|
(or (listp excl-buff-lst) (setq excl-buff-lst (list excl-buff-lst)))
|
2000-10-29 04:56:45 +00:00
|
|
|
|
(let* ((all-buffers (nconc (ediff-get-selected-buffers) (buffer-list)))
|
|
|
|
|
;; we compute this the second time because we need to do memq on it
|
|
|
|
|
;; later, and nconc above will break it. Either this or use slow
|
|
|
|
|
;; append instead of nconc
|
|
|
|
|
(selected-buffers (ediff-get-selected-buffers))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(prefered-buffer (car all-buffers))
|
|
|
|
|
visible-dired-buffers
|
|
|
|
|
(excl-buff-name-list
|
1997-09-06 04:16:05 +00:00
|
|
|
|
(mapcar
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(lambda (b) (cond ((stringp b) b)
|
|
|
|
|
((bufferp b) (buffer-name b))))
|
|
|
|
|
excl-buff-lst))
|
|
|
|
|
;; if at least one buffer on the exclusion list is dired, then force
|
|
|
|
|
;; all others to be dired. This is because this means that the user
|
|
|
|
|
;; has already chosen a dired buffer before
|
|
|
|
|
(use-dired-major-mode
|
|
|
|
|
(cond ((null (ediff-buffer-live-p (car excl-buff-lst))) 'unknown)
|
|
|
|
|
((eq (ediff-with-current-buffer (car excl-buff-lst) major-mode)
|
|
|
|
|
'dired-mode)
|
|
|
|
|
'yes)
|
|
|
|
|
(t 'no)))
|
|
|
|
|
;; significant-buffers must be visible and not belong
|
|
|
|
|
;; to the exclusion list `buff-list'
|
|
|
|
|
;; We also exclude temporary buffers, but keep mail and gnus buffers
|
|
|
|
|
;; Furthermore, we exclude dired buffers, unless they are the only
|
|
|
|
|
;; ones visible (and there are at least two of them).
|
|
|
|
|
;; Also, any visible window not on the exclusion list that is first in
|
|
|
|
|
;; the buffer list is chosen regardless. (This is because the user
|
|
|
|
|
;; clicked on it or did something to distinguish it).
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(significant-buffers
|
|
|
|
|
(mapcar
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(lambda (x)
|
|
|
|
|
(cond ((member (buffer-name x) excl-buff-name-list) nil)
|
2000-10-29 04:56:45 +00:00
|
|
|
|
((memq x selected-buffers) x)
|
|
|
|
|
((not (ediff-get-visible-buffer-window x)) nil)
|
|
|
|
|
((eq x prefered-buffer) x)
|
|
|
|
|
;; if prev selected buffer is dired, look only at
|
|
|
|
|
;; dired.
|
|
|
|
|
((eq use-dired-major-mode 'yes)
|
|
|
|
|
(if (eq (ediff-with-current-buffer x major-mode)
|
|
|
|
|
'dired-mode)
|
|
|
|
|
x nil))
|
|
|
|
|
((eq (ediff-with-current-buffer x major-mode)
|
|
|
|
|
'dired-mode)
|
|
|
|
|
(if (null use-dired-major-mode)
|
|
|
|
|
;; don't know if we must enforce dired.
|
|
|
|
|
;; Remember this buffer in case
|
|
|
|
|
;; dired buffs are the only ones visible.
|
|
|
|
|
(setq visible-dired-buffers
|
|
|
|
|
(cons x visible-dired-buffers)))
|
|
|
|
|
;; skip, if dired is not forced
|
|
|
|
|
nil)
|
|
|
|
|
((memq (ediff-with-current-buffer x major-mode)
|
|
|
|
|
'(rmail-mode
|
|
|
|
|
vm-mode
|
|
|
|
|
gnus-article-mode
|
|
|
|
|
mh-show-mode))
|
|
|
|
|
x)
|
|
|
|
|
((string-match "^[ *]" (buffer-name x)) nil)
|
|
|
|
|
((string= "*scratch*" (buffer-name x)) nil)
|
|
|
|
|
(t x)))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
all-buffers))
|
|
|
|
|
(clean-significant-buffers (delq nil significant-buffers))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
less-significant-buffers)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
|
|
|
|
|
(if (and (null clean-significant-buffers)
|
|
|
|
|
(> (length visible-dired-buffers) 0))
|
|
|
|
|
(setq clean-significant-buffers visible-dired-buffers))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(cond (clean-significant-buffers (car clean-significant-buffers))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; try also buffers that are not displayed in windows
|
|
|
|
|
((setq less-significant-buffers
|
|
|
|
|
(delq nil
|
|
|
|
|
(mapcar
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(lambda (x)
|
|
|
|
|
(cond ((member (buffer-name x) excl-buff-name-list)
|
|
|
|
|
nil)
|
|
|
|
|
((eq use-dired-major-mode 'yes)
|
|
|
|
|
(if (eq (ediff-with-current-buffer
|
|
|
|
|
x major-mode)
|
|
|
|
|
'dired-mode)
|
|
|
|
|
x nil))
|
|
|
|
|
((eq (ediff-with-current-buffer x major-mode)
|
|
|
|
|
'dired-mode)
|
|
|
|
|
nil)
|
|
|
|
|
((string-match "^[ *]" (buffer-name x)) nil)
|
|
|
|
|
((string= "*scratch*" (buffer-name x)) nil)
|
|
|
|
|
(t x)))
|
|
|
|
|
all-buffers)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(car less-significant-buffers))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(t "*scratch*"))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
|
2000-10-29 04:56:45 +00:00
|
|
|
|
|
|
|
|
|
;; If current buffer is a Buffer-menu buffer, then take the selected buffers
|
|
|
|
|
;; and append the buffer at the cursor to the end.
|
|
|
|
|
;; This list would be the preferred list.
|
|
|
|
|
(defun ediff-get-selected-buffers ()
|
|
|
|
|
(if (eq major-mode 'Buffer-menu-mode)
|
|
|
|
|
(let ((lis (condition-case nil
|
|
|
|
|
(list (Buffer-menu-buffer t))
|
|
|
|
|
(error))
|
|
|
|
|
))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(while (search-backward "\n>" nil t)
|
|
|
|
|
(forward-char 1)
|
|
|
|
|
(setq lis (cons (Buffer-menu-buffer t) lis)))
|
|
|
|
|
lis))
|
|
|
|
|
))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; Construct a unique buffer name.
|
|
|
|
|
;; The first one tried is prefixsuffix, then prefix<2>suffix,
|
|
|
|
|
;; prefix<3>suffix, etc.
|
|
|
|
|
(defun ediff-unique-buffer-name (prefix suffix)
|
|
|
|
|
(if (null (get-buffer (concat prefix suffix)))
|
|
|
|
|
(concat prefix suffix)
|
|
|
|
|
(let ((n 2))
|
|
|
|
|
(while (get-buffer (format "%s<%d>%s" prefix n suffix))
|
|
|
|
|
(setq n (1+ n)))
|
|
|
|
|
(format "%s<%d>%s" prefix n suffix))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-submit-report ()
|
|
|
|
|
"Submit bug report on Ediff."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(let ((reporter-prompt-for-summary-p t)
|
|
|
|
|
(ctl-buf ediff-control-buffer)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-device-type (ediff-device-type))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
varlist salutation buffer-name)
|
|
|
|
|
(setq varlist '(ediff-diff-program ediff-diff-options
|
|
|
|
|
ediff-patch-program ediff-patch-options
|
|
|
|
|
ediff-shell
|
|
|
|
|
ediff-use-faces
|
|
|
|
|
ediff-auto-refine ediff-highlighting-style
|
|
|
|
|
ediff-buffer-A ediff-buffer-B ediff-control-buffer
|
|
|
|
|
ediff-forward-word-function
|
|
|
|
|
ediff-control-frame
|
|
|
|
|
ediff-control-frame-parameters
|
|
|
|
|
ediff-control-frame-position-function
|
|
|
|
|
ediff-prefer-iconified-control-frame
|
|
|
|
|
ediff-window-setup-function
|
|
|
|
|
ediff-split-window-function
|
|
|
|
|
ediff-job-name
|
|
|
|
|
ediff-word-mode
|
|
|
|
|
buffer-name
|
1995-06-05 23:43:51 +00:00
|
|
|
|
ediff-device-type
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
(setq salutation "
|
1999-11-01 07:16:15 +00:00
|
|
|
|
Congratulations! You may have unearthed a bug in Ediff!
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
Please make a concise and accurate summary of what happened
|
|
|
|
|
and mail it to the address above.
|
|
|
|
|
-----------------------------------------------------------
|
|
|
|
|
")
|
|
|
|
|
|
|
|
|
|
(ediff-skip-unsuitable-frames)
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(ediff-reset-mouse)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(switch-to-buffer ediff-msg-buffer)
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(delete-other-windows)
|
|
|
|
|
(insert "
|
|
|
|
|
Please read this first:
|
|
|
|
|
----------------------
|
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
Some ``bugs'' may actually be no bugs at all. For instance, if you are
|
1995-03-16 22:34:51 +00:00
|
|
|
|
reporting that certain difference regions are not matched as you think they
|
|
|
|
|
should, this is most likely due to the way Unix diff program decides what
|
1999-11-01 07:16:15 +00:00
|
|
|
|
constitutes a difference region. Ediff is an Emacs interface to diff, and
|
1995-03-16 22:34:51 +00:00
|
|
|
|
it has nothing to do with those decisions---it only takes the output from
|
|
|
|
|
diff and presents it in a way that is better suited for human browsing and
|
|
|
|
|
manipulation.
|
|
|
|
|
|
|
|
|
|
If Emacs happens to dump core, this is NOT an Ediff problem---it is
|
1999-11-01 07:16:15 +00:00
|
|
|
|
an Emacs bug. Report this to Emacs maintainers.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
Another popular topic for reports is compilation messages. Because Ediff
|
|
|
|
|
interfaces to several other packages and runs under Emacs and XEmacs,
|
|
|
|
|
byte-compilation may produce output like this:
|
|
|
|
|
|
|
|
|
|
While compiling toplevel forms in file ediff.el:
|
|
|
|
|
** reference to free variable pm-color-alist
|
|
|
|
|
........................
|
|
|
|
|
While compiling the end of the data:
|
|
|
|
|
** The following functions are not known to be defined:
|
1995-06-05 23:43:51 +00:00
|
|
|
|
ediff-valid-color-p, ediff-set-face,
|
1995-03-16 22:34:51 +00:00
|
|
|
|
........................
|
|
|
|
|
|
|
|
|
|
These are NOT errors, but inevitable warnings, which ought to be ignored.
|
|
|
|
|
|
|
|
|
|
Please do not report those and similar things. However, comments and
|
|
|
|
|
suggestions are always welcome.
|
|
|
|
|
|
|
|
|
|
Mail anyway? (y or n) ")
|
|
|
|
|
|
|
|
|
|
(if (y-or-n-p "Mail anyway? ")
|
|
|
|
|
(progn
|
|
|
|
|
(if (ediff-buffer-live-p ctl-buf)
|
|
|
|
|
(set-buffer ctl-buf))
|
|
|
|
|
(setq buffer-name (buffer-name))
|
|
|
|
|
(require 'reporter)
|
|
|
|
|
(reporter-submit-bug-report "kifer@cs.sunysb.edu"
|
|
|
|
|
(ediff-version)
|
|
|
|
|
varlist
|
|
|
|
|
nil
|
|
|
|
|
'delete-other-windows
|
|
|
|
|
salutation))
|
|
|
|
|
(bury-buffer)
|
|
|
|
|
(beep 1)(message "Bug report aborted")
|
|
|
|
|
(if (ediff-buffer-live-p ctl-buf)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ctl-buf
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-recenter 'no-rehighlight))))
|
|
|
|
|
))
|
2001-03-17 Michael Kifer <kifer@cs.sunysb.edu>
* ediff-util.el: Copyright years.
(ediff-choose-syntax-table): New function.
(ediff-setup): Use ediff-choose-syntax-table.
* ediff-init.el (ediff-with-syntax-table): New macro, uses
with-syntax-table.
* ediff.el: Date of last update, copyright years.
* ediff-wind (ediff-setup-control-frame): Nill->nil.
* viper-ex.el (ex-token-list,ex-cmd-execute): Revamped, courtesy
of Scott Bronson.
(ex-cmd-assoc,ex-cmd-one-letr): New functions.
(viper-check-sub,viper-get-ex-command,viper-execute-ex-command):
Deleted functions.
(viper-get-ex-com-subr,viper-ex,ex-mark): Changed to use the new
ex-token-list.
* viper-util.el: Spaces, indentation.
* viper.el: Changed version, modification time.
2001-03-17 18:59:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Find an appropriate syntax table for everyone to use
|
|
|
|
|
;; If buffer B is not fundamental or text mode, use its syntax table
|
|
|
|
|
;; Otherwise, use buffer B's.
|
|
|
|
|
;; The syntax mode is used in ediff-forward-word-function
|
|
|
|
|
;; The important thing is that every buffer should use the same syntax table
|
|
|
|
|
;; during the refinement operation
|
|
|
|
|
(defun ediff-choose-syntax-table ()
|
|
|
|
|
(setq ediff-syntax-table
|
|
|
|
|
(ediff-with-current-buffer ediff-buffer-A
|
|
|
|
|
(if (not (memq major-mode
|
|
|
|
|
'(fundamental-mode text-mode indented-text-mode)))
|
|
|
|
|
(syntax-table))))
|
|
|
|
|
(if (not ediff-syntax-table)
|
|
|
|
|
(setq ediff-syntax-table
|
|
|
|
|
(ediff-with-current-buffer ediff-buffer-B
|
|
|
|
|
(syntax-table))))
|
|
|
|
|
)
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-deactivate-mark ()
|
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(zmacs-deactivate-region)
|
|
|
|
|
(deactivate-mark)))
|
1996-12-28 02:53:04 +00:00
|
|
|
|
(defun ediff-activate-mark ()
|
|
|
|
|
(if ediff-emacs-p
|
|
|
|
|
(setq mark-active t)
|
|
|
|
|
(zmacs-activate-region)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(cond ((fboundp 'nuke-selective-display)
|
|
|
|
|
;; XEmacs 19.12 has nuke-selective-display
|
|
|
|
|
(fset 'ediff-nuke-selective-display 'nuke-selective-display))
|
|
|
|
|
(t
|
|
|
|
|
(defun ediff-nuke-selective-display ()
|
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((mod-p (buffer-modified-p))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
buffer-read-only end)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(and (eq t selective-display)
|
|
|
|
|
(while (search-forward "\^M" nil t)
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(setq end (point))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(while (search-forward "\^M" end t)
|
|
|
|
|
(delete-char -1)
|
|
|
|
|
(insert "\^J"))))
|
|
|
|
|
(set-buffer-modified-p mod-p)
|
|
|
|
|
(setq selective-display nil)))))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; The next two are modified versions from emerge.el.
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; VARS must be a list of symbols
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; ediff-save-variables returns an association list: ((var . val) ...)
|
|
|
|
|
(defsubst ediff-save-variables (vars)
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(mapcar (lambda (v) (cons v (symbol-value v)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
vars))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
;; VARS is a list of variable symbols.
|
|
|
|
|
(defun ediff-restore-variables (vars assoc-list)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(while vars
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(set (car vars) (cdr (assoc (car vars) assoc-list)))
|
|
|
|
|
(setq vars (cdr vars))))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(defun ediff-change-saved-variable (var value buf-type)
|
|
|
|
|
(let* ((assoc-list
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(symbol-value (ediff-get-symbol-from-alist
|
|
|
|
|
buf-type
|
|
|
|
|
ediff-buffer-values-orig-alist)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(assoc-elt (assoc var assoc-list)))
|
|
|
|
|
(if assoc-elt
|
|
|
|
|
(setcdr assoc-elt value))))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;; must execute in control buf
|
|
|
|
|
(defun ediff-save-protected-variables ()
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(setq ediff-buffer-values-orig-A
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-A
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-save-variables ediff-protected-variables)))
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(setq ediff-buffer-values-orig-B
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-B
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-save-variables ediff-protected-variables)))
|
|
|
|
|
(if ediff-3way-comparison-job
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(setq ediff-buffer-values-orig-C
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-save-variables ediff-protected-variables))))
|
|
|
|
|
(if (ediff-buffer-live-p ediff-ancestor-buffer)
|
|
|
|
|
(setq ediff-buffer-values-orig-Ancestor
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-ancestor-buffer
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(ediff-save-variables ediff-protected-variables)))))
|
|
|
|
|
|
|
|
|
|
;; must execute in control buf
|
|
|
|
|
(defun ediff-restore-protected-variables ()
|
1995-06-05 23:43:51 +00:00
|
|
|
|
(let ((values-A ediff-buffer-values-orig-A)
|
|
|
|
|
(values-B ediff-buffer-values-orig-B)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(values-C ediff-buffer-values-orig-C)
|
|
|
|
|
(values-Ancestor ediff-buffer-values-orig-Ancestor))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-A
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-restore-variables ediff-protected-variables values-A))
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-B
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-restore-variables ediff-protected-variables values-B))
|
|
|
|
|
(if ediff-3way-comparison-job
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-buffer-C
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-restore-variables ediff-protected-variables values-C)))
|
|
|
|
|
(if (ediff-buffer-live-p ediff-ancestor-buffer)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer ediff-ancestor-buffer
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-restore-variables ediff-protected-variables values-Ancestor)))
|
|
|
|
|
))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1999-11-01 07:16:15 +00:00
|
|
|
|
;; save BUFFER in FILE. used in hooks.
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(defun ediff-save-buffer-in-file (buffer file)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
(ediff-with-current-buffer buffer
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(write-file file)))
|
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
;;; Debug
|
|
|
|
|
|
|
|
|
|
(ediff-defvar-local ediff-command-begin-time '(0 0 0) "")
|
|
|
|
|
|
|
|
|
|
;; calculate time used by command
|
|
|
|
|
(defun ediff-calc-command-time ()
|
|
|
|
|
(let ((end (current-time))
|
|
|
|
|
micro sec)
|
|
|
|
|
(setq micro
|
|
|
|
|
(if (>= (nth 2 end) (nth 2 ediff-command-begin-time))
|
|
|
|
|
(- (nth 2 end) (nth 2 ediff-command-begin-time))
|
|
|
|
|
(+ (nth 2 end) (- 1000000 (nth 2 ediff-command-begin-time)))))
|
|
|
|
|
(setq sec (- (nth 1 end) (nth 1 ediff-command-begin-time)))
|
|
|
|
|
(or (equal ediff-command-begin-time '(0 0 0))
|
|
|
|
|
(message "Elapsed time: %d second(s) + %d microsecond(s)" sec micro))))
|
|
|
|
|
|
|
|
|
|
(defsubst ediff-save-time ()
|
|
|
|
|
(setq ediff-command-begin-time (current-time)))
|
|
|
|
|
|
|
|
|
|
(defun ediff-profile ()
|
|
|
|
|
"Toggle profiling Ediff commands."
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
2001-12-24 05:50:31 +00:00
|
|
|
|
|
|
|
|
|
(if ediff-xemacs-p
|
|
|
|
|
(make-local-hook 'post-command-hook))
|
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
(let ((pre-hook 'pre-command-hook)
|
|
|
|
|
(post-hook 'post-command-hook))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(if (not (equal ediff-command-begin-time '(0 0 0)))
|
|
|
|
|
(progn (remove-hook pre-hook 'ediff-save-time)
|
|
|
|
|
(remove-hook post-hook 'ediff-calc-command-time)
|
|
|
|
|
(setq ediff-command-begin-time '(0 0 0))
|
|
|
|
|
(message "Ediff profiling disabled"))
|
2001-12-24 05:50:31 +00:00
|
|
|
|
(add-hook pre-hook 'ediff-save-time t 'local)
|
|
|
|
|
(add-hook post-hook 'ediff-calc-command-time nil 'local)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(message "Ediff profiling enabled"))))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
|
|
|
|
(defun ediff-print-diff-vector (diff-vector-var)
|
|
|
|
|
(princ (format "\n*** %S ***\n" diff-vector-var))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(mapcar (lambda (overl-vec)
|
|
|
|
|
(princ
|
|
|
|
|
(format
|
|
|
|
|
"Diff %d: \tOverlay: %S
|
1995-03-16 22:34:51 +00:00
|
|
|
|
\t\tFine diffs: %s
|
|
|
|
|
\t\tNo-fine-diff-flag: %S
|
|
|
|
|
\t\tState-of-diff:\t %S
|
|
|
|
|
\t\tState-of-merge:\t %S
|
|
|
|
|
"
|
1999-11-01 07:16:15 +00:00
|
|
|
|
(1+ (ediff-overlay-get (aref overl-vec 0) 'ediff-diff-num))
|
|
|
|
|
(aref overl-vec 0)
|
|
|
|
|
;; fine-diff-vector
|
|
|
|
|
(if (= (length (aref overl-vec 1)) 0)
|
|
|
|
|
"none\n"
|
|
|
|
|
(mapconcat 'prin1-to-string
|
|
|
|
|
(aref overl-vec 1) "\n\t\t\t "))
|
|
|
|
|
(aref overl-vec 2) ; no fine diff flag
|
|
|
|
|
(aref overl-vec 3) ; state-of-diff
|
|
|
|
|
(aref overl-vec 4) ; state-of-merge
|
|
|
|
|
)))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(eval diff-vector-var)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun ediff-debug-info ()
|
|
|
|
|
(interactive)
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-barf-if-not-control-buffer)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(with-output-to-temp-buffer ediff-debug-buffer
|
2000-11-10 22:35:35 +00:00
|
|
|
|
(ediff-with-current-buffer standard-output
|
|
|
|
|
(fundamental-mode))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
(princ (format "\nCtl buffer: %S\n" ediff-control-buffer))
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(ediff-print-diff-vector (intern "ediff-difference-vector-A"))
|
|
|
|
|
(ediff-print-diff-vector (intern "ediff-difference-vector-B"))
|
|
|
|
|
(ediff-print-diff-vector (intern "ediff-difference-vector-C"))
|
|
|
|
|
(ediff-print-diff-vector (intern "ediff-difference-vector-Ancestor"))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
))
|
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
|
|
|
|
|
;;; General utilities
|
|
|
|
|
|
|
|
|
|
;; this uses comparison-func to decide who is a member
|
|
|
|
|
(defun ediff-member (elt lis comparison-func)
|
|
|
|
|
(while (and lis (not (funcall comparison-func (car lis) elt)))
|
|
|
|
|
(setq lis (cdr lis)))
|
|
|
|
|
lis)
|
|
|
|
|
|
|
|
|
|
;; this uses comparison-func to decide who is a member, and this determines how
|
|
|
|
|
;; intersection looks like
|
|
|
|
|
(defun ediff-intersection (lis1 lis2 comparison-func)
|
|
|
|
|
(let ((result (list 'a)))
|
|
|
|
|
(while lis1
|
|
|
|
|
(if (ediff-member (car lis1) lis2 comparison-func)
|
|
|
|
|
(nconc result (list (car lis1))))
|
|
|
|
|
(setq lis1 (cdr lis1)))
|
|
|
|
|
(cdr result)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; eliminates duplicates using comparison-func
|
|
|
|
|
(defun ediff-union (lis1 lis2 comparison-func)
|
|
|
|
|
(let ((result (list 'a)))
|
|
|
|
|
(while lis1
|
|
|
|
|
(or (ediff-member (car lis1) (cdr result) comparison-func)
|
|
|
|
|
(nconc result (list (car lis1))))
|
|
|
|
|
(setq lis1 (cdr lis1)))
|
|
|
|
|
(while lis2
|
|
|
|
|
(or (ediff-member (car lis2) (cdr result) comparison-func)
|
|
|
|
|
(nconc result (list (car lis2))))
|
|
|
|
|
(setq lis2 (cdr lis2)))
|
|
|
|
|
(cdr result)))
|
|
|
|
|
|
|
|
|
|
;; eliminates duplicates using comparison-func
|
|
|
|
|
(defun ediff-set-difference (lis1 lis2 comparison-func)
|
|
|
|
|
(let ((result (list 'a)))
|
|
|
|
|
(while lis1
|
|
|
|
|
(or (ediff-member (car lis1) (cdr result) comparison-func)
|
|
|
|
|
(ediff-member (car lis1) lis2 comparison-func)
|
|
|
|
|
(nconc result (list (car lis1))))
|
|
|
|
|
(setq lis1 (cdr lis1)))
|
|
|
|
|
(cdr result)))
|
|
|
|
|
|
2000-11-10 22:35:35 +00:00
|
|
|
|
(if (fboundp 'copy-sequence)
|
|
|
|
|
(defalias 'ediff-copy-list 'copy-sequence)
|
|
|
|
|
(defun ediff-copy-list (list)
|
|
|
|
|
(if (consp list)
|
1996-02-16 06:36:35 +00:00
|
|
|
|
;;;(let ((res nil))
|
|
|
|
|
;;; (while (consp list) (push (pop list) res))
|
|
|
|
|
;;; (prog1 (nreverse res) (setcdr res list)))
|
2000-11-10 22:35:35 +00:00
|
|
|
|
(let (res elt)
|
|
|
|
|
(while (consp list)
|
|
|
|
|
(setq elt (car list)
|
|
|
|
|
res (cons elt res)
|
|
|
|
|
list (cdr list)))
|
|
|
|
|
(nreverse res))
|
|
|
|
|
(car list))))
|
1999-11-01 07:16:15 +00:00
|
|
|
|
|
1996-02-16 06:36:35 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;; don't report error if version control package wasn't found
|
|
|
|
|
;;(ediff-load-version-control 'silent)
|
|
|
|
|
|
1995-10-06 00:59:04 +00:00
|
|
|
|
(run-hooks 'ediff-load-hook)
|
1995-03-16 22:34:51 +00:00
|
|
|
|
|
1995-06-05 23:43:51 +00:00
|
|
|
|
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;;; Local Variables:
|
|
|
|
|
;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
|
1997-07-31 04:04:23 +00:00
|
|
|
|
;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
|
|
|
|
|
;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
|
1995-03-16 22:34:51 +00:00
|
|
|
|
;;; End:
|
|
|
|
|
|
|
|
|
|
;;; ediff-util.el ends here
|