From e756eb9faf8c0f3f30d6bc0b35b964d55de57382 Mon Sep 17 00:00:00 2001 From: Michael Kifer Date: Thu, 31 Jul 1997 04:04:23 +0000 Subject: [PATCH] new version --- lisp/ediff-diff.el | 91 ++++++++-------- lisp/ediff-init.el | 144 +++++++++++++++++++------ lisp/ediff-merg.el | 6 +- lisp/ediff-mult.el | 54 +++++----- lisp/ediff-ptch.el | 32 +++--- lisp/ediff-util.el | 263 ++++++++++++++++++++++----------------------- lisp/ediff-vers.el | 4 +- lisp/ediff-wind.el | 73 +++++++------ lisp/ediff.el | 18 ++-- 9 files changed, 379 insertions(+), 306 deletions(-) diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el index fc288bf933a..6a9bc8d51f8 100644 --- a/lisp/ediff-diff.el +++ b/lisp/ediff-diff.el @@ -212,7 +212,7 @@ one optional arguments, diff-number to refine.") ediff-diff-options file1 file2) ;;(message "Computing differences ... done") (message "") - (ediff-eval-in-buffer diff-buffer + (ediff-with-current-buffer diff-buffer (buffer-size)))))) @@ -283,15 +283,15 @@ one optional arguments, diff-number to refine.") (setq ediff-error-buffer (get-buffer-create (ediff-unique-buffer-name "*ediff-errors" "*")))) - (ediff-eval-in-buffer ediff-error-buffer + (ediff-with-current-buffer ediff-error-buffer (erase-buffer) - (insert (ediff-eval-in-buffer diff-buff (buffer-string))) + (insert (ediff-with-current-buffer diff-buff (buffer-string))) (goto-char (point-min)) (delete-matching-lines ok-regexp) (if (memq system-type '(vax-vms axp-vms)) (delete-matching-lines "^$"))) ;; If diff reports errors, show them then quit. - (if (/= 0 (ediff-eval-in-buffer ediff-error-buffer (buffer-size))) + (if (/= 0 (ediff-with-current-buffer ediff-error-buffer (buffer-size))) (let ((ctl-buf ediff-control-buffer) (error-buf ediff-error-buffer)) (ediff-skip-unsuitable-frames) @@ -328,15 +328,15 @@ one optional arguments, diff-number to refine.") (ediff-get-value-according-to-buffer-type 'B bounds)))) ;; reset point in buffers A/B/C - (ediff-eval-in-buffer A-buffer + (ediff-with-current-buffer A-buffer (goto-char (if shift-A shift-A (point-min)))) - (ediff-eval-in-buffer B-buffer + (ediff-with-current-buffer B-buffer (goto-char (if shift-B shift-B (point-min)))) (if (ediff-buffer-live-p C-buffer) - (ediff-eval-in-buffer C-buffer + (ediff-with-current-buffer C-buffer (goto-char (point-min)))) - (ediff-eval-in-buffer diff-buffer + (ediff-with-current-buffer diff-buffer (goto-char (point-min)) (while (re-search-forward ediff-match-diff-line nil t) (let* ((a-begin (string-to-int (buffer-substring (match-beginning 1) @@ -404,20 +404,20 @@ one optional arguments, diff-number to refine.") b-prev b-end c-prev c-end) ;; else convert lines to points - (ediff-eval-in-buffer A-buffer + (ediff-with-current-buffer A-buffer (forward-line (- a-begin a-prev)) (setq a-begin-pt (point)) (forward-line (- a-end a-begin)) (setq a-end-pt (point) a-prev a-end)) - (ediff-eval-in-buffer B-buffer + (ediff-with-current-buffer B-buffer (forward-line (- b-begin b-prev)) (setq b-begin-pt (point)) (forward-line (- b-end b-begin)) (setq b-end-pt (point) b-prev b-end)) (if (ediff-buffer-live-p C-buffer) - (ediff-eval-in-buffer C-buffer + (ediff-with-current-buffer C-buffer (forward-line (- c-begin c-prev)) (setq c-begin-pt (point)) (forward-line (- c-end c-begin)) @@ -447,7 +447,7 @@ one optional arguments, diff-number to refine.") ))) ))) - ))) ; end ediff-eval-in-buffer + ))) ; end ediff-with-current-buffer diff-list )) @@ -495,7 +495,7 @@ one optional arguments, diff-number to refine.") (setq total-diffs (length diff-list)) ;; shift, if necessary - (ediff-eval-in-buffer buff (setq pt-saved shift)) + (ediff-with-current-buffer buff (setq pt-saved shift)) (while diff-list (setq current-diff (1+ current-diff) @@ -524,12 +524,12 @@ one optional arguments, diff-number to refine.") ;; convert word numbers to points, if necessary (if (eq diff-list-type 'words) (progn - (ediff-eval-in-buffer buff (goto-char pt-saved)) + (ediff-with-current-buffer buff (goto-char pt-saved)) (setq begin (ediff-goto-word (1+ begin) buff) end (ediff-goto-word end buff 'end)) (if (> end limit) (setq end limit)) (if (> begin end) (setq begin end)) - (setq pt-saved (ediff-eval-in-buffer buff (point))))) + (setq pt-saved (ediff-with-current-buffer buff (point))))) (setq overlay (ediff-make-bullet-proof-overlay begin end buff)) (ediff-overlay-put overlay 'priority ediff-shadow-overlay-priority) @@ -553,7 +553,7 @@ one optional arguments, diff-number to refine.") (cdr diff-list)) ) ; while - (set (intern (format "ediff-difference-vector-%S" buf-type)) + (set (ediff-get-symbol-from-alist buf-type ediff-difference-vector-alist) (vconcat diff-overlay-list)) )) @@ -761,14 +761,15 @@ one optional arguments, diff-number to refine.") (face (if default 'default (face-name - (intern (format "ediff-fine-diff-face-%S" buf-type))))) + (ediff-get-symbol-from-alist + buf-type ediff-fine-diff-face-alist)))) (priority (if default 0 (1+ (or (ediff-overlay-get (symbol-value - (intern - (format - "ediff-current-diff-overlay-%S" buf-type))) + (ediff-get-symbol-from-alist + buf-type + ediff-current-diff-overlay-alist)) 'priority) 0))))) (mapcar @@ -806,7 +807,7 @@ one optional arguments, diff-number to refine.") (ediff-clear-fine-differences-in-one-buffer region-num buf-type) (setq diff-list (cdr diff-list)) ; discard list type (words or points) - (ediff-eval-in-buffer buff (goto-char reg-start)) + (ediff-with-current-buffer buff (goto-char reg-start)) ;; if it is a combined merge then set overlays in buff C specially (if (and ediff-merge-job (eq buf-type 'C) @@ -909,18 +910,18 @@ one optional arguments, diff-number to refine.") (ediff-get-value-according-to-buffer-type 'C bounds))))) ;; reset point in buffers A, B, C - (ediff-eval-in-buffer A-buffer + (ediff-with-current-buffer A-buffer (goto-char (if shift-A shift-A (point-min)))) - (ediff-eval-in-buffer B-buffer + (ediff-with-current-buffer B-buffer (goto-char (if shift-B shift-B (point-min)))) (if three-way-comp - (ediff-eval-in-buffer C-buffer + (ediff-with-current-buffer C-buffer (goto-char (if shift-C shift-C (point-min))))) (if (ediff-buffer-live-p anc-buffer) - (ediff-eval-in-buffer anc-buffer + (ediff-with-current-buffer anc-buffer (goto-char (point-min)))) - (ediff-eval-in-buffer diff-buffer + (ediff-with-current-buffer diff-buffer (goto-char (point-min)) (while (re-search-forward ediff-match-diff3-line nil t) ;; leave point after matched line @@ -983,26 +984,26 @@ one optional arguments, diff-number to refine.") b-prev b-end c-prev c-end) ;; else convert lines to points - (ediff-eval-in-buffer A-buffer + (ediff-with-current-buffer A-buffer (forward-line (- a-begin a-prev)) (setq a-begin-pt (point)) (forward-line (- a-end a-begin)) (setq a-end-pt (point) a-prev a-end)) - (ediff-eval-in-buffer B-buffer + (ediff-with-current-buffer B-buffer (forward-line (- b-begin b-prev)) (setq b-begin-pt (point)) (forward-line (- b-end b-begin)) (setq b-end-pt (point) b-prev b-end)) - (ediff-eval-in-buffer C-buffer + (ediff-with-current-buffer C-buffer (forward-line (- c-begin c-prev)) (setq c-begin-pt (point)) (forward-line (- c-end c-begin)) (setq c-end-pt (point) c-prev c-end)) (if (ediff-buffer-live-p anc-buffer) - (ediff-eval-in-buffer anc-buffer + (ediff-with-current-buffer anc-buffer (forward-line (- c-or-anc-begin anc-prev)) (setq anc-begin-pt (point)) (forward-line (- c-or-anc-end c-or-anc-begin)) @@ -1034,7 +1035,7 @@ one optional arguments, diff-number to refine.") ))) )) - ))) ; end ediff-eval-in-buffer + ))) ; end ediff-with-current-buffer diff-list )) @@ -1065,15 +1066,15 @@ one optional arguments, diff-number to refine.") ;; Execute PROGRAM asynchronously, unless OS/2, Windows-*, or DOS, or unless -;; SYNCH is non-nil. BUFFER must be a buffer object, and must be alive. All -;; arguments in ARGS must be strings. The first arg may be a blank string, in -;; which case we delete it from ARGS list. We also delete nil from args. -(defun ediff-exec-process (program buffer synch &rest args) - (let ((data (match-data))) - (if (string-match "^[ \t]*$" (car args)) ; delete blank string - (setq args (cdr args))) - (setq args (delq nil args)) ; delete nil from arguments - (setq args (ediff-split-string (mapconcat 'identity args " "))) +;; SYNCH is non-nil. BUFFER must be a buffer object, and must be alive. The +;; OPTIONS arg is a list of options to pass to PROGRAM. It may be a blank +;; string. All elements in FILES must be strings. We also delete nil from +;; args. +(defun ediff-exec-process (program buffer synch options &rest files) + (let ((data (match-data)) + args) + (setq args (append (split-string options) files)) + (setq args (delete "" (delq nil args))) ; delete nil and "" from arguments (unwind-protect (let ((directory default-directory) proc) @@ -1191,7 +1192,7 @@ argument to `skip-chars-forward'." (let (sv-point string) (save-excursion (set-buffer in-buffer) - (setq string (buffer-substring beg end)) + (setq string (buffer-substring-no-properties beg end)) (set-buffer out-buffer) (erase-buffer) @@ -1205,7 +1206,7 @@ argument to `skip-chars-forward'." ;; different invocations (if control-buf (funcall - (ediff-eval-in-buffer control-buf ediff-forward-word-function)) + (ediff-with-current-buffer control-buf ediff-forward-word-function)) (funcall ediff-forward-word-function)) (setq sv-point (point)) (skip-chars-forward ediff-whitespace) @@ -1232,7 +1233,7 @@ argument to `skip-chars-forward'." (defun ediff-goto-word (n buf &optional flag) ;; remember val ediff-forward-word-function has in ctl buf (let ((fwd-word-fun ediff-forward-word-function)) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (skip-chars-forward ediff-whitespace) (while (> n 1) (funcall fwd-word-fun) @@ -1245,8 +1246,8 @@ argument to `skip-chars-forward'." ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: diff --git a/lisp/ediff-init.el b/lisp/ediff-init.el index d825cae43f0..30e67232ba1 100644 --- a/lisp/ediff-init.el +++ b/lisp/ediff-init.el @@ -97,6 +97,13 @@ that Ediff doesn't know about.") ;; The Ediff control buffer (ediff-defvar-local ediff-control-buffer nil "") + +;; Association between buff-type and ediff-buffer-* +(defconst ediff-buffer-alist + '((?A . ediff-buffer-A) + (?B . ediff-buffer-B) + (?C . ediff-buffer-C))) + ;;; Macros (defmacro ediff-odd-p (arg) (` (eq (logand (, arg) 1) 1))) @@ -123,11 +130,26 @@ that Ediff doesn't know about.") ((memq (, arg) '(?c ?C)) 'C) ) )) + +;; A-list is supposed to be of the form (A . symb) (B . symb)...) +;; where the first part of any association is a buffer type and the second is +;; an appropriate symbol. Given buffer-type, this function returns the +;; symbol. This is used to avoid using `intern' +(defsubst ediff-get-symbol-from-alist (buf-type alist) + (cdr (assoc buf-type alist))) +(defconst ediff-difference-vector-alist + '((A . ediff-difference-vector-A) + (B . ediff-difference-vector-B) + (C . ediff-difference-vector-C) + (Ancestor . ediff-difference-vector-Ancestor))) + (defmacro ediff-get-difference (n buf-type) (` (aref (symbol-value - (intern (format "ediff-difference-vector-%S" (, buf-type)))) (, n)))) + (ediff-get-symbol-from-alist + (, buf-type) ediff-difference-vector-alist)) + (, n)))) ;; Tell if it has been previously determined that the region has ;; no diffs other than the white space and newlines @@ -189,21 +211,18 @@ that Ediff doesn't know about.") (` (ediff-get-fine-diff-vector-from-diff-record (ediff-get-difference (, n) (, buf-type))))) -;; Macro to switch to BUFFER, evaluate FORMS, returns to original buffer. -;; Differs from `save-excursion' in that it doesn't save the point and mark. -;; This is essentially `emerge-eval-in-buffer' with the test for live buffers." -(defmacro ediff-eval-in-buffer (buffer &rest forms) - (` (let ((StartBuffer (current-buffer))) - (if (ediff-buffer-live-p (, buffer)) - (unwind-protect - (progn - (set-buffer (, buffer)) - (,@ forms)) - (set-buffer StartBuffer)) - (or (eq this-command 'ediff-quit) - (error ediff-KILLED-VITAL-BUFFER)) - )))) - +;; Macro to switch to BUFFER, evaluate BODY, returns to original buffer. +;; Doesn't save the point and mark. +;; This is `with-current-buffer' with the added test for live buffers." +(defmacro ediff-with-current-buffer (buffer &rest body) + (` (if (ediff-buffer-live-p (, buffer)) + (save-current-buffer + (set-buffer (, buffer)) + (,@ body)) + (or (eq this-command 'ediff-quit) + (error ediff-KILLED-VITAL-BUFFER)) + ))) + (defsubst ediff-multiframe-setup-p () (and (ediff-window-display-p) ediff-multiframe)) @@ -561,6 +580,13 @@ ediff-toggle-hilit. Use `setq-default' to set it.") ;; The original values of ediff-protected-variables for buffer Ancestor (ediff-defvar-local ediff-buffer-values-orig-Ancestor nil "") +;; association between buff-type and ediff-buffer-values-orig-* +(defconst ediff-buffer-values-orig-alist + '((A . ediff-buffer-values-orig-A) + (B . ediff-buffer-values-orig-B) + (C . ediff-buffer-values-orig-C) + (Ancestor . ediff-buffer-values-orig-Ancestor))) + ;; Buffer-local variables to be saved then restored during Ediff sessions (defconst ediff-protected-variables '( ;;buffer-read-only @@ -585,6 +611,12 @@ ediff-toggle-hilit. Use `setq-default' to set it.") (ediff-defvar-local ediff-difference-vector-B nil "") (ediff-defvar-local ediff-difference-vector-C nil "") (ediff-defvar-local ediff-difference-vector-Ancestor nil "") +;; A-list of diff vector types associated with buffer types +(defconst ediff-difference-vector-alist + '((A . ediff-difference-vector-A) + (B . ediff-difference-vector-B) + (C . ediff-difference-vector-C) + (Ancestor . ediff-difference-vector-Ancestor))) ;; [ status status status ...] ;; Each status: [state-of-merge state-of-ancestor] @@ -743,14 +775,30 @@ appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire." (fset 'ediff-display-pixel-height (symbol-function 'x-display-pixel-height)))) +;; A-list of current-diff-overlay symbols asssociated with buf types +(defconst ediff-current-diff-overlay-alist + '((A . ediff-current-diff-overlay-A) + (B . ediff-current-diff-overlay-B) + (C . ediff-current-diff-overlay-C) + (Ancestor . ediff-current-diff-overlay-Ancestor))) + +;; A-list of current-diff-face-* symbols asssociated with buf types +(defconst ediff-current-diff-face-alist + '((A . ediff-current-diff-face-A) + (B . ediff-current-diff-face-B) + (C . ediff-current-diff-face-C) + (Ancestor . ediff-current-diff-face-Ancestor))) + (defun ediff-make-current-diff-overlay (type) (if (ediff-has-face-support-p) - (let ((overlay (intern (format "ediff-current-diff-overlay-%S" type))) + (let ((overlay (ediff-get-symbol-from-alist + type ediff-current-diff-overlay-alist)) (buffer (ediff-get-buffer type)) (face (face-name (symbol-value - (intern (format "ediff-current-diff-face-%S" type)))))) + (ediff-get-symbol-from-alist + type ediff-current-diff-face-alist))))) (set overlay (ediff-make-bullet-proof-overlay (point-max) (point-max) buffer)) (ediff-set-overlay-face (symbol-value overlay) face) @@ -1032,7 +1080,14 @@ ancestor buffer.") ediff-even-diff-pixmap))) 'ediff-even-diff-face-Ancestor)) "Face highlighting even-numbered differences in the ancestor buffer.") - + +;; Association between buffer types and even-diff-face symbols +(defconst ediff-even-diff-face-alist + '((A . ediff-even-diff-face-A) + (B . ediff-even-diff-face-B) + (C . ediff-even-diff-face-C) + (Ancestor . ediff-even-diff-face-Ancestor))) + (defvar ediff-odd-diff-face-A (if (ediff-has-face-support-p) (progn @@ -1097,6 +1152,20 @@ ancestor buffer.") 'ediff-odd-diff-face-Ancestor)) "Face used to highlight even-numbered differences in the ancestor buffer.") +;; Association between buffer types and odd-diff-face symbols +(defconst ediff-odd-diff-face-alist + '((A . ediff-odd-diff-face-A) + (B . ediff-odd-diff-face-B) + (C . ediff-odd-diff-face-C) + (Ancestor . ediff-odd-diff-face-Ancestor))) + +;; A-list of fine-diff face symbols associated with buffer types +(defconst ediff-fine-diff-face-alist + '((A . ediff-fine-diff-face-A) + (B . ediff-fine-diff-face-B) + (C . ediff-fine-diff-face-C) + (Ancestor . ediff-fine-diff-face-Ancestor))) + ;; Help echo (put 'ediff-fine-diff-face-A 'ediff-help-echo "A `refinement' of the current difference region") @@ -1118,14 +1187,14 @@ ancestor buffer.") "Overlay for the current difference region in buffer C.") (ediff-defvar-local ediff-current-diff-overlay-Ancestor nil "Overlay for the current difference region in the ancestor buffer.") - + ;; Compute priority of ediff overlay. (defun ediff-highest-priority (start end buffer) (let ((pos (max 1 (1- start))) ovr-list) (if ediff-xemacs-p (1+ ediff-shadow-overlay-priority) - (ediff-eval-in-buffer buffer + (ediff-with-current-buffer buffer (while (< pos (min (point-max) (1+ end))) (setq ovr-list (append (overlays-at pos) ovr-list)) (setq pos (next-overlay-change pos))) @@ -1240,16 +1309,18 @@ More precisely, a regexp to match any one such character.") (defsubst ediff-background-face (buf-type dif-num) ;; The value of dif-num is always 1- the one that user sees. ;; This is why even face is used when dif-num is odd. - (intern (format (if (ediff-odd-p dif-num) - "ediff-even-diff-face-%S" - "ediff-odd-diff-face-%S") - buf-type))) + (ediff-get-symbol-from-alist + buf-type (if (ediff-odd-p dif-num) + ediff-even-diff-face-alist + ediff-odd-diff-face-alist) + )) ;; activate faces on diff regions in buffer (defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight) (let ((diff-vector - (eval (intern (format "ediff-difference-vector-%S" buf-type)))) + (eval (ediff-get-symbol-from-alist + buf-type ediff-difference-vector-alist))) overl diff-num) (mapcar (function (lambda (rec) @@ -1279,14 +1350,15 @@ More precisely, a regexp to match any one such character.") (defun ediff-highlight-diff-in-one-buffer (n buf-type) (if (ediff-buffer-live-p (ediff-get-buffer buf-type)) (let* ((buff (ediff-get-buffer buf-type)) - (last (ediff-eval-in-buffer buff (point-max))) + (last (ediff-with-current-buffer buff (point-max))) (begin (ediff-get-diff-posn buf-type 'beg n)) (end (ediff-get-diff-posn buf-type 'end n)) (xtra (if (equal begin end) 1 0)) (end-hilit (min last (+ end xtra))) (current-diff-overlay (symbol-value - (intern (format "ediff-current-diff-overlay-%S" buf-type))))) + (ediff-get-symbol-from-alist + buf-type ediff-current-diff-overlay-alist)))) (if ediff-xemacs-p (ediff-move-overlay current-diff-overlay begin end-hilit) @@ -1305,7 +1377,8 @@ More precisely, a regexp to match any one such character.") (if (ediff-buffer-live-p (ediff-get-buffer buf-type)) (let ((current-diff-overlay (symbol-value - (intern (format "ediff-current-diff-overlay-%S" buf-type)))) + (ediff-get-symbol-from-alist + buf-type ediff-current-diff-overlay-alist))) (overlay (ediff-get-diff-overlay ediff-current-difference buf-type)) ) @@ -1326,7 +1399,8 @@ More precisely, a regexp to match any one such character.") (if (and (ediff-has-face-support-p) ediff-use-faces) (let* ((inhibit-quit t) (current-diff-overlay-var - (intern (format "ediff-current-diff-overlay-%S" buf-type))) + (ediff-get-symbol-from-alist + buf-type ediff-current-diff-overlay-alist)) (current-diff-overlay (symbol-value current-diff-overlay-var))) (ediff-paint-background-regions 'unhighlight) (if (ediff-overlayp current-diff-overlay) @@ -1557,7 +1631,7 @@ Checks if overlay's buffer exists." (ediff-empty-diff-region-p n buf-type) (let ((beg (ediff-get-diff-posn buf-type 'beg n)) (end (ediff-get-diff-posn buf-type 'end n))) - (ediff-eval-in-buffer (ediff-get-buffer buf-type) + (ediff-with-current-buffer (ediff-get-buffer buf-type) (save-excursion (goto-char beg) (skip-chars-forward ediff-whitespace) @@ -1632,8 +1706,8 @@ Checks if overlay's buffer exists." (defsubst ediff-get-region-contents (n buf-type ctrl-buf &optional start end) - (ediff-eval-in-buffer - (ediff-eval-in-buffer ctrl-buf (ediff-get-buffer buf-type)) + (ediff-with-current-buffer + (ediff-with-current-buffer ctrl-buf (ediff-get-buffer buf-type)) (buffer-substring (or start (ediff-get-diff-posn buf-type 'beg n ctrl-buf)) (or end (ediff-get-diff-posn buf-type 'end n ctrl-buf))))) @@ -1678,8 +1752,8 @@ Checks if overlay's buffer exists." ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: (provide 'ediff-init) diff --git a/lisp/ediff-merg.el b/lisp/ediff-merg.el index f2cdf4cbc22..142d9fc9ac2 100644 --- a/lisp/ediff-merg.el +++ b/lisp/ediff-merg.el @@ -281,7 +281,7 @@ Combining is done according to the specifications in variable reg-a-beg reg-a-end reg-b-beg reg-b-end reg-c-beg reg-c-end) (if combined - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (goto-char reg-beg) (search-forward pat1 reg-end 'noerror) (setq reg-a-beg (match-beginning 0)) @@ -300,8 +300,8 @@ Combining is done according to the specifications in variable ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: ;; ediff-merg.el ends here diff --git a/lisp/ediff-mult.el b/lisp/ediff-mult.el index c6fa5694612..98d41109bae 100644 --- a/lisp/ediff-mult.el +++ b/lisp/ediff-mult.el @@ -559,7 +559,7 @@ Moves in circular fashion. With numeric prefix arg, skip this many items." (let* ((meta-buffer-name (ediff-unique-buffer-name meta-buffer-name "*")) (meta-buffer (get-buffer-create meta-buffer-name))) - (ediff-eval-in-buffer meta-buffer + (ediff-with-current-buffer meta-buffer ;; comes first (ediff-meta-mode) @@ -662,7 +662,7 @@ Moves in circular fashion. With numeric prefix arg, skip this many items." regexp elt session-buf f1 f2 f3 pt merge-autostore-dir point tmp-list buffer-read-only) - (ediff-eval-in-buffer meta-buf + (ediff-with-current-buffer meta-buf (setq point (point)) (erase-buffer) (insert (format ediff-meta-buffer-message @@ -828,7 +828,7 @@ Moves in circular fashion. With numeric prefix arg, skip this many items." ;; skip the directory part (setq diff-list (cdr diff-list)) (setq ediff-dir-diffs-buffer (get-buffer-create buf-name)) - (ediff-eval-in-buffer ediff-dir-diffs-buffer + (ediff-with-current-buffer ediff-dir-diffs-buffer (use-local-map ediff-dir-diffs-buffer-map) (erase-buffer) (setq ediff-meta-buffer meta-buf) @@ -938,7 +938,7 @@ Useful commands: ;; argument is ignored (defun ediff-redraw-registry-buffer (&optional ignore) - (ediff-eval-in-buffer ediff-registry-buffer + (ediff-with-current-buffer ediff-registry-buffer (let ((point (point)) elt bufAname bufBname bufCname cur-diff total-diffs pt job-name meta-list registry-list buffer-read-only) @@ -975,7 +975,7 @@ Useful commands: registry-list (cdr registry-list)) (if (ediff-buffer-live-p elt) - (if (ediff-eval-in-buffer elt + (if (ediff-with-current-buffer elt (setq job-name ediff-metajob-name meta-list ediff-meta-list) (and ediff-metajob-name @@ -1000,7 +1000,7 @@ Useful commands: "")))) (ediff-set-meta-overlay pt (point) elt)) (progn - (ediff-eval-in-buffer elt + (ediff-with-current-buffer elt (setq bufAname (if (ediff-buffer-live-p ediff-buffer-A) (buffer-name ediff-buffer-A) "!!!killed buffer!!!") @@ -1143,7 +1143,7 @@ Useful commands: (metajob ediff-metajob-name) tmp-buf custom-diff-buf) (if (ediff-buffer-live-p session-buf) - (ediff-eval-in-buffer session-buf + (ediff-with-current-buffer session-buf (if (eq ediff-control-buffer session-buf) ; individual session (progn (ediff-compute-custom-diffs-maybe) @@ -1191,7 +1191,7 @@ all marked sessions must be active." (setq ediff-meta-diff-buffer (get-buffer-create (ediff-unique-buffer-name "*Ediff Multifile Diffs" "*")))) - (ediff-eval-in-buffer ediff-meta-diff-buffer + (ediff-with-current-buffer ediff-meta-diff-buffer (erase-buffer)) (if (> (ediff-operate-on-marked-sessions 'ediff-append-custom-diff) 0) ;; did something @@ -1207,7 +1207,7 @@ all marked sessions must be active." (info (ediff-get-meta-info meta-buf pos 'noerror)) (patchbuffer ediff-meta-patchbufer)) (if (ediff-buffer-live-p patchbuffer) - (ediff-eval-in-buffer patchbuffer + (ediff-with-current-buffer patchbuffer (save-restriction (if (not info) (widen) @@ -1249,7 +1249,7 @@ all marked sessions must be active." (ediff-update-meta-buffer meta-buf)) (error "Aborted")))) - (ediff-eval-in-buffer meta-buf + (ediff-with-current-buffer meta-buf (setq merge-autostore-dir (ediff-get-group-merge-autostore-dir ediff-meta-list)) (goto-char pos) ; if the user clicked on session--move point there @@ -1299,7 +1299,7 @@ all marked sessions must be active." ;; handle an individual session with a live control buffer ((ediff-buffer-live-p session-buf) - (ediff-eval-in-buffer session-buf + (ediff-with-current-buffer session-buf (setq ediff-mouse-pixel-position (mouse-pixel-position)) (ediff-recenter 'no-rehighlight))) @@ -1387,18 +1387,18 @@ all marked sessions must be active." (if (ediff-buffer-live-p ctl-buf) ;; check if this is ediff-control-buffer or ediff-meta-buffer - (if (ediff-eval-in-buffer ctl-buf + (if (ediff-with-current-buffer ctl-buf (eq (key-binding "q") 'ediff-quit-meta-buffer)) ;; it's a meta-buffer -- last action should just display it (ediff-show-meta-buffer ctl-buf) ;; it's a session buffer -- invoke go back to session - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (setq ediff-mouse-pixel-position (mouse-pixel-position)) (ediff-recenter 'no-rehighlight))) (beep) (message "You've selected a stale session --- try again") (ediff-update-registry)) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (goto-char pos)) )) @@ -1417,7 +1417,7 @@ all marked sessions must be active." "Can't find this session's group panel -- session itself is ok"))) (ediff-cleanup-meta-buffer meta-buf) - (ediff-eval-in-buffer meta-buf + (ediff-with-current-buffer meta-buf (save-excursion (cond ((setq wind (ediff-get-visible-buffer-window meta-buf)) (or silent @@ -1461,7 +1461,7 @@ all marked sessions must be active." (meta-buf (ediff-event-buffer last-command-event)) (info (ediff-get-meta-info meta-buf pos)) (meta-or-session-buf info)) - (ediff-eval-in-buffer meta-or-session-buf + (ediff-with-current-buffer meta-or-session-buf (ediff-show-meta-buffer)))) ;;;###autoload @@ -1474,7 +1474,7 @@ all marked sessions must be active." (let (wind frame) ;; for some reason, point moves in ediff-registry-buffer, so we preserve it ;; explicitly - (ediff-eval-in-buffer ediff-registry-buffer + (ediff-with-current-buffer ediff-registry-buffer (save-excursion (cond ((setq wind (ediff-get-visible-buffer-window ediff-registry-buffer)) @@ -1516,14 +1516,14 @@ all marked sessions must be active." ;; parent meta-buf ;; Check if META-BUF exists before calling this function (defun ediff-update-meta-buffer (meta-buf) - (ediff-eval-in-buffer (current-buffer) + (ediff-with-current-buffer (current-buffer) (if (ediff-buffer-live-p meta-buf) - (ediff-eval-in-buffer meta-buf + (ediff-with-current-buffer meta-buf (funcall ediff-meta-redraw-function ediff-meta-list)) ))) (defun ediff-update-registry () - (ediff-eval-in-buffer (current-buffer) + (ediff-with-current-buffer (current-buffer) (if (ediff-buffer-live-p ediff-registry-buffer) (ediff-redraw-registry-buffer) (ediff-prepare-meta-buffer @@ -1538,7 +1538,7 @@ all marked sessions must be active." ;; Otherwise, nothing happens. (defun ediff-cleanup-meta-buffer (meta-buffer) (if (ediff-buffer-live-p meta-buffer) - (ediff-eval-in-buffer meta-buffer + (ediff-with-current-buffer meta-buffer (ediff-update-meta-buffer meta-buffer) (if (ediff-buffer-live-p ediff-parent-meta-buffer) (ediff-update-meta-buffer ediff-parent-meta-buffer))))) @@ -1550,7 +1550,7 @@ all marked sessions must be active." (cont t) buffer-read-only) (ediff-update-meta-buffer meta-buffer) - (ediff-eval-in-buffer meta-buffer + (ediff-with-current-buffer meta-buffer (setq lis (cdr lis)) ; discard the description part of meta-list (while (and cont lis) (if (ediff-buffer-live-p @@ -1596,7 +1596,7 @@ If this is a session registry buffer then just bury it." (defun ediff-dispose-of-meta-buffer (buf) (setq ediff-session-registry (delq buf ediff-session-registry)) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (if (ediff-buffer-live-p ediff-dir-diffs-buffer) (kill-buffer ediff-dir-diffs-buffer))) (kill-buffer buf)) @@ -1609,7 +1609,7 @@ If this is a session registry buffer then just bury it." (defun ediff-get-meta-info (buf point &optional noerror) (let (result olist tmp) (if (and point (ediff-buffer-live-p buf)) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (if ediff-xemacs-p (setq result (if (setq tmp (extent-at point buf 'ediff-meta-info)) @@ -1702,7 +1702,7 @@ If this is a session registry buffer then just bury it." (error "Patch has been already applied to this file--cannot be repeated!")) - (ediff-eval-in-buffer meta-patchbuf + (ediff-with-current-buffer meta-patchbuf (save-restriction (widen) (narrow-to-region beg-marker end-marker) @@ -1747,8 +1747,8 @@ This is used only for sessions that involve 2 or 3 files at the same time." ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: ;;; ediff-mult.el ends here diff --git a/lisp/ediff-ptch.el b/lisp/ediff-ptch.el index ca63ce1830b..901e6053986 100644 --- a/lisp/ediff-ptch.el +++ b/lisp/ediff-ptch.el @@ -155,7 +155,7 @@ program." ;; no longer used ;; return the number of matches of regexp in buf starting from the beginning (defun ediff-count-matches (regexp buf) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (let ((count 0) opoint) (save-excursion (goto-char (point-min)) @@ -174,7 +174,7 @@ program." ;; it for the end. This list is then assigned to ediff-patch-map. ;; Returns the number of elements in the list ediff-patch-map (defun ediff-map-patch-buffer (buf) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (let ((count 0) (mark1 (move-marker (make-marker) (point-min))) (mark1-end (point-min)) @@ -403,7 +403,7 @@ Else, read patch file into a new buffer." (read-file-name "Which file contains the patch? " dir nil 'must-match)))) - (ediff-eval-in-buffer patch-buf + (ediff-with-current-buffer patch-buf (goto-char (point-min)) (or (ediff-get-visible-buffer-window patch-buf) (progn @@ -418,7 +418,7 @@ Else, read patch file into a new buffer." ;; Should return either the ctl buffer or the meta-buffer (defun ediff-dispatch-file-patching-job (patch-buf filename &optional startup-hooks) - (ediff-eval-in-buffer patch-buf + (ediff-with-current-buffer patch-buf ;; relativize names in the patch with respect to source-file (ediff-fixup-patch-map filename) (if (< (length ediff-patch-map) 2) @@ -438,7 +438,7 @@ Else, read patch file into a new buffer." (let* ((buf-to-patch (get-buffer buf-to-patch-name)) (file-name-ok (if buf-to-patch (buffer-file-name buf-to-patch))) (buf-mod-status (buffer-modified-p buf-to-patch)) - (multifile-patch-p (> (length (ediff-eval-in-buffer patch-buf + (multifile-patch-p (> (length (ediff-with-current-buffer patch-buf ediff-patch-map)) 1)) default-dir file-name ctl-buf) (if file-name-ok @@ -446,7 +446,7 @@ Else, read patch file into a new buffer." (if multifile-patch-p (error "Can't apply multi-file patches to buffers that visit no files")) - (ediff-eval-in-buffer buf-to-patch + (ediff-with-current-buffer buf-to-patch (setq default-dir default-directory) (setq file-name (ediff-make-temp-file buf-to-patch)) (set-visited-file-name file-name) @@ -466,15 +466,15 @@ Else, read patch file into a new buffer." () ;; buffer wasn't visiting any file, ;; so we will not run meta-level ediff here - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (delete-file (buffer-file-name ediff-buffer-A)) (delete-file (buffer-file-name ediff-buffer-B)) - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (if default-dir (setq default-directory default-dir)) (set-visited-file-name nil) (rename-buffer buf-to-patch-name) (set-buffer-modified-p buf-mod-status)) - (ediff-eval-in-buffer ediff-buffer-B + (ediff-with-current-buffer ediff-buffer-B (setq buffer-auto-save-file-name nil) ; don't create auto-save file (if default-dir (setq default-directory default-dir)) (set-visited-file-name nil) @@ -496,7 +496,7 @@ Else, read patch file into a new buffer." (true-source-filename source-filename) (target-filename source-filename) target-buf buf-to-patch file-name-magic-p - patch-return-code ctl-buf backup-style) + patch-return-code ctl-buf backup-style aux-wind) (if (string-match "-V" ediff-patch-options) (error @@ -520,7 +520,7 @@ Else, read patch file into a new buffer." ;; could be checked back in. (ediff-maybe-checkout buf-to-patch) - (ediff-eval-in-buffer patch-diagnostics + (ediff-with-current-buffer patch-diagnostics (insert-buffer patch-buf) (message "Applying patch ... ") ;; fix environment for gnu patch, so it won't make numbered extensions @@ -593,7 +593,7 @@ In particular, check the documentation for `ediff-backup-specs'. " ;; old-name_orig) and the result of patching will have the same name as ;; the original. (if (not file-name-magic-p) - (ediff-eval-in-buffer buf-to-patch + (ediff-with-current-buffer buf-to-patch (set-visited-file-name (concat source-filename ediff-backup-extension)) (set-buffer-modified-p nil)) @@ -626,7 +626,7 @@ In particular, check the documentation for `ediff-backup-specs'. " (ediff-buffers-internal buf-to-patch target-buf nil startup-hooks 'epatch)) - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (setq ediff-patchbufer patch-buf ediff-patch-diagnostics patch-diagnostics)) @@ -648,7 +648,7 @@ In particular, check the documentation for `ediff-backup-specs'. " startup-hooks)) (setq meta-buf (ediff-prepare-meta-buffer 'ediff-filegroup-action - (ediff-eval-in-buffer patch-buf + (ediff-with-current-buffer patch-buf ;; nil replaces a regular expression (cons (list nil (format "%S" patch-buf)) ediff-patch-map)) @@ -664,8 +664,8 @@ In particular, check the documentation for `ediff-backup-specs'. " ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: ;;; ediff-ptch.el ends here diff --git a/lisp/ediff-util.el b/lisp/ediff-util.el index a87e4549648..0d0cf25a903 100644 --- a/lisp/ediff-util.el +++ b/lisp/ediff-util.el @@ -260,9 +260,9 @@ to invocation.") (ediff-convert-standard-filename (expand-file-name file-C)))) (let* ((control-buffer-name (ediff-unique-buffer-name "*Ediff Control Panel" "*")) - (control-buffer (ediff-eval-in-buffer buffer-A + (control-buffer (ediff-with-current-buffer buffer-A (get-buffer-create control-buffer-name)))) - (ediff-eval-in-buffer control-buffer + (ediff-with-current-buffer control-buffer (ediff-mode) (make-local-variable 'ediff-use-long-help-message) @@ -325,7 +325,7 @@ to invocation.") (save-excursion (set-buffer buffer-C) (insert-buffer buf) - (funcall (ediff-eval-in-buffer buf major-mode)) + (funcall (ediff-with-current-buffer buf major-mode)) ;; after Stig@hackvan.com (add-hook 'local-write-file-hooks 'ediff-set-merge-mode nil t) ))) @@ -354,12 +354,12 @@ to invocation.") (setq ediff-error-buffer (get-buffer-create (ediff-unique-buffer-name "*ediff-errors" "*"))) - (ediff-eval-in-buffer buffer-A (ediff-strip-mode-line-format)) - (ediff-eval-in-buffer buffer-B (ediff-strip-mode-line-format)) + (ediff-with-current-buffer buffer-A (ediff-strip-mode-line-format)) + (ediff-with-current-buffer buffer-B (ediff-strip-mode-line-format)) (if ediff-3way-job - (ediff-eval-in-buffer buffer-C (ediff-strip-mode-line-format))) + (ediff-with-current-buffer buffer-C (ediff-strip-mode-line-format))) (if (ediff-buffer-live-p ediff-ancestor-buffer) - (ediff-eval-in-buffer ediff-ancestor-buffer + (ediff-with-current-buffer ediff-ancestor-buffer (ediff-strip-mode-line-format))) (ediff-save-protected-variables) ; save variables to be restored on exit @@ -392,13 +392,13 @@ to invocation.") (or ediff-narrow-bounds (setq ediff-narrow-bounds ediff-wide-bounds)) - ;; All these must be inside ediff-eval-in-buffer control-buffer, + ;; All these must be inside ediff-with-current-buffer control-buffer, ;; since these vars are local to control-buffer ;; These won't run if there are errors in diff - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (ediff-nuke-selective-display) (run-hooks 'ediff-prepare-buffer-hook) - (if (ediff-eval-in-buffer control-buffer ediff-merge-job) + (if (ediff-with-current-buffer control-buffer ediff-merge-job) (setq buffer-read-only t)) ;; add control-buffer to the list of sessions--no longer used, but may ;; be used again in the future @@ -409,10 +409,10 @@ to invocation.") (setq buffer-read-only t)) ) - (ediff-eval-in-buffer ediff-buffer-B + (ediff-with-current-buffer ediff-buffer-B (ediff-nuke-selective-display) (run-hooks 'ediff-prepare-buffer-hook) - (if (ediff-eval-in-buffer control-buffer ediff-merge-job) + (if (ediff-with-current-buffer control-buffer ediff-merge-job) (setq buffer-read-only t)) ;; add control-buffer to the list of sessions (or (memq control-buffer ediff-this-buffer-ediff-sessions) @@ -423,7 +423,7 @@ to invocation.") ) (if ediff-3way-job - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (ediff-nuke-selective-display) (run-hooks 'ediff-prepare-buffer-hook) ;; add control-buffer to the list of sessions @@ -436,7 +436,7 @@ to invocation.") )) (if (ediff-buffer-live-p ediff-ancestor-buffer) - (ediff-eval-in-buffer ediff-ancestor-buffer + (ediff-with-current-buffer ediff-ancestor-buffer (ediff-nuke-selective-display) (setq buffer-read-only t) (run-hooks 'ediff-prepare-buffer-hook) @@ -548,27 +548,19 @@ if necessary." (interactive) (ediff-barf-if-not-control-buffer) (if (and (ediff-buffer-live-p ediff-ancestor-buffer) - (not (y-or-n-p "Recompute differences during merge, really? "))) - (error "Recomputation of differences cancelled")) + (not + (y-or-n-p + "Ancestor buffer will not be used. Recompute diffs anyway? "))) + (error "Recomputation of differences canceled")) - (let ((point-A (ediff-eval-in-buffer ediff-buffer-A (point))) - ;;(point-B (ediff-eval-in-buffer ediff-buffer-B (point))) + (let ((point-A (ediff-with-current-buffer ediff-buffer-A (point))) + ;;(point-B (ediff-with-current-buffer ediff-buffer-B (point))) (tmp-buffer (get-buffer-create ediff-tmp-buffer)) - (buf-A-file-name - (file-name-nondirectory (or (buffer-file-name ediff-buffer-A) - (buffer-name ediff-buffer-A) - ))) - (buf-B-file-name - (file-name-nondirectory (or (buffer-file-name ediff-buffer-B) - (buffer-name ediff-buffer-B) - ))) - (buf-C-file-name - (file-name-nondirectory (or (buffer-file-name ediff-buffer-C) - ;; if (null ediff-buffer-C), there is - ;; no danger, since we later check if - ;; ediff-buffer-C is alive - (buffer-name ediff-buffer-C) - ))) + (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)) (overl-A (ediff-get-value-according-to-buffer-type 'A ediff-narrow-bounds)) (overl-B (ediff-get-value-according-to-buffer-type @@ -577,6 +569,14 @@ if necessary." 'C ediff-narrow-bounds)) beg-A end-A beg-B end-B beg-C end-C file-A file-B file-C) + + (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))) + (ediff-unselect-and-select-difference -1) (setq beg-A (ediff-overlay-start overl-A) @@ -659,13 +659,13 @@ if necessary." (ancestor-job ediff-merge-with-ancestor-job) (merge ediff-merge-job) (comparison ediff-3way-comparison-job)) - (ediff-eval-in-buffer bufA + (ediff-with-current-buffer bufA (revert-buffer t noconfirm)) - (ediff-eval-in-buffer bufB + (ediff-with-current-buffer bufB (revert-buffer t noconfirm)) ;; this should only be executed in a 3way comparison, not in merge (if comparison - (ediff-eval-in-buffer bufC + (ediff-with-current-buffer bufC (revert-buffer t noconfirm))) (if merge (progn @@ -753,7 +753,7 @@ Reestablish the default three-window display." (if ediff-3way-job (ediff-recenter-one-window 'C)) - (ediff-eval-in-buffer control-buf + (ediff-with-current-buffer control-buf (ediff-recenter-ancestor) ; check if ancestor is alive (if (and (ediff-multiframe-setup-p) @@ -766,7 +766,7 @@ Reestablish the default three-window display." )) (ediff-restore-highlighting) - (ediff-eval-in-buffer control-buf (ediff-refresh-mode-lines)) + (ediff-with-current-buffer control-buf (ediff-refresh-mode-lines)) )) ;; this function returns to the window it was called from @@ -780,7 +780,8 @@ Reestablish the default three-window display." buf-type ediff-narrow-bounds))) (job-name ediff-job-name) (control-buf ediff-control-buffer) - (window-name (intern (format "ediff-window-%S" buf-type))) + (window-name (ediff-get-symbol-from-alist + buf-type ediff-window-alist)) (window (if (window-live-p (symbol-value window-name)) (symbol-value window-name)))) @@ -808,7 +809,7 @@ Reestablish the default three-window display." (ctl-wind (selected-window)) (job-name ediff-job-name) (ctl-buf ediff-control-buffer)) - (ediff-eval-in-buffer ediff-ancestor-buffer + (ediff-with-current-buffer ediff-ancestor-buffer (goto-char (ediff-get-diff-posn 'Ancestor 'beg nil ctl-buf)) (if window (progn @@ -960,7 +961,7 @@ of the current buffer." (or buf (setq buf (ediff-get-buffer buf-type))) - (ediff-eval-in-buffer buf ; eval in buf A/B/C + (ediff-with-current-buffer buf ; eval in buf A/B/C (let* ((file (buffer-file-name buf)) (file-writable (and file (file-exists-p file) @@ -990,7 +991,7 @@ of the current buffer." ;; 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. - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (ediff-change-saved-variable 'buffer-read-only nil buf-type))) (t @@ -1027,7 +1028,7 @@ of the current buffer." (format "File %s is under version control. Check it out? " (ediff-abbreviate-file-name file)))) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (command-execute checkout-function))))) @@ -1178,7 +1179,7 @@ This is especially useful when comparing buffers side-by-side." (let ((ctl-buf ediff-control-buffer)) (setq ediff-wide-display-p (not ediff-wide-display-p)) (if (not ediff-wide-display-p) - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (modify-frame-parameters ediff-wide-display-frame ediff-wide-display-orig-parameters) ;;(sit-for (if ediff-xemacs-p 0.4 0)) @@ -1190,7 +1191,7 @@ This is especially useful when comparing buffers side-by-side." (ediff-recenter 'no-rehighlight)) (funcall ediff-make-wide-display-function) ;;(sit-for (if ediff-xemacs-p 0.4 0)) - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (setq ediff-window-B nil) ; force update of window config (ediff-recenter 'no-rehighlight))))) @@ -1216,7 +1217,7 @@ which see." (setq-default ediff-window-setup-function window-setup-func) ;; change in all active ediff sessions (mapcar (function (lambda(buf) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (setq ediff-window-setup-function window-setup-func ediff-window-B nil)))) ediff-session-registry) @@ -1241,7 +1242,7 @@ To change the default, set the variable `ediff-use-toolbar-p', which see." (setq ediff-use-toolbar-p (not ediff-use-toolbar-p)) (mapcar (function (lambda(buf) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf ;; force redisplay (setq ediff-window-config-saved "") ))) @@ -1331,15 +1332,15 @@ Used in ediff-windows/regions only." (overl-C (ediff-get-value-according-to-buffer-type 'C ediff-visible-bounds)) ) - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (narrow-to-region (ediff-overlay-start overl-A) (ediff-overlay-end overl-A))) - (ediff-eval-in-buffer ediff-buffer-B + (ediff-with-current-buffer ediff-buffer-B (narrow-to-region (ediff-overlay-start overl-B) (ediff-overlay-end overl-B))) (if ediff-3way-job - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (narrow-to-region (ediff-overlay-start overl-C) (ediff-overlay-end overl-C)))) ))) @@ -1522,13 +1523,14 @@ the width of the A/B/C windows." (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)) - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (let* ((buf (ediff-get-buffer buf-type)) - (wind (eval (intern (format "ediff-window-%S" buf-type)))) + (wind (eval (ediff-get-symbol-from-alist + buf-type ediff-window-alist))) (beg (window-start wind)) (end (ediff-get-diff-posn buf-type 'end)) lines) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (if (< beg end) (setq lines (count-lines beg end)) (setq lines 0)) @@ -1539,12 +1541,13 @@ the width of the A/B/C windows." (defun ediff-get-lines-to-region-start (buf-type &optional n ctl-buf) (or n (setq n ediff-current-difference)) (or ctl-buf (setq ctl-buf ediff-control-buffer)) - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (let* ((buf (ediff-get-buffer buf-type)) - (wind (eval (intern (format "ediff-window-%S" buf-type)))) + (wind (eval (ediff-get-symbol-from-alist + buf-type ediff-window-alist))) (end (window-end wind)) (beg (ediff-get-diff-posn buf-type 'beg))) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (if (< beg end) (count-lines beg end) 0)) ))) @@ -1557,7 +1560,7 @@ the width of the A/B/C windows." ;; ;; If the difference region is invalid, the coefficient is 1 (defun ediff-get-region-size-coefficient (buf-type op &optional n ctl-buf) - (ediff-eval-in-buffer (or ctl-buf ediff-control-buffer) + (ediff-with-current-buffer (or ctl-buf ediff-control-buffer) (if (ediff-valid-difference-p n) (let* ((func (cond ((eq op 'scroll-down) 'ediff-get-lines-to-region-start) @@ -1684,11 +1687,11 @@ in the specified buffer." (ediff-barf-if-not-control-buffer) (let* ((buf-type (ediff-char-to-buftype last-command-char)) (buffer (ediff-get-buffer buf-type)) - (pt (ediff-eval-in-buffer buffer (point))) + (pt (ediff-with-current-buffer buffer (point))) (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 - (ediff-eval-in-buffer buffer (point-max)) + (ediff-with-current-buffer buffer (point-max)) (ediff-get-diff-posn buf-type 'beg (1- diff-no)))) ctl-wind wind-A wind-B wind-C shift) @@ -1701,7 +1704,7 @@ in the specified buffer." wind-C ediff-window-C) (if arg (progn - (ediff-eval-in-buffer buffer + (ediff-with-current-buffer buffer (setq shift (- beg pt))) (select-window wind-A) (if past-last-diff (goto-char (point-max))) @@ -1745,7 +1748,7 @@ in the specified buffer." (beg 0) (end 0)) - (ediff-eval-in-buffer buffer + (ediff-with-current-buffer buffer (setq pos (or pos (point))) (while (and (or (< pos prev-beg) (> pos beg)) (< diff-no max-dif-num)) @@ -1873,7 +1876,7 @@ ARG is a prefix argument. If nil, copy the current difference region." (if (or batch-invocation (ediff-test-save-region n to-buf-type)) (condition-case conds (progn - (ediff-eval-in-buffer to-buf + (ediff-with-current-buffer to-buf ;; to prevent flags from interfering if buffer is writable (let ((inhibit-read-only (null buffer-read-only))) @@ -1977,7 +1980,7 @@ ARG is a prefix argument. If nil, copy the current difference region." (setq reg-end (ediff-get-diff-posn buf-type 'end n ediff-control-buffer)) (condition-case conds - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (let ((inhibit-read-only (null buffer-read-only))) (goto-char reg-end) @@ -2159,21 +2162,21 @@ the number seen by the user." (regex-A ediff-regexp-focus-A) (regex-B ediff-regexp-focus-B) (regex-C ediff-regexp-focus-C) - (reg-A-match (ediff-eval-in-buffer ediff-buffer-A + (reg-A-match (ediff-with-current-buffer ediff-buffer-A (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)))) - (reg-B-match (ediff-eval-in-buffer ediff-buffer-B + (reg-B-match (ediff-with-current-buffer ediff-buffer-B (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)))) (reg-C-match (if ediff-3way-comparison-job - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (save-restriction (narrow-to-region (ediff-get-diff-posn 'C 'beg n ctl-buf) @@ -2200,14 +2203,14 @@ the number seen by the user." (regex-A ediff-regexp-hide-A) (regex-B ediff-regexp-hide-B) (regex-C ediff-regexp-hide-C) - (reg-A-match (ediff-eval-in-buffer ediff-buffer-A + (reg-A-match (ediff-with-current-buffer ediff-buffer-A (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)))) - (reg-B-match (ediff-eval-in-buffer ediff-buffer-B + (reg-B-match (ediff-with-current-buffer ediff-buffer-B (save-restriction (narrow-to-region (ediff-get-diff-posn 'B 'beg n ctl-buf) @@ -2215,7 +2218,7 @@ the number seen by the user." (goto-char (point-min)) (re-search-forward regex-B nil t)))) (reg-C-match (if ediff-3way-comparison-job - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (save-restriction (narrow-to-region (ediff-get-diff-posn 'C 'beg n ctl-buf) @@ -2295,7 +2298,7 @@ temporarily reverses the meaning of this variable." (window-frame ediff-window-B)) (t (next-frame)))))) (condition-case nil - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (setq ediff-this-buffer-ediff-sessions (delq control-buffer ediff-this-buffer-ediff-sessions)) (kill-local-variable 'mode-line-buffer-identification) @@ -2304,7 +2307,7 @@ temporarily reverses the meaning of this variable." (error)) (condition-case nil - (ediff-eval-in-buffer ediff-buffer-B + (ediff-with-current-buffer ediff-buffer-B (setq ediff-this-buffer-ediff-sessions (delq control-buffer ediff-this-buffer-ediff-sessions)) (kill-local-variable 'mode-line-buffer-identification) @@ -2313,7 +2316,7 @@ temporarily reverses the meaning of this variable." (error)) (condition-case nil - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (setq ediff-this-buffer-ediff-sessions (delq control-buffer ediff-this-buffer-ediff-sessions)) (kill-local-variable 'mode-line-buffer-identification) @@ -2322,7 +2325,7 @@ temporarily reverses the meaning of this variable." (error)) (condition-case nil - (ediff-eval-in-buffer ediff-ancestor-buffer + (ediff-with-current-buffer ediff-ancestor-buffer (setq ediff-this-buffer-ediff-sessions (delq control-buffer ediff-this-buffer-ediff-sessions)) (kill-local-variable 'mode-line-buffer-identification) @@ -2494,7 +2497,7 @@ only if this merge job is part of a group, i.e., was invoked from within (ediff-write-merge-buffer-and-maybe-kill ediff-buffer-C merge-store-file nil save-and-continue)) ((and (ediff-buffer-live-p ediff-meta-buffer) - (ediff-eval-in-buffer ediff-meta-buffer + (ediff-with-current-buffer ediff-meta-buffer (ediff-merge-metajob))) ;; This case shouldn't occur, as the parent metajob must pass on ;; a file name, ediff-merge-store-file, where to save the result @@ -2511,7 +2514,7 @@ only if this merge job is part of a group, i.e., was invoked from within (defun ediff-write-merge-buffer-and-maybe-kill (buf file &optional show-file save-and-continue) - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (if (or (not (file-exists-p file)) (y-or-n-p (format "File %s exists, overwrite? " file))) (progn @@ -2605,20 +2608,20 @@ Hit \\[ediff-recenter] to reset the windows afterward." (raise-frame (selected-frame)) (princ (ediff-version)) (princ "\n\n") - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (if buffer-file-name (princ (format "File A = %S\n" buffer-file-name)) (princ (format "Buffer A = %S\n" (buffer-name))))) - (ediff-eval-in-buffer ediff-buffer-B + (ediff-with-current-buffer ediff-buffer-B (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 - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (if buffer-file-name (princ (format "File C = %S\n" buffer-file-name)) @@ -2635,16 +2638,16 @@ Hit \\[ediff-recenter] to reset the windows afterward." (buffer-name ediff-diff-buffer)) " is not available"))) - (let* ((A-line (ediff-eval-in-buffer ediff-buffer-A + (let* ((A-line (ediff-with-current-buffer ediff-buffer-A (1+ (count-lines (point-min) (point))))) - (B-line (ediff-eval-in-buffer ediff-buffer-B + (B-line (ediff-with-current-buffer ediff-buffer-B (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 - (setq C-line (ediff-eval-in-buffer ediff-buffer-C + (setq C-line (ediff-with-current-buffer ediff-buffer-C (1+ (count-lines (point-min) (point))))) (princ (format "Buffer C's point is on line %d\n" C-line))))) @@ -2780,7 +2783,7 @@ Hit \\[ediff-recenter] to reset the windows afterward." (setq ediff-current-difference n) ) ; end protected section - (ediff-eval-in-buffer control-buf (ediff-refresh-mode-lines)) + (ediff-with-current-buffer control-buf (ediff-refresh-mode-lines)) ))) @@ -2861,7 +2864,7 @@ Hit \\[ediff-recenter] to reset the windows afterward." (t (make-temp-name f)))) ;; create the file - (ediff-eval-in-buffer buff + (ediff-with-current-buffer buff (write-region (if start start (point-min)) (if end end (point-max)) f @@ -2926,7 +2929,7 @@ Without an argument, it saves customized diff argument, if available (interactive "P") (ediff-barf-if-not-control-buffer) (ediff-compute-custom-diffs-maybe) - (ediff-eval-in-buffer + (ediff-with-current-buffer (cond ((memq last-command-char '(?a ?b ?c)) (ediff-get-buffer (ediff-char-to-buftype last-command-char))) @@ -2983,7 +2986,7 @@ Without an argument, it saves customized diff argument, if available nil)))) (if buf (progn - (ediff-eval-in-buffer buf + (ediff-with-current-buffer buf (goto-char (point-min))) (switch-to-buffer buf) (raise-frame (selected-frame))))) @@ -3032,7 +3035,8 @@ Ediff Control Panel to restore highlighting." (setq possibilities (delq answer possibilities)) (setq bufA (eval - (intern (format "ediff-buffer-%c" answer)))) + (ediff-get-symbol-from-alist + answer ediff-buffer-alist))) nil) ((equal answer "")) (t (beep 1) @@ -3050,7 +3054,8 @@ Ediff Control Panel to restore highlighting." (setq possibilities (delq answer possibilities)) (setq bufB (eval - (intern (format "ediff-buffer-%c" answer)))) + (ediff-get-symbol-from-alist + answer ediff-buffer-alist))) nil) ((equal answer "")) (t (beep 1) @@ -3068,7 +3073,7 @@ Ediff Control Panel to restore highlighting." bufB ediff-buffer-B possibilities nil))) - (ediff-eval-in-buffer bufA + (ediff-with-current-buffer bufA (or (mark t) (error "You forgot to specify a region in buffer %s" (buffer-name))) (setq begA (region-beginning) @@ -3080,7 +3085,7 @@ Ediff Control Panel to restore highlighting." (end-of-line) (or (eobp) (forward-char)) ; include the newline char (setq endA (point))) - (ediff-eval-in-buffer bufB + (ediff-with-current-buffer bufB (or (mark t) (error "You forgot to specify a region in buffer %s" (buffer-name))) (setq begB (region-beginning) @@ -3097,14 +3102,14 @@ Ediff Control Panel to restore highlighting." ediff-current-difference 'unselect-only) (ediff-paint-background-regions 'unhighlight) - (ediff-eval-in-buffer bufA + (ediff-with-current-buffer bufA (goto-char begA) (set-mark endA) (narrow-to-region begA endA) ;; (ediff-activate-mark) ) ;; (sit-for 0) - (ediff-eval-in-buffer bufB + (ediff-with-current-buffer bufB (goto-char begB) (set-mark endB) (narrow-to-region begB endB) @@ -3116,11 +3121,11 @@ Ediff Control Panel to restore highlighting." ;; that was not selected, or it is nil. We delete the window that is not ;; selected. (if possibilities - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (let* ((wind-to-delete (eval - (intern - (format - "ediff-window-%c" (car possibilities))))) + (ediff-get-symbol-from-alist + (car possibilities) + ediff-window-alist))) (frame (window-frame wind-to-delete))) (delete-window wind-to-delete) (select-frame frame) @@ -3129,12 +3134,12 @@ Ediff Control Panel to restore highlighting." "Please check regions selected for comparison. Continue? ") (setq quit-now t)) - (ediff-eval-in-buffer bufA + (ediff-with-current-buffer bufA (widen)) - (ediff-eval-in-buffer bufB + (ediff-with-current-buffer bufB (widen)) (if quit-now - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (ediff-recenter) (sit-for 0) (error "All right. Make up your mind and come back..."))) @@ -3151,7 +3156,7 @@ Ediff Control Panel to restore highlighting." (defun ediff-remove-flags-from-buffer (buffer overlay) - (ediff-eval-in-buffer buffer + (ediff-with-current-buffer buffer (let ((inhibit-read-only t)) (if ediff-xemacs-p (ediff-overlay-put overlay 'begin-glyph nil) @@ -3165,12 +3170,12 @@ Ediff Control Panel to restore highlighting." (defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff) - (ediff-eval-in-buffer buffer + (ediff-with-current-buffer buffer (ediff-place-flags-in-buffer1 buf-type ctl-buffer diff))) (defun ediff-place-flags-in-buffer1 (buf-type ctl-buffer diff-no) - (let* ((curr-overl (ediff-eval-in-buffer ctl-buffer + (let* ((curr-overl (ediff-with-current-buffer ctl-buffer (ediff-get-diff-overlay diff-no buf-type))) (before (ediff-get-diff-posn buf-type 'beg diff-no ctl-buffer)) after beg-of-line flag) @@ -3179,7 +3184,7 @@ Ediff Control Panel to restore highlighting." (goto-char before) (setq beg-of-line (bolp)) - (setq flag (ediff-eval-in-buffer ctl-buffer + (setq flag (ediff-with-current-buffer ctl-buffer (if (eq ediff-highlighting-style 'ascii) (if beg-of-line ediff-before-flag-bol ediff-before-flag-mol)))) @@ -3195,7 +3200,7 @@ Ediff Control Panel to restore highlighting." (goto-char after) (setq beg-of-line (bolp)) - (setq flag (ediff-eval-in-buffer ctl-buffer + (setq flag (ediff-with-current-buffer ctl-buffer (if (eq ediff-highlighting-style 'ascii) (if beg-of-line ediff-after-flag-eol ediff-after-flag-mol)))) @@ -3222,7 +3227,7 @@ Ediff Control Panel to restore highlighting." (or control-buf (setq control-buf (current-buffer))) - (ediff-eval-in-buffer control-buf + (ediff-with-current-buffer control-buf (or n (setq n ediff-current-difference)) (if (or (< n 0) (>= n ediff-number-of-differences)) (if (> ediff-number-of-differences 0) @@ -3241,7 +3246,7 @@ Ediff Control Panel to restore highlighting." ;; 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) - (ediff-eval-in-buffer (or ctl-buf (current-buffer)) + (ediff-with-current-buffer (or ctl-buf (current-buffer)) (if (and (ediff-has-face-support-p) ediff-use-faces ediff-highlight-all-diffs) @@ -3281,7 +3286,7 @@ Ediff Control Panel to restore highlighting." (defun ediff-make-bullet-proof-overlay (beg end buff) (if (ediff-buffer-live-p buff) (let (overl) - (ediff-eval-in-buffer buff + (ediff-with-current-buffer buff (or (number-or-marker-p beg) (setq beg (eval beg))) (or (number-or-marker-p end) @@ -3354,22 +3359,6 @@ Ediff Control Panel to restore highlighting." (format "%s<%d>%s" prefix n suffix)))) -;; splits at a white space, returns a list -(defun ediff-split-string (string) - (let ((start 0) - (result '()) - substr) - (while (string-match "[ \t]+" string start) - (let ((match (string-match "[ \t]+" string start))) - (setq substr (substring string start match)) - (if (> (length substr) 0) - (setq result (cons substr result))) - (setq start (match-end 0)))) - (setq substr (substring string start nil)) - (if (> (length substr) 0) - (setq result (cons substr result))) - (nreverse result))) - (defun ediff-submit-report () "Submit bug report on Ediff." (interactive) @@ -3459,7 +3448,7 @@ Mail anyway? (y or n) ") (bury-buffer) (beep 1)(message "Bug report aborted") (if (ediff-buffer-live-p ctl-buf) - (ediff-eval-in-buffer ctl-buf + (ediff-with-current-buffer ctl-buf (ediff-recenter 'no-rehighlight)))) )) @@ -3511,9 +3500,9 @@ Mail anyway? (y or n) ") (defun ediff-change-saved-variable (var value buf-type) (let* ((assoc-list - (symbol-value (intern - (concat "ediff-buffer-values-orig-" - (symbol-name buf-type))))) + (symbol-value (ediff-get-symbol-from-alist + buf-type + ediff-buffer-values-orig-alist))) (assoc-elt (assoc var assoc-list))) (if assoc-elt (setcdr assoc-elt value)))) @@ -3522,18 +3511,18 @@ Mail anyway? (y or n) ") ;; must execute in control buf (defun ediff-save-protected-variables () (setq ediff-buffer-values-orig-A - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (ediff-save-variables ediff-protected-variables))) (setq ediff-buffer-values-orig-B - (ediff-eval-in-buffer ediff-buffer-B + (ediff-with-current-buffer ediff-buffer-B (ediff-save-variables ediff-protected-variables))) (if ediff-3way-comparison-job (setq ediff-buffer-values-orig-C - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (ediff-save-variables ediff-protected-variables)))) (if (ediff-buffer-live-p ediff-ancestor-buffer) (setq ediff-buffer-values-orig-Ancestor - (ediff-eval-in-buffer ediff-ancestor-buffer + (ediff-with-current-buffer ediff-ancestor-buffer (ediff-save-variables ediff-protected-variables))))) ;; must execute in control buf @@ -3542,21 +3531,21 @@ Mail anyway? (y or n) ") (values-B ediff-buffer-values-orig-B) (values-C ediff-buffer-values-orig-C) (values-Ancestor ediff-buffer-values-orig-Ancestor)) - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (ediff-restore-variables ediff-protected-variables values-A)) - (ediff-eval-in-buffer ediff-buffer-B + (ediff-with-current-buffer ediff-buffer-B (ediff-restore-variables ediff-protected-variables values-B)) (if ediff-3way-comparison-job - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (ediff-restore-variables ediff-protected-variables values-C))) (if (ediff-buffer-live-p ediff-ancestor-buffer) - (ediff-eval-in-buffer ediff-ancestor-buffer + (ediff-with-current-buffer ediff-ancestor-buffer (ediff-restore-variables ediff-protected-variables values-Ancestor))) )) ;; save BUFFER in FILE. used in hooks. (defun ediff-save-buffer-in-file (buffer file) - (ediff-eval-in-buffer buffer + (ediff-with-current-buffer buffer (write-file file))) @@ -3698,8 +3687,8 @@ Mail anyway? (y or n) ") ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: ;;; ediff-util.el ends here diff --git a/lisp/ediff-vers.el b/lisp/ediff-vers.el index 75cfb789d0e..00b7b41f51e 100644 --- a/lisp/ediff-vers.el +++ b/lisp/ediff-vers.el @@ -359,8 +359,8 @@ ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: (provide 'ediff-vers) diff --git a/lisp/ediff-wind.el b/lisp/ediff-wind.el index ac942dc1eb1..e5edc2f08f5 100644 --- a/lisp/ediff-wind.el +++ b/lisp/ediff-wind.el @@ -110,6 +110,15 @@ provided functions are written." ;; Used to minimize the need to rearrange windows. (ediff-defvar-local ediff-window-config-saved "" "") +;; Association between buff-type and ediff-window-* +(defconst ediff-window-alist + '((A . ediff-window-A) + (?A . ediff-window-A) + (B . ediff-window-B) + (?B . ediff-window-B) + (C . ediff-window-C) + (?C . ediff-window-C))) + (defcustom ediff-split-window-function 'split-window-vertically "*The function used to split the main window between buffer-A and buffer-B. @@ -304,7 +313,7 @@ into icons, regardless of the window manager." (or (ediff-keep-window-config control-buffer) (funcall - (ediff-eval-in-buffer control-buffer ediff-window-setup-function) + (ediff-with-current-buffer control-buffer ediff-window-setup-function) buffer-A buffer-B buffer-C control-buffer)) (run-hooks 'ediff-after-setup-windows-hook)) @@ -312,7 +321,7 @@ into icons, regardless of the window manager." ;; Usually used without windowing systems ;; With windowing, we want to use dedicated frames. (defun ediff-setup-windows-plain (buffer-A buffer-B buffer-C control-buffer) - (ediff-eval-in-buffer control-buffer + (ediff-with-current-buffer control-buffer (setq ediff-multiframe nil)) (if ediff-merge-job (ediff-setup-windows-plain-merge @@ -327,7 +336,7 @@ into icons, regardless of the window manager." split-window-function merge-window-share merge-window-lines wind-A wind-B wind-C) - (ediff-eval-in-buffer control-buffer + (ediff-with-current-buffer control-buffer (setq merge-window-share ediff-merge-window-share ;; this lets us have local versions of ediff-split-window-function split-window-function ediff-split-window-function)) @@ -362,7 +371,7 @@ into icons, regardless of the window manager." (switch-to-buffer buf-B) (setq wind-B (selected-window)) - (ediff-eval-in-buffer control-buffer + (ediff-with-current-buffer control-buffer (setq ediff-window-A wind-A ediff-window-B wind-B ediff-window-C wind-C)) @@ -380,7 +389,7 @@ into icons, regardless of the window manager." split-window-function wind-width-or-height three-way-comparison wind-A-start wind-B-start wind-A wind-B wind-C) - (ediff-eval-in-buffer control-buffer + (ediff-with-current-buffer control-buffer (setq wind-A-start (ediff-overlay-start (ediff-get-value-according-to-buffer-type 'A ediff-narrow-bounds)) @@ -426,7 +435,7 @@ into icons, regardless of the window manager." (switch-to-buffer buf-C) (setq wind-C (selected-window)))) - (ediff-eval-in-buffer control-buffer + (ediff-with-current-buffer control-buffer (setq ediff-window-A wind-A ediff-window-B wind-B ediff-window-C wind-C)) @@ -445,7 +454,7 @@ into icons, regardless of the window manager." ;; dispatch an appropriate window setup function (defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf) - (ediff-eval-in-buffer control-buf + (ediff-with-current-buffer control-buf (setq ediff-multiframe t)) (if ediff-merge-job (ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf) @@ -476,10 +485,10 @@ into icons, regardless of the window manager." (frame-C (if wind-C (window-frame wind-C))) ;; on wide display, do things in one frame (force-one-frame - (ediff-eval-in-buffer control-buf ediff-wide-display-p)) + (ediff-with-current-buffer control-buf ediff-wide-display-p)) ;; this lets us have local versions of ediff-split-window-function (split-window-function - (ediff-eval-in-buffer control-buf ediff-split-window-function)) + (ediff-with-current-buffer control-buf ediff-split-window-function)) (orig-wind (selected-window)) (orig-frame (selected-frame)) (use-same-frame (or force-one-frame @@ -501,7 +510,7 @@ into icons, regardless of the window manager." ;; use-same-frame-for-AB implies wind A and B are ok for display (use-same-frame-for-AB (and (not use-same-frame) (eq frame-A frame-B))) - (merge-window-share (ediff-eval-in-buffer control-buf + (merge-window-share (ediff-with-current-buffer control-buf ediff-merge-window-share)) merge-window-lines designated-minibuffer-frame @@ -623,7 +632,7 @@ into icons, regardless of the window manager." (setq wind-C (selected-window)) )) - (ediff-eval-in-buffer control-buf + (ediff-with-current-buffer control-buf (setq ediff-window-A wind-A ediff-window-B wind-B ediff-window-C wind-C) @@ -660,16 +669,16 @@ into icons, regardless of the window manager." (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))) - (ctl-frame-exists-p (ediff-eval-in-buffer control-buf + (ctl-frame-exists-p (ediff-with-current-buffer control-buf (frame-live-p ediff-control-frame))) ;; on wide display, do things in one frame (force-one-frame - (ediff-eval-in-buffer control-buf ediff-wide-display-p)) + (ediff-with-current-buffer control-buf ediff-wide-display-p)) ;; this lets us have local versions of ediff-split-window-function (split-window-function - (ediff-eval-in-buffer control-buf ediff-split-window-function)) + (ediff-with-current-buffer control-buf ediff-split-window-function)) (three-way-comparison - (ediff-eval-in-buffer control-buf ediff-3way-comparison-job)) + (ediff-with-current-buffer control-buf ediff-3way-comparison-job)) (orig-wind (selected-window)) (use-same-frame (or force-one-frame (eq frame-A frame-B) @@ -692,7 +701,7 @@ into icons, regardless of the window manager." designated-minibuffer-frame done-A done-B done-C) - (ediff-eval-in-buffer control-buf + (ediff-with-current-buffer control-buf (setq wind-A-start (ediff-overlay-start (ediff-get-value-according-to-buffer-type 'A ediff-narrow-bounds)) @@ -793,7 +802,7 @@ into icons, regardless of the window manager." (setq wind-C (selected-window)) ))) - (ediff-eval-in-buffer control-buf + (ediff-with-current-buffer control-buf (setq ediff-window-A wind-A ediff-window-B wind-B ediff-window-C wind-C) @@ -870,13 +879,13 @@ into icons, regardless of the window manager." ;; user-grabbed-mouse fheight fwidth adjusted-parameters) - (ediff-eval-in-buffer ctl-buffer + (ediff-with-current-buffer ctl-buffer (if ediff-xemacs-p (set-buffer-menubar nil)) ;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse)) (run-hooks 'ediff-before-setup-control-frame-hook)) - (setq old-ctl-frame (ediff-eval-in-buffer ctl-buffer ediff-control-frame)) - (ediff-eval-in-buffer ctl-buffer + (setq old-ctl-frame (ediff-with-current-buffer ctl-buffer ediff-control-frame)) + (ediff-with-current-buffer ctl-buffer (setq ctl-frame (if (frame-live-p old-ctl-frame) old-ctl-frame (make-frame ediff-control-frame-parameters)) @@ -891,7 +900,7 @@ into icons, regardless of the window manager." ;; must be before ediff-setup-control-buffer ;; just a precaution--we should be in ctl-buffer already - (ediff-eval-in-buffer ctl-buffer + (ediff-with-current-buffer ctl-buffer (make-local-variable 'frame-title-format) (make-local-variable 'frame-icon-title-format) ; XEmacs (make-local-variable 'icon-title-format)) ; Emacs @@ -986,18 +995,18 @@ into icons, regardless of the window manager." (not (eq ediff-grab-mouse t))))) (if ediff-xemacs-p - (ediff-eval-in-buffer ctl-buffer + (ediff-with-current-buffer ctl-buffer (make-local-hook 'select-frame-hook) (add-hook 'select-frame-hook 'ediff-xemacs-select-frame-hook nil t) )) - (ediff-eval-in-buffer ctl-buffer + (ediff-with-current-buffer ctl-buffer (run-hooks 'ediff-after-setup-control-frame-hook)) )) (defun ediff-destroy-control-frame (ctl-buffer) - (ediff-eval-in-buffer ctl-buffer + (ediff-with-current-buffer ctl-buffer (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame)) (let ((ctl-frame ediff-control-frame)) (if ediff-xemacs-p @@ -1012,7 +1021,7 @@ into icons, regardless of the window manager." ;; finds a good place to clip control frame (defun ediff-make-frame-position (ctl-buffer ctl-frame-width ctl-frame-height) - (ediff-eval-in-buffer ctl-buffer + (ediff-with-current-buffer ctl-buffer (let* ((frame-A (window-frame ediff-window-A)) (frame-A-parameters (frame-parameters frame-A)) (frame-A-top (eval (cdr (assoc 'top frame-A-parameters)))) @@ -1135,27 +1144,27 @@ It assumes that it is called from within the control buffer." (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame)) (ediff-refresh-control-frame)) - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (setq ediff-diff-status buf-A-state-diff) (ediff-strip-mode-line-format) (setq mode-line-format (list " A: " 'ediff-diff-status mode-line-format)) (force-mode-line-update)) - (ediff-eval-in-buffer ediff-buffer-B + (ediff-with-current-buffer ediff-buffer-B (setq ediff-diff-status buf-B-state-diff) (ediff-strip-mode-line-format) (setq mode-line-format (list " B: " 'ediff-diff-status mode-line-format)) (force-mode-line-update)) (if ediff-3way-job - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (setq ediff-diff-status buf-C-state-diff) (ediff-strip-mode-line-format) (setq mode-line-format (list " C: " 'ediff-diff-status mode-line-format)) (force-mode-line-update))) (if (ediff-buffer-live-p ediff-ancestor-buffer) - (ediff-eval-in-buffer ediff-ancestor-buffer + (ediff-with-current-buffer ediff-ancestor-buffer (ediff-strip-mode-line-format) ;; we keep the second dummy string in the mode line format of the ;; ancestor, since for other buffers Ediff prepends 2 strings and @@ -1234,7 +1243,7 @@ It assumes that it is called from within the control buffer." (defun ediff-keep-window-config (control-buf) (and (eq control-buf (current-buffer)) (/= (buffer-size) 0) - (ediff-eval-in-buffer control-buf + (ediff-with-current-buffer control-buf (let ((ctl-wind ediff-control-window) (A-wind ediff-window-A) (B-wind ediff-window-B) @@ -1260,8 +1269,8 @@ It assumes that it is called from within the control buffer." ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: ;;; ediff-wind.el ends here diff --git a/lisp/ediff.el b/lisp/ediff.el index 677931f85f3..d27b08b159e 100644 --- a/lisp/ediff.el +++ b/lisp/ediff.el @@ -6,8 +6,8 @@ ;; Created: February 2, 1994 ;; Keywords: comparing, merging, patching, version control. -(defconst ediff-version "2.66" "The current version of Ediff") -(defconst ediff-date "July 9, 1997" "Date of last update") +(defconst ediff-version "2.67" "The current version of Ediff") +(defconst ediff-date "July 31, 1997" "Date of last update") ;; This file is part of GNU Emacs. @@ -158,7 +158,7 @@ ;; Used as a startup hook to set `_orig' patch file read-only. (defun ediff-set-read-only-in-buf-A () - (ediff-eval-in-buffer ediff-buffer-A + (ediff-with-current-buffer ediff-buffer-A (toggle-read-only 1))) ;; Return a plausible default for ediff's first file: @@ -291,7 +291,7 @@ ;; Setup the buffer (set buffer-name (find-file-noselect file)) - (ediff-eval-in-buffer (symbol-value buffer-name) + (ediff-with-current-buffer (symbol-value buffer-name) (widen) ; Make sure the entire file is seen (cond (file-magic ; file has a handler, such as jka-compr-handler or ;;; ange-ftp-hook-function--arrange for temp file @@ -888,10 +888,10 @@ lines. For small regions, use `ediff-regions-wordwise'." file-A file-B) ;; in case beg/end-A/B aren't markers--make them into markers - (ediff-eval-in-buffer buffer-A + (ediff-with-current-buffer buffer-A (setq beg-A (move-marker (make-marker) beg-A) end-A (move-marker (make-marker) end-A))) - (ediff-eval-in-buffer buffer-B + (ediff-with-current-buffer buffer-B (setq beg-B (move-marker (make-marker) beg-B) end-B (move-marker (make-marker) end-B))) @@ -949,7 +949,7 @@ Continue anyway? (y/n) ")) (defsubst ediff-merge-on-startup () (ediff-do-merge 0) - (ediff-eval-in-buffer ediff-buffer-C + (ediff-with-current-buffer ediff-buffer-C (set-buffer-modified-p nil))) ;;;###autoload @@ -1293,8 +1293,8 @@ With optional NODE, goes to that node." ;;; Local Variables: ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) -;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) -;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) +;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) +;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) ;;; End: (require 'ediff-util) -- 2.39.2