Function: majutsu-row-read-region

majutsu-row-read-region is a natively compiled function defined in majutsu-row.el.

Signature

(majutsu-row-read-region COMPILED BEG END &optional OPTIONS)

Documentation

Read row protocol events between BEG and END using COMPILED.

Return a plist with :roots, :entries, and :diagnostics.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-row.el
(defun majutsu-row-read-region (compiled beg end &optional _options)
  "Read row protocol events between BEG and END using COMPILED.
Return a plist with :roots, :entries, and :diagnostics."
  (let (roots entries diagnostics suffix-owner)
    (save-excursion
      (let ((cursor beg))
        (while (< cursor end)
          (if-let* ((marker (majutsu-row--next-marker-position cursor end)))
              (progn
                (majutsu-row--finalize-entry-gap
                 suffix-owner cursor marker marker)
                (goto-char marker)
                (pcase-let ((`(,kind . ,token)
                             (or (majutsu-row--event-at-point)
                                 (cons 'unknown majutsu-row-record-marker))))
                  (pcase kind
                    ('row
                     (if-let* ((parsed (majutsu-row--parse-entry-record-at-point
                                        compiled)))
                         (let ((entry (car parsed))
                               (record-end (cdr parsed)))
                           (push entry roots)
                           (push entry entries)
                           (setq suffix-owner entry
                                 cursor record-end))
                       (push (list :position marker
                                   :message "Incomplete row record")
                             diagnostics)
                       (setq suffix-owner nil
                             cursor (+ marker (length token)))))
                    (_
                     (push (list :position marker
                                 :message "Unknown row protocol marker")
                           diagnostics)
                     (setq suffix-owner nil
                           cursor (min end (1+ marker)))))))
            (majutsu-row--finalize-entry-gap suffix-owner cursor end nil)
            (setq cursor end)))))
    (list :roots (nreverse roots)
          :entries (nreverse entries)
          :diagnostics (nreverse diagnostics))))