An Emacs package that integrates Unison file synchronization into your Emacs workflow.
- Automatically sync files using Unison when saving in Emacs
- Queue multiple sync commands to avoid conflicts
- Exclude specific files or patterns from synchronization
- Support for one-way synchronization
- Force sync with ignorearchives flag
- Detailed output buffer for sync operations
To install unison-sync-mode using straight.el, add the following to your Emacs configuration:
(straight-use-package
'(unison-sync-mode :type git :host github :repo "jsigman/unison-sync-mode"))
If you prefer using use-package with straight.el:
(use-package unison-sync-mode
:straight (:type git :host github :repo "jsigman/unison-sync-mode"))
- Clone this repository:
git clone https://github.com/jsigman/unison-sync-mode.git
- Add the following to your
.emacs
orinit.el
file:(add-to-list 'load-path "/path/to/unison-sync-mode") (require 'unison-sync-mode)
To use unison-sync-mode
, you need to set up directory local variables for your project. Create a .dir-locals.el
file in your project root with the following content:
((nil . ((unison-root1 . "/path/to/local/directory")
(unison-root2 . "/path/to/remote/directory")
(unison-excluded . ("*.tmp" "*.log"))
(unison-one-way-sync . nil))))
Adjust the paths and excluded patterns according to your needs.
Once configured, unison-sync-mode
will be automatically enabled for files in directories where unison-root1
and unison-root2
are set.
When unison-sync-mode
is active:
- Files will be synchronized using Unison every time you save.
- The mode lighter “Unison-Sync” will be displayed in the mode line.
unison-sync-mode
: Toggle the minor mode on/off manually.unison-sync-force
: Force a sync operation with the -ignorearchives flag.
You can customize the following variables:
unison-one-way-sync
: Set to non-nil to perform one-way synchronization fromunison-root1
tounison-root2
.unison-sync-auto-enable
: Set to nil if you want to manually enable the mode instead of having it automatically enabled when root directories are set.
Example:
(setq unison-one-way-sync t)
(setq unison-sync-auto-enable nil)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.