I am using next-conflict
to detect is there any git conflict, using following answer:
Jump to next merge conflict in project using Magit and Smerge. I experience that if I am at the end of the file/buffer and if there is a conflict in the same buffer/file, the conflict is not found. But if I switch into another buffer, or go to top of the buffer it iss found.
Is there any workaround to fix this issue?
setup:
(defun smerge-try-smerge ()
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil t)
(require 'smerge-mode)
(smerge-mode 1))))
(add-hook 'find-file-hook 'smerge-try-smerge t)
(add-hook 'after-revert-hook 'smerge-try-smerge t)
(defun smerge-next-safe ()
"returns t on success, nil otherwise"
(condition-case err
(not (smerge-next))
('error
nil)))
(require 'vc)
(defun next-conflict () ;; key-binding
(interactive)
(let ((buffer (current-buffer)))
(when (not (smerge-next-safe))
(vc-find-conflicted-file)
(if (eq buffer (current-buffer))
(message "No conflicts found")
(goto-char 0)
(smerge-next-safe)))))