dotfiles/emacs/org/+babel-diff.el

12 lines
433 B
EmacsLisp
Raw Normal View History

2022-08-30 18:31:22 +00:00
;;; +org.el -*- lexical-binding: t; -*-
2021-11-20 20:37:15 +00:00
(defun org-babel-execute:diff (body params)
"Applies diff patches. Use with care.
See https://emacs.stackexchange.com/questions/63517/org-mode-evaluate-diff-code-block"
(with-temp-buffer
(insert body "\n")
(shell-command-on-region (point-min) (point-max) "patch --strip=1" "*patch*")
(prog1
(with-current-buffer "*patch*" (buffer-string))
(kill-buffer "*patch*"))))