I am using smerge to resolve conflicts in order to apply merge. I am applying one by one for smerge-keep-mine to all conflicts, which I belive equivalent for git merge --strategy-option ours

[Q] Is it possible to apply smerge-keep-mine for all the conflicts by using a single keybinding?


(defun smerge-try-smerge ()
    (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))

(require 'vc)
(defun next-conflict ()  ;; key-binding
  (let ((buffer (current-buffer)))
    (when (not (smerge-next-safe))
      (if (eq buffer (current-buffer))
          (message "No conflicts found")
        (goto-char 0)

;; smerge-keep-current bound to smerge-command-prefix (RET) to keep the version the cursor is on.
;; smerge-keep-mine bound to smerge-command-prefix (m) to keep your changes.
;; smerge-keep-other bound to smerge-command-prefix (o) to keep other changes.

As far as I know, no smerge does not provide that functionality.

  • Can it be done in combination with additional packages? – alper Dec 5 '20 at 15:24
  • I don't know about such a package. – tarsius Dec 5 '20 at 17:47
  • It would be pretty useful if it was possible – alper Dec 5 '20 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.