conflict-buttons.el

Clickable inline buttons for merge conflict resolution in Emacs, inspired by VS Code's CodeLens feature.

License Emacs Version

Overview

When editing files with git merge conflicts, conflict-buttons displays clickable buttons directly above conflict markers, allowing you to resolve conflicts with a single click instead of remembering keyboard shortcuts.

conflict-buttons in action

Before (smerge-mode only)

<<<<<<< HEAD
current version
=======
incoming version
>>>>>>> feature-branch

After (with conflict-buttons)

[ Accept Current ] | [ Accept Incoming ] | [ Accept Both ] | [ Compare ]
<<<<<<< HEAD
current version
=======
incoming version
>>>>>>> feature-branch

Features

  • One-click resolution: Click buttons to resolve conflicts instantly
  • Four actions: Accept Current, Accept Incoming, Accept Both, or Compare with ediff
  • Automatic activation: Works seamlessly with smerge-mode
  • Mouse hover highlighting: Buttons highlight when you hover over them
  • Auto-refresh: Buttons update automatically after resolving conflicts
  • Customizable style: Choose between Unicode or ASCII button styles
  • Lightweight: Less than 200 lines of code

Installation

Manual installation

  1. Download conflict-buttons.el
  2. Place it in your Emacs load path
  3. Add to your init file:
(require 'conflict-buttons)
(conflict-buttons-global-mode 1)

Using use-package (Emacs 29+)

(use-package conflict-buttons
  :ensure t
  :vc (:url "https://git.andros.dev/andros/conflict-buttons.el")
  :config
  (conflict-buttons-global-mode 1))

Or from a local path:

(use-package conflict-buttons
  :load-path "~/path/to/conflict-buttons"
  :config
  (conflict-buttons-global-mode 1))

Usage

Enable globally to automatically show buttons whenever smerge-mode is active:

(conflict-buttons-global-mode 1)

Manual activation

If you prefer to enable it only when needed:

(add-hook 'smerge-mode-hook #'conflict-buttons-setup)

Or toggle manually in a buffer:

M-x conflict-buttons-mode

Resolving conflicts

When you open a file with merge conflicts, buttons appear above each conflict marker:

  • Accept Current: Keep the version from your current branch (HEAD)
  • Accept Incoming: Keep the version from the incoming branch
  • Accept Both: Keep both versions (current first, then incoming)
  • Compare: Open ediff to compare and merge versions interactively

Simply click any button with your mouse, or navigate to it and press RET.

Customization

Button style

Choose between Unicode box-drawing characters or simple ASCII:

;; Unicode style (default): [ Accept Current ]
(setq conflict-buttons-style 'unicode)

;; ASCII style: [Accept Current]
(setq conflict-buttons-style 'ascii)

Button separator

Customize the separator between buttons:

;; Default
(setq conflict-buttons-separator " | ")

;; Alternative styles
(setq conflict-buttons-separator " · ")
(setq conflict-buttons-separator "  ")

Button appearance

Customize button faces:

(custom-set-faces
 '(conflict-buttons-button-face
   ((t (:foreground "blue" :weight bold))))
 '(conflict-buttons-button-hover-face
   ((t (:background "yellow" :foreground "black" :weight bold)))))

Comparison with existing tools

Feature conflict-buttons smerge-mode ediff Magit
Inline buttons
Click to resolve Partial (right-click menu)
Keyboard shortcuts
Visual comparison ✓ (via Compare)
Lightweight

Requirements

  • Emacs 26.1 or higher
  • smerge-mode (built-in)

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Acknowledgments

Inspired by VS Code's CodeLens feature for merge conflict resolution.

Similar packages

While there are no existing Emacs packages that provide inline clickable buttons for merge conflicts, here are related tools:

  • smerge-mode (built-in): Provides syntax highlighting and keyboard commands
  • ediff (built-in): Interactive merge tool with split-panel interface
  • Magit: Git interface that delegates conflict resolution to smerge-mode

conflict-buttons complements these tools by adding the missing piece: discoverable, one-click conflict resolution.

Description
No description provided
Readme 162 KiB
Languages
Emacs Lisp 100%