All Projects → mtekman → org-tanglesync.el

mtekman / org-tanglesync.el

Licence: GPL-3.0 License
A package to pull external changes into an org-mode source block if that block is tangled to an external file

Programming Languages

emacs lisp
2029 projects

Projects that are alternatives of or similar to org-tanglesync.el

counsel-org-clock
Counsel (Ivy) interface for org-clock
Stars: ✭ 44 (-45%)
Mutual labels:  org-mode
ob-tmux
Ob-tmux is an Emacs library that allows org mode to evaluate code blocks in a tmux session.
Stars: ✭ 46 (-42.5%)
Mutual labels:  org-mode
emacs-modified-windows
Mirror of the GitLab project Emacs Modified for Windows
Stars: ✭ 79 (-1.25%)
Mutual labels:  org-mode
nano-agenda
A minimal org agenda for Emacs
Stars: ✭ 33 (-58.75%)
Mutual labels:  org-mode
org-agda-mode
An Emacs mode for working with Agda code in an Org-mode like fashion, more or less.
Stars: ✭ 14 (-82.5%)
Mutual labels:  org-mode
tangle-rs
a collection of tools to do tangle in rust
Stars: ✭ 23 (-71.25%)
Mutual labels:  org-mode
zshorg
org-mode literate programming zsh config
Stars: ✭ 17 (-78.75%)
Mutual labels:  org-mode
Eorg
new version: https://github.com/SoftMaple/Editor
Stars: ✭ 27 (-66.25%)
Mutual labels:  org-mode
org-onenote
Post org file to onenote
Stars: ✭ 40 (-50%)
Mutual labels:  org-mode
ntangle
Command-line utility for Tangling of Org documents — programmed in Nim.
Stars: ✭ 56 (-30%)
Mutual labels:  org-mode
organic
Outliner, organizer and notes management app.
Stars: ✭ 37 (-53.75%)
Mutual labels:  org-mode
vimwiki2org
Convert VimWiki files to Emacs Org-Mode
Stars: ✭ 18 (-77.5%)
Mutual labels:  org-mode
babel
A Leiningen project template for literate Clojure projects w/ org-mode
Stars: ✭ 74 (-7.5%)
Mutual labels:  org-mode
notes
just notes
Stars: ✭ 21 (-73.75%)
Mutual labels:  org-mode
org-beamer-cn
[Deprecated] org-mode Simple Chinese Template for Beamer
Stars: ✭ 23 (-71.25%)
Mutual labels:  org-mode
phscroll
Enable partial horizontal scroll in Emacs
Stars: ✭ 52 (-35%)
Mutual labels:  org-mode
emacs-up
My emacs configuration files
Stars: ✭ 23 (-71.25%)
Mutual labels:  org-mode
zettel-mode
A Zettelkasten-style note-taking helper
Stars: ✭ 32 (-60%)
Mutual labels:  org-mode
org parser
An Org Mode parser for Dart
Stars: ✭ 21 (-73.75%)
Mutual labels:  org-mode
dotfiles
Personal config and utils for emacs, vim, tmux, i3, git, etc.
Stars: ✭ 29 (-63.75%)
Mutual labels:  org-mode

This repo has migrated to GitLab

https://gitlab.com/mtekman/org-tanglesync.el

(The copy here is archived. Please see the above link for the latest developments)

org-tanglesync

MELPA

Tangled blocks provide a nice way of exporting code into external files, acting as a fantastic agent to write literate dotfile configs. However, such dotfiles tend to be changed externally, sometimes for the worse and sometimes for the better. In the latter case it would be nice to be able to pull those external changes back into the original org src block it originated from.

Installation

(use-package org-tanglesync
  :hook ((org-mode . org-tanglesync-mode)
         ;; enable watch-mode globally:
         ((prog-mode text-mode) . org-tanglesync-watch-mode))
  :custom
  (org-tanglesync-watch-files '("conf.org" "myotherconf.org"))
  :bind
  (( "C-c M-i" . org-tanglesync-process-buffer-interactive)
   ( "C-c M-a" . org-tanglesync-process-buffer-automatic)))

Overview

This package offers two complementary methods for syncing changes between a tangled block and the source org file it is tangled from:

  1. From External File, Push to Tangled Block
  2. From Org File, Pull External Changes Into Tangled Blocks

From External File, Push to Tangled Block

screen2
Left - the org buffer with the tangled file, Right - the external .xinitrc file

This is the use-case where you have ~/.xinitrc open and want to automatically sync your changes back to conf.org every time you save the ~/.xinitrc file (i.e. you don't want to open conf.org to sync).

Configuration and Execution

The user needs to only set the org-tanglesync-watch-files to a list of org files which have tangled blocks that need to be 'watched', and enable org-tanglesync-watch-mode globally, as given in the installation example.

In the above screencast specifically, we have set:

(setq org-tanglesync-watch-files '("conf.org"))
(org-tanglesync-watch-mode 1)

Here our conf.org contains the tangled block ~/.xinitrc, which has the changes synced whenever the ~/.xinitrc is modified and saved.

Note: By default, all tangled blocks specified in org-tanglesync-watch-files are watched and updated upon saving, however this can be overridden at the individual block level by adding :nowatch to the org block src header.

From Org File, Pull External Changes Into Tangled Blocks

screen Left - Sync all blocks, Right - Sync just this block.

This is the use-case where you have opened conf.org containing - among many other tangled source blocks - a block with :tangle ~/.xinitrc as a header. You wish to sync changes either by exporting that block to the ~/.xinitrc file, or by pulling the changes you have made externally to that file back into the block within your conf.org.

The above actions can be performed either globally or at the individual block level depending on your configuration.

Configuration

Any src block that has :tangle <fname> will compare the block with the external <fname> it is tangled to. When a diff is detected, 1 of 5 different :diff <action> actions can occur:

  1. prompt - (default) The user will be prompted to pull or reject external changes
  2. external - The <fname> contents will override the block contents
  3. internal - The block will retain the block contents
  4. diff - A diff of the <fname> and block contents will be produced
  5. custom - A custom user-defined function will be called instead

These 5 options can be set as the default action by changing the org-tanglesync-default-diff-action custom parameter. Otherwise individual block actions can be set in the org src block header e.g. :diff external for pulling external changes without prompt into a specific block. The default action is to simply prompt the user.

Execution

Sync All Tangled Blocks in Buffer

The user can either call org-tanglesync-process-buffer-interactive or org-tanglesync-process-buffer-automatic to interactively/automatically process all tangled blocks in the org buffer. This will go through each tangled block from top to bottom, pausing to prompt the user for an action if one has not been defined in its header.

Sync Just One Block

If the user wishes to sync only a single block, a much easier way is to simply edit the block in the org-src mode (activated via C-c '). This executes a hook which prompts the user for an action on that specific block if a difference is detected. The user can bypass this and always pull changes by setting the org-tanglesync-skip-user-check custom parameter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].