summaryrefslogtreecommitdiff
path: root/lisp/ediff-util.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ediff-util.el')
-rw-r--r--lisp/ediff-util.el220
1 files changed, 108 insertions, 112 deletions
diff --git a/lisp/ediff-util.el b/lisp/ediff-util.el
index f39663c2e5b..7497cd3745f 100644
--- a/lisp/ediff-util.el
+++ b/lisp/ediff-util.el
@@ -38,33 +38,31 @@
(defvar bottom-toolbar-visible-p)
(defvar bottom-toolbar-height)
(defvar mark-active)
-(defvar ediff-emacs-p)
(defvar ediff-after-quit-hook-internal nil)
-(and noninteractive
- (eval-when-compile
- (load "reporter" 'noerror)))
+(eval-and-compile
+ (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
(eval-when-compile
(let ((load-path (cons (expand-file-name ".") load-path)))
(provide 'ediff-util) ; to break recursive load cycle
(or (featurep 'ediff-init)
- (load "ediff-init.el" nil nil 'nosuffix))
+ (load "ediff-init.el" nil t 'nosuffix))
(or (featurep 'ediff-help)
- (load "ediff-help.el" nil nil 'nosuffix))
+ (load "ediff-help.el" nil t 'nosuffix))
(or (featurep 'ediff-mult)
- (load "ediff-mult.el" nil nil 'nosuffix))
+ (load "ediff-mult.el" nil t 'nosuffix))
(or (featurep 'ediff-wind)
- (load "ediff-wind.el" nil nil 'nosuffix))
+ (load "ediff-wind.el" nil t 'nosuffix))
(or (featurep 'ediff-diff)
- (load "ediff-diff.el" nil nil 'nosuffix))
+ (load "ediff-diff.el" nil t 'nosuffix))
(or (featurep 'ediff-merg)
- (load "ediff-merg.el" nil nil 'nosuffix))
+ (load "ediff-merg.el" nil t 'nosuffix))
(or (featurep 'ediff)
- (load "ediff.el" nil nil 'nosuffix))
+ (load "ediff.el" nil t 'nosuffix))
(or (featurep 'ediff-tbar)
- ediff-emacs-p
+ (featurep 'emacs)
(load "ediff-tbar.el" 'noerror nil 'nosuffix))
))
;; end pacifier
@@ -77,7 +75,7 @@
(require 'ediff-diff)
(require 'ediff-merg)
-(if ediff-xemacs-p
+(if (featurep 'xemacs)
(require 'ediff-tbar))
@@ -122,7 +120,7 @@ Commands:
;; modified by minor modes and such. So, run-mode-hooks doesn't do anything
;; useful here on top of what run-hooks does.
;; Second, changing run-hooks to run-mode-hooks would require an
- ;; if-statement, since XEmacs doesn't have this.
+ ;; if-statement, since XEmacs doesn't have this.
(run-hooks 'ediff-mode-hook))
@@ -154,7 +152,7 @@ to invocation.")
(suppress-keymap ediff-mode-map)
(define-key ediff-mode-map
- (if ediff-emacs-p [mouse-2] [button2]) 'ediff-help-for-quick-help)
+ (if (featurep 'emacs) [mouse-2] [button2]) 'ediff-help-for-quick-help)
(define-key ediff-mode-map "\C-m" 'ediff-help-for-quick-help)
(define-key ediff-mode-map "p" 'ediff-previous-difference)
@@ -401,6 +399,9 @@ to invocation.")
(setq ediff-error-buffer
(get-buffer-create (ediff-unique-buffer-name "*ediff-errors" "*")))
+ (with-current-buffer ediff-error-buffer
+ (setq buffer-undo-list t))
+
(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
@@ -1141,7 +1142,7 @@ of the current buffer."
(or (memq (vc-state file) '(edited needs-merge))
(stringp (vc-state file)))
;; XEmacs has no vc-state
- (vc-locking-user file))
+ (when (featurep 'xemacs) (vc-locking-user file)))
)))
(defun ediff-file-checked-in-p (file)
@@ -1153,7 +1154,7 @@ of the current buffer."
(not (memq (vc-state file) '(edited needs-merge)))
(not (stringp (vc-state file))))
;; XEmacs has no vc-state
- (not (vc-locking-user file)))
+ (when (featurep 'xemacs) (not (vc-locking-user file))))
))
(defun ediff-file-compressed-p (file)
@@ -1275,7 +1276,7 @@ This is especially useful when comparing buffers side-by-side."
(ediff-barf-if-not-control-buffer)
(or (ediff-window-display-p)
(error "%sEmacs is not running as a window application"
- (if ediff-emacs-p "" "X")))
+ (if (featurep 'emacs) "" "X")))
(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))
@@ -1283,7 +1284,7 @@ This is especially useful when comparing buffers side-by-side."
(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))
+ ;;(sit-for (if (featurep 'xemacs) 0.4 0))
;; restore control buf, since ctl window may have been deleted
;; during resizing
(set-buffer ctl-buf)
@@ -1291,7 +1292,7 @@ This is especially useful when comparing buffers side-by-side."
ediff-window-B nil) ; force update of window config
(ediff-recenter 'no-rehighlight))
(funcall ediff-make-wide-display-function)
- ;;(sit-for (if ediff-xemacs-p 0.4 0))
+ ;;(sit-for (if (featurep 'xemacs) 0.4 0))
(ediff-with-current-buffer ctl-buf
(setq ediff-window-B nil) ; force update of window config
(ediff-recenter 'no-rehighlight)))))
@@ -1305,7 +1306,7 @@ which see."
(let (window-setup-func)
(or (ediff-window-display-p)
(error "%sEmacs is not running as a window application"
- (if ediff-emacs-p "" "X")))
+ (if (featurep 'emacs) "" "X")))
(cond ((eq ediff-window-setup-function 'ediff-setup-windows-multiframe)
(setq window-setup-func 'ediff-setup-windows-plain))
@@ -1317,10 +1318,10 @@ which see."
;; change default
(setq-default ediff-window-setup-function window-setup-func)
;; change in all active ediff sessions
- (mapcar (lambda(buf) (ediff-with-current-buffer buf
- (setq ediff-window-setup-function window-setup-func
- ediff-window-B nil)))
- ediff-session-registry)
+ (mapc (lambda(buf) (ediff-with-current-buffer buf
+ (setq ediff-window-setup-function window-setup-func
+ ediff-window-B nil)))
+ ediff-session-registry)
(if (ediff-in-control-buffer-p)
(ediff-recenter 'no-rehighlight))))
@@ -1335,18 +1336,18 @@ To change the default, set the variable `ediff-use-toolbar-p', which see."
(progn
(or (ediff-window-display-p)
(error "%sEmacs is not running as a window application"
- (if ediff-emacs-p "" "X")))
+ (if (featurep 'emacs) "" "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))
- (mapcar (lambda(buf)
- (ediff-with-current-buffer buf
- ;; force redisplay
- (setq ediff-window-config-saved "")
- ))
- ediff-session-registry)
+ (mapc (lambda(buf)
+ (ediff-with-current-buffer buf
+ ;; force redisplay
+ (setq ediff-window-config-saved "")
+ ))
+ ediff-session-registry)
(if (ediff-in-control-buffer-p)
(ediff-recenter 'no-rehighlight)))))
@@ -2408,7 +2409,9 @@ If it is t, they will be preserved unconditionally. A prefix argument,
temporarily reverses the meaning of this variable."
(interactive "P")
(ediff-barf-if-not-control-buffer)
- (let ((ctl-buf (current-buffer)))
+ (let ((ctl-buf (current-buffer))
+ (ctl-frm (selected-frame))
+ (minibuffer-auto-raise t))
(if (y-or-n-p (format "Quit this Ediff session%s? "
(if (ediff-buffer-live-p ediff-meta-buffer)
" & show containing session group" "")))
@@ -2416,6 +2419,8 @@ temporarily reverses the meaning of this variable."
(message "")
(set-buffer ctl-buf)
(ediff-really-quit reverse-default-keep-variants))
+ (select-frame ctl-frm)
+ (raise-frame ctl-frm)
(message ""))))
@@ -2439,14 +2444,14 @@ temporarily reverses the meaning of this variable."
;; Apply selective display to narrow or widen
(ediff-visible-region)
- (mapcar (lambda (overl)
- (if (ediff-overlayp overl)
- (ediff-delete-overlay overl)))
- ediff-wide-bounds)
- (mapcar (lambda (overl)
- (if (ediff-overlayp overl)
- (ediff-delete-overlay overl)))
- ediff-narrow-bounds)
+ (mapc (lambda (overl)
+ (if (ediff-overlayp overl)
+ (ediff-delete-overlay overl)))
+ ediff-wide-bounds)
+ (mapc (lambda (overl)
+ (if (ediff-overlayp overl)
+ (ediff-delete-overlay overl)))
+ ediff-narrow-bounds)
;; restore buffer mode line id's in buffer-A/B/C
(let ((control-buffer ediff-control-buffer)
@@ -2529,7 +2534,7 @@ temporarily reverses the meaning of this variable."
(cond ((ediff-good-frame-under-mouse))
(t warp-frame)))
(if (and (ediff-window-display-p) (frame-live-p warp-frame) ediff-grab-mouse)
- (set-mouse-position (if ediff-emacs-p
+ (set-mouse-position (if (featurep 'emacs)
warp-frame
(frame-selected-window warp-frame))
2 1))
@@ -2544,11 +2549,11 @@ temporarily reverses the meaning of this variable."
(buf-name "")
frame obj-ok)
(setq obj-ok
- (if ediff-emacs-p
+ (if (featurep 'emacs)
(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))
+ (setq frame (if (featurep 'emacs) frame-or-win (window-frame frame-or-win))
buf-name
(buffer-name (window-buffer (frame-selected-window frame)))))
(if (string-match "Minibuf" buf-name)
@@ -2818,6 +2823,8 @@ up an appropriate window config."
(message
"To resume, type M-x eregistry and select the desired Ediff session"))
+;; ediff-barf-if-not-control-buffer ensures only called from ediff.
+(declare-function ediff-version "ediff" ())
(defun ediff-status-info ()
"Show the names of the buffers or files being operated on by Ediff.
@@ -3031,7 +3038,7 @@ Hit \\[ediff-recenter] to reset the windows afterward."
(ediff-get-symbol-from-alist
buf-type ediff-current-diff-overlay-alist))))
- (if ediff-xemacs-p
+ (if (featurep 'xemacs)
(ediff-move-overlay current-diff-overlay begin end-hilit)
(ediff-move-overlay current-diff-overlay begin end-hilit buff))
(ediff-overlay-put current-diff-overlay 'priority
@@ -3164,7 +3171,11 @@ Hit \\[ediff-recenter] to reset the windows afterward."
(defun ediff-make-temp-file (buff &optional prefix given-file start end)
(let* ((p (ediff-convert-standard-filename (or prefix "ediff")))
(short-p p)
- (coding-system-for-write ediff-coding-system-for-write)
+ (coding-system-for-write
+ (ediff-with-current-buffer buff
+ (if (boundp 'buffer-file-coding-system)
+ buffer-file-coding-system
+ ediff-coding-system-for-write)))
f short-f)
(if (and (fboundp 'msdos-long-file-names)
(not (msdos-long-file-names))
@@ -3413,10 +3424,14 @@ Without an argument, it saves customized diff argument, if available
(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)
- (unless (and buf-A-file-name (file-exists-p buf-A-file-name))
+ (unless (and buf-A-file-name
+ (file-exists-p buf-A-file-name)
+ (not (ediff-file-remote-p buf-A-file-name)))
(setq file-A
(ediff-make-temp-file ediff-buffer-A)))
- (unless (and buf-B-file-name (file-exists-p buf-B-file-name))
+ (unless (and buf-B-file-name
+ (file-exists-p buf-B-file-name)
+ (not (ediff-file-remote-p buf-B-file-name)))
(setq file-B
(ediff-make-temp-file ediff-buffer-B)))
(or (ediff-buffer-live-p ediff-custom-diff-buffer)
@@ -3430,16 +3445,14 @@ Without an argument, it saves customized diff argument, if available
ediff-custom-diff-program ediff-custom-diff-buffer 'synchronize
ediff-custom-diff-options
;; repetition of buf-A-file-name is needed so it'll return a file
- (or (and buf-A-file-name (file-exists-p buf-A-file-name) buf-A-file-name)
- file-A)
- (or (and buf-B-file-name (file-exists-p buf-B-file-name) buf-B-file-name)
- file-B))
+ (or file-A buf-A-file-name)
+ (or file-B buf-B-file-name))
;; put the diff file in diff-mode, if it is available
(if (fboundp 'diff-mode)
(with-current-buffer ediff-custom-diff-buffer
(diff-mode)))
- (and file-A (file-exists-p file-A) (delete-file file-A))
- (and file-B (file-exists-p file-B) (delete-file file-B))
+ (and file-A (delete-file file-A))
+ (and file-B (delete-file file-B))
))
(defun ediff-show-diff-output (arg)
@@ -3607,11 +3620,11 @@ Ediff Control Panel to restore highlighting."
(defun ediff-remove-flags-from-buffer (buffer overlay)
(ediff-with-current-buffer buffer
(let ((inhibit-read-only t))
- (if ediff-xemacs-p
+ (if (featurep 'xemacs)
(ediff-overlay-put overlay 'begin-glyph nil)
(ediff-overlay-put overlay 'before-string nil))
- (if ediff-xemacs-p
+ (if (featurep 'xemacs)
(ediff-overlay-put overlay 'end-glyph nil)
(ediff-overlay-put overlay 'after-string nil))
)))
@@ -3639,7 +3652,7 @@ Ediff Control Panel to restore highlighting."
ediff-before-flag-bol ediff-before-flag-mol))))
;; insert the flag itself
- (if ediff-xemacs-p
+ (if (featurep 'xemacs)
(ediff-overlay-put curr-overl 'begin-glyph flag)
(ediff-overlay-put curr-overl 'before-string flag))
@@ -3655,7 +3668,7 @@ Ediff Control Panel to restore highlighting."
ediff-after-flag-eol ediff-after-flag-mol))))
;; insert the flag itself
- (if ediff-xemacs-p
+ (if (featurep 'xemacs)
(ediff-overlay-put curr-overl 'end-glyph flag)
(ediff-overlay-put curr-overl 'after-string flag))
))
@@ -3743,13 +3756,13 @@ Ediff Control Panel to restore highlighting."
;; 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))
- (mapcar (lambda (elt)
- (ediff-delete-overlay
- (ediff-get-diff-overlay-from-diff-record elt))
- (if fine-diffs-also
- (ediff-clear-fine-diff-vector elt))
- )
- (symbol-value vec-var)))
+ (mapc (lambda (elt)
+ (ediff-delete-overlay
+ (ediff-get-diff-overlay-from-diff-record elt))
+ (if fine-diffs-also
+ (ediff-clear-fine-diff-vector elt))
+ )
+ (symbol-value vec-var)))
;; allow them to be garbage collected
(set vec-var nil))
@@ -3782,10 +3795,10 @@ Ediff Control Panel to restore highlighting."
;; never detach
(ediff-overlay-put
- overl (if ediff-emacs-p 'evaporate 'detachable) nil)
+ overl (if (featurep 'emacs) 'evaporate 'detachable) nil)
;; make overlay open-ended
;; In emacs, it is made open ended at creation time
- (if ediff-xemacs-p
+ (if (featurep 'xemacs)
(progn
(ediff-overlay-put overl 'start-open nil)
(ediff-overlay-put overl 'end-open nil)))
@@ -3798,9 +3811,8 @@ Ediff Control Panel to restore highlighting."
(let ((overlay (ediff-get-symbol-from-alist
type ediff-current-diff-overlay-alist))
(buffer (ediff-get-buffer type))
- (face (face-name
- (ediff-get-symbol-from-alist
- type ediff-current-diff-face-alist))))
+ (face (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)
@@ -4067,28 +4079,25 @@ Mail anyway? (y or n) ")
)
))
-(cond ((fboundp 'nuke-selective-display)
- ;; XEmacs has nuke-selective-display
- (defalias '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))
- buffer-read-only end)
- (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)))))
- ))
+(defun ediff-nuke-selective-display ()
+ (if (featurep 'xemacs)
+ (nuke-selective-display)
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (let ((mod-p (buffer-modified-p))
+ buffer-read-only end)
+ (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))))))
;; The next two are modified versions from emerge.el.
@@ -4291,20 +4300,7 @@ Mail anyway? (y or n) ")
(add-to-history history-var newelt)
(set history-var (cons newelt (symbol-value history-var)))))
-(if (fboundp 'copy-sequence)
- (defalias 'ediff-copy-list 'copy-sequence)
- (defun ediff-copy-list (list)
- (if (consp list)
- ;;;(let ((res nil))
- ;;; (while (consp list) (push (pop list) res))
- ;;; (prog1 (nreverse res) (setcdr res list)))
- (let (res elt)
- (while (consp list)
- (setq elt (car list)
- res (cons elt res)
- list (cdr list)))
- (nreverse res))
- (car list))))
+(defalias 'ediff-copy-list 'copy-sequence)
;; don't report error if version control package wasn't found
@@ -4315,11 +4311,11 @@ Mail anyway? (y or n) ")
(provide 'ediff-util)
-;;; Local Variables:
-;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
-;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
-;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
-;;; End:
+;; Local Variables:
+;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
+;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
+;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
+;; End:
-;;; arch-tag: f51099b6-ef4b-470f-88a1-3a0e0b03a879
+;; arch-tag: f51099b6-ef4b-470f-88a1-3a0e0b03a879
;;; ediff-util.el ends here