(defun dired-ediff-marked-files ()
"Run ediff on marked ediff files."
(interactive)
(set 'marked-files (dired-get-marked-files))
(when (= (safe-length marked-files) 2)
(ediff-files (nth 0 marked-files) (nth 1 marked-files)))
(when (= (safe-length marked-files) 3)
(ediff3 (buffer-file-name (nth 0 marked-files))
(buffer-file-name (nth 1 marked-files))
(buffer-file-name (nth 2 marked-files)))))
Another way (link)
(defun mkm/ediff-marked-pair ()
"Run ediff-files on a pair of files marked in dired buffer"
(interactive)
(let* ((marked-files (dired-get-marked-files nil nil))
(other-win (get-window-with-predicate
(lambda (window)
(with-current-buffer (window-buffer window)
(and (not (eq window (selected-window)))
(eq major-mode 'dired-mode))))))
(other-marked-files (and other-win
(with-current-buffer (window-buffer other-win)
(dired-get-marked-files nil)))))
(cond ((= (length marked-files) 2)
(ediff-files (nth 0 marked-files)
(nth 1 marked-files)))
((and (= (length marked-files) 1)
(= (length other-marked-files) 1))
(ediff-files (nth 0 marked-files)
(nth 0 other-marked-files)))
(t (error "mark exactly 2 files, at least 1 locally")))))
No comments:
Post a Comment