Skip to content.

Sections
Personal tools
You are here: Home » コミュニティ » masarl memorial » homepage3.nifty.com » masarl » lib » elisp » ediff-expected-but-was.el

ediff-expected-but-was.el

Document Actions

(require 'ediff)

(defun buffer-substring-between (prefix suffix search-point) (save-excursion (goto-char search-point) (let (bgn end) (setq bgn (search-forward prefix)) (setq end (- (search-forward suffix) (length suffix))) (buffer-substring bgn end))))

(defun create-substring-between-buffer (prefix suffix buffer-name search-point) (interactive) (let (result content) (save-excursion (setq content (buffer-substring-between prefix suffix search-point)) (if (get-buffer buffer-name) (kill-buffer buffer-name)) (setq result (get-buffer-create buffer-name)) (set-buffer result) (insert content)) result))

(defun ediff-expected-but-was-search-point (prefix suffix) (save-excursion (let (found result) (re-search-forward (concat "\\(" prefix "\\|" suffix "\\)")) (setq found (buffer-substring (match-beginning 0) (match-end 0))) (if (string= found prefix) (setq result (match-beginning 0)) (setq result (search-backward prefix))) result)))

(defun ediff-expected-but-was (bgn mid end) (let (search-point) (setq search-point (ediff-expected-but-was-search-point bgn end)) (ediff-buffers (create-substring-between-buffer bgn mid "expected" search-point) (create-substring-between-buffer mid end "but was" search-point))))

(defun ediff-runit-expected-but-was () (interactive) (ediff-expected-but-was " expected:<" "> but was:<" "> (RUNIT::AssertionFailedError)"))

(defun ediff-junit-expected-but-was () (interactive) (ediff-expected-but-was " expected:<" "> but was:<" "> at "))

(defun ediff-cpp-unit-x-expected-but-was () (interactive) (ediff-expected-but-was "expected:<" "> but was:<" ">"))

(require' compile)

(add-hook 'compilation-mode-hook (lambda () (define-key compilation-mode-map "\C-c\C-r" 'ediff-runit-expected-but-was) (define-key compilation-mode-map "\C-c\C-j" 'ediff-junit-expected-but-was) ))