Function: combobulate-clone-node-dwim

combobulate-clone-node-dwim is an interactive and natively compiled function defined in combobulate-manipulation.el.

Signature

(combobulate-clone-node-dwim &optional ARG)

Documentation

Clone node at point ARG times.

Key Bindings

combobulate-key-map C-c o c combobulate-options-key-map c

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-manipulation.el
(defun combobulate-clone-node-dwim (&optional arg)
  "Clone node at point ARG times."
  (interactive "^p")
  (with-argument-repetition arg
    (with-navigation-nodes (:procedures (combobulate-read procedures-sibling))
      (when-let ((node (combobulate-proffer-choices
                        (seq-sort #'combobulate-node-larger-than-node-p
                                  (combobulate--get-all-navigable-nodes-at-point))
                        (lambda-slots (current-node refactor-id)
                          (combobulate-refactor (:id refactor-id)
                            (let* ((ov (mark-node-highlighted current-node))
                                   (start (overlay-start ov))
                                   (end (overlay-end ov)))
                              ;; This'll shift around the overlay
                              ;; extents, so put em back where they
                              ;; were after cloning.
                              (combobulate--clone-node current-node (combobulate-node-start current-node))
                              (setf (overlay-start ov) start)
                              (setf (overlay-end ov) end))))
                        :reset-point-on-abort t)))
        (combobulate-message "Cloning" node)
        (combobulate--clone-node node (combobulate-node-start node))))))