;;; -*- encoding:utf-8 -*- --- (defun my-changes () (interactive) (with-current-buffer (find-file-noselect "/tmp/test.diff") (fundamental-mode) (goto-char (point-min)) (let (result-list cur-file cur-file-changes) (while (search-forward "Index: " nil t) (message "range:%d,%d" (point) (line-end-position)) (setf cur-file (buffer-substring-no-properties (point) (line-end-position))) (next-line 3) '(loop repeat 3 do (message "move line") (next-line)) (let ((start-pos (line-beginning-position)) (end-pos (point-max))) (when (search-forward "Index: " nil t) (previous-line) (setf end-pos (line-end-position))) (setf cur-file-changes (buffer-substring-no-properties start-pos end-pos)) (push (cons cur-file cur-file-changes) result-list) (goto-char end-pos))) (message "result is %s" (reverse result-list)))))