Function: kimport:text-paragraphs

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

Signature

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

Documentation

Insert text paragraphs from IMPORT-FROM into existing OUTPUT-TO.

First cell is inserted with KLABEL at OUTPUT-LEVEL, as the sibling of the previous cell, with the COUNT of inserted paragraphs starting at 0. TOTAL is the total number of paragraphs in IMPORT-FROM, used to show a running tally of the imported paragraphs.

The variable, paragraph-start is used to determine paragraphs.

Return COUNT.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kimport.el
(defun kimport:text-paragraphs (import-from output-to klabel
                                output-level count total)
  "Insert text paragraphs from IMPORT-FROM into existing OUTPUT-TO.
First cell is inserted with KLABEL at OUTPUT-LEVEL, as the sibling of the
previous cell, with the COUNT of inserted paragraphs starting at 0.  TOTAL is
the total number of paragraphs in IMPORT-FROM, used to show a running tally
of the imported paragraphs.

The variable, `paragraph-start' is used to determine paragraphs.

Return COUNT."
  (set-buffer import-from)
  (let* (start end contents)
    ;; Next line is needed when importing into an existing kview.
    (goto-char (point-min))
    ;; Move past blank lines at point.
    (skip-chars-forward " \t\n\r")
    (beginning-of-line)
    (while (and (setq start (point))
		(progn (while (and (not (looking-at paragraph-start))
				   (zerop (forward-line 1))))
		       t)
		(if (looking-at paragraph-start)
		    (setq end (goto-char (match-end 0))))
		(/= start end))
      (setq contents (kimport:unindent-region start end))
      (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))
	(setq count (1+ count))
	(message "%d of %d paragraphs converted..."
		 count total)
	(setq klabel (klabel:increment klabel)))
      (set-buffer import-from)
      (goto-char end)
      ;; Move past blank lines separating paragraphs.
      (skip-chars-forward " \t\n\r")
      (beginning-of-line))
    (message "%d of %d paragraphs converted" count total)
    count))