Function: kimport:aug-post-statements
kimport:aug-post-statements is a byte-compiled function defined in
kimport.el.
Signature
(kimport:aug-post-statements IMPORT-FROM OUTPUT-TO KLABEL OUTPUT-LEVEL IMPORT-LEVEL COUNT TOTAL MAX-POS)
Documentation
Insert post-numbered Augment statements (contents only) from IMPORT-FROM.
Is inserted in existing OUTPUT-TO.
KLABEL is the label to use for the first imported statement. OUTPUT-LEVEL is the level at which to insert the first statement. IMPORT-LEVEL is the depth of the current statement in the import file, (initially 1).
COUNT of inserted cells starts at 0. TOTAL is the total number of statements in IMPORT-FROM, used to show a running tally of the imported statements. MAX-POS is the furthest position searched in IMPORT-FROM so far (initially 0).
Return a cons of MAX-POS and COUNT.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kimport.el
(defun kimport:aug-post-statements (import-from output-to klabel output-level
import-level count total max-pos)
"Insert post-numbered Augment statements (contents only) from IMPORT-FROM.
Is inserted in existing OUTPUT-TO.
KLABEL is the label to use for the first imported statement.
OUTPUT-LEVEL is the level at which to insert the first statement.
IMPORT-LEVEL is the depth of the current statement in the import
file, \(initially 1).
COUNT of inserted cells starts at 0. TOTAL is the total number
of statements in IMPORT-FROM, used to show a running tally of the
imported statements. MAX-POS is the furthest position searched
in IMPORT-FROM so far (initially 0).
Return a cons of MAX-POS and COUNT."
(set-buffer import-from)
(let ((start (point))
(cell-end-regexp " +\\([0-9][0-9a-z]*\\)\n\\(\n+\\|\\'\\)")
(case-fold-search)
max-pos-and-count
contents subtree-p end end-contents statement-level
child-label)
;; While find cells at import-level or deeper ...
(while (and (setq start (point))
(re-search-forward cell-end-regexp nil t)
(<= import-level
(setq statement-level
(klabel:level-alpha (match-string 1)))))
(setq end-contents (match-beginning 0)
end (match-end 0))
(goto-char start)
(skip-chars-forward " ")
(setq contents (kimport:unindent-region (point) end-contents))
(goto-char end)
(setq subtree-p (save-excursion
(if (re-search-forward cell-end-regexp nil t)
(< statement-level
(klabel:level-alpha (match-string 1))))))
(with-current-buffer output-to
(if (and (zerop count) (string-empty-p (kcell-view:contents)))
;; Reuse this initial empty cell in koutline
(progn (kview:insert-contents (kcell-view:cell) contents 'no-fill
(make-string (kcell-view:indent) ?\ ))
(goto-char (kcell-view:end)))
;; 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 statements converted..."
(if (= statement-level 1) (setq count (1+ count)) count)
total)
(setq klabel (klabel:increment klabel)))
;;
;; Current buffer returns to `import-from' here.
;; Handle each sub-level through recursion.
(when subtree-p
;; Subtree exists so insert its cells.
(setq max-pos-and-count
(kimport:aug-post-statements
import-from output-to child-label (1+ output-level)
(1+ import-level) count total max-pos)
max-pos (car max-pos-and-count)
count (cdr max-pos-and-count))))
(goto-char (setq max-pos (max end max-pos))))
(cons max-pos count))