Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created October 11, 2012 20:55
Show Gist options
  • Save amalloy/3875422 to your computer and use it in GitHub Desktop.
Save amalloy/3875422 to your computer and use it in GitHub Desktop.
(defvar reenable-paredit-modes
'(emacs-lisp-mode clojure-mode lisp-mode)
"Modes to automatically re-enable paredit for after fixing version-control conflict markers")
(put 'unresolved-conflict 'error-conditions '(unresolved-conflict error))
(put 'unresolved-conflict 'error-message "Unresolved conflict markers in file")
(defun mark-git-conflict-resolved ()
(interactive)
(when (apply #'derived-mode-p reenable-paredit-modes)
(paredit-mode t)) ;; will fail and abort if parens are unbalanced
(if (save-excursion
(beginning-of-buffer)
(re-search-forward "[<=>]\\{7\\}" nil t))
(let ((error-location (match-beginning 0)))
(goto-char error-location)
(signal 'unresolved-conflict (list error-location)))
(save-buffer)
(shell-command (concat "git add " (buffer-file-name)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment