Files
conflict-buttons.el/README.md
Andros Fenollosa a86f9b2bd6 Add screenshot showing conflict-buttons in action
- Create visual demonstration of the interface
- Add screenshot to README.md Overview section
- Show clickable buttons above conflict markers
2026-02-22 21:48:08 +01:00

185 lines
4.9 KiB
Markdown

# conflict-buttons.el
Clickable inline buttons for merge conflict resolution in Emacs, inspired by VS Code's CodeLens feature.
![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg)
![Emacs Version](https://img.shields.io/badge/Emacs-26.1+-purple.svg)
## 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](screenshot.png)
### 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:
```elisp
(require 'conflict-buttons)
(conflict-buttons-global-mode 1)
```
### Using `use-package` (Emacs 29+)
```elisp
(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:
```elisp
(use-package conflict-buttons
:load-path "~/path/to/conflict-buttons"
:config
(conflict-buttons-global-mode 1))
```
## Usage
### Automatic activation (recommended)
Enable globally to automatically show buttons whenever `smerge-mode` is active:
```elisp
(conflict-buttons-global-mode 1)
```
### Manual activation
If you prefer to enable it only when needed:
```elisp
(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:
```elisp
;; 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:
```elisp
;; Default
(setq conflict-buttons-separator " | ")
;; Alternative styles
(setq conflict-buttons-separator " · ")
(setq conflict-buttons-separator " ")
```
### Button appearance
Customize button faces:
```elisp
(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.