Function: kimport:kcells

kimport:kcells is a byte-compiled function defined in kimport.el.

Signature

(kimport:kcells IMPORT-FROM OUTPUT-TO KLABEL OUTPUT-LEVEL IMPORT-LEVEL COUNT TOTAL)

Documentation

Insert visible koutline cells (contents and attributes) from IMPORT-FROM.

Insert into existing OUTPUT-TO.

KLABEL is the label to use for the first imported cell. OUTPUT-LEVEL is the level at which to insert the first cell. IMPORT-LEVEL is the depth of the current cell in the import file,
(initially 1).

COUNT of inserted cells starts at 0. TOTAL is the total number of cells in IMPORT-FROM, used to show a running tally of the imported cells.

Return COUNT.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kimport.el
(defun kimport:kcells (import-from output-to klabel output-level
		       import-level count total)
  "Insert visible koutline cells (contents and attributes) from IMPORT-FROM.
Insert into existing OUTPUT-TO.

KLABEL is the label to use for the first imported cell.
OUTPUT-LEVEL is the level at which to insert the first cell.
IMPORT-LEVEL is the depth of the current cell in the import file,
\(initially 1).

COUNT of inserted cells starts at 0.  TOTAL is the total number of cells
in IMPORT-FROM, used to show a running tally of the imported cells.

Return COUNT."
  (set-buffer import-from)
  (goto-char (kcell-view:start))
  (let ((again t) contents subtree-p child-label)
    ;; While find cells at import-level or deeper ...
    (while (<= import-level (kcell-view:level))
      (setq subtree-p (kcell-view:child-p nil t)
	    contents (kcell-view:contents))
      (goto-char (kcell-view:end-contents))
      (with-current-buffer output-to
	;; Add the cell starting at point.
	(kview:add-cell klabel output-level contents nil t)
	(if subtree-p (setq child-label (klabel:child klabel)))
	(message "%d of %d cells inserted..."
		 (setq count (1+ count)) total)
	(setq klabel (klabel:increment klabel)))
      ;;
      ;; Current buffer returns to `import-from' here.
      ;; Handle each sub-level through recursion.
      (when (and (setq again (kcell-view:next t)) subtree-p)
	;; Subtree exists so insert its cells.
	(setq count
	      (kimport:kcells
	       import-from output-to child-label (1+ output-level)
	       (1+ import-level) count total)))
      (unless again
	(throw 'end count))))
  count)