Function: majutsu-interactive-build-replay-plan-if-selected

majutsu-interactive-build-replay-plan-if-selected is a natively compiled function defined in majutsu-interactive.el.

Signature

(majutsu-interactive-build-replay-plan-if-selected &optional BUFFER MODE)

Documentation

Return a plan that reconstructs the editor's right tree from selections.

MODE is selected for Split and Squash, or complement for Restore. A selected plan starts from the editor's left tree and replays selected changes from its initial right tree. A complement plan starts from the initial right tree and replays unselected changes from the left tree. Both plans apply their text patches forward; this keeps new-file and copy patches valid.

The returned plist contains :base, :payload-root, :patch, and :file-ops, or nil when BUFFER has no selections.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-interactive.el
(defun majutsu-interactive-build-replay-plan-if-selected (&optional buffer mode)
  "Return a plan that reconstructs the editor's right tree from selections.
MODE is `selected' for Split and Squash, or `complement' for Restore.  A
selected plan starts from the editor's left tree and replays selected changes
from its initial right tree.  A complement plan starts from the initial right
tree and replays unselected changes from the left tree.  Both plans apply
their text patches forward; this keeps new-file and copy patches valid.

The returned plist contains :base, :payload-root, :patch, and :file-ops, or
nil when BUFFER has no selections."
  (with-current-buffer (or buffer (current-buffer))
    (when (majutsu-interactive--has-selections-p)
      (pcase (or mode 'selected)
        ('selected
         (list :base 'left
               :payload-root 'right
               :patch (and (majutsu-interactive--collect-selected-hunks)
                           (majutsu-interactive--build-patch))
               :file-ops
               (majutsu-interactive--build-file-operations
                (majutsu-interactive--collect-selected-files))))
        ('complement
         (list :base 'right
               :payload-root 'left
               :patch (majutsu-interactive--build-patch t t)
               :file-ops
               (majutsu-interactive--build-file-operations
                (majutsu-interactive--collect-unselected-files))))
        (_ (error "Unknown replay plan mode: %S" mode))))))