Function: majutsu-conflict--parse-marker-line

majutsu-conflict--parse-marker-line is a natively compiled function defined in majutsu-conflict.el.

Signature

(majutsu-conflict--parse-marker-line LINE EXPECTED-LEN)

Documentation

Parse LINE as a conflict marker of at least EXPECTED-LEN.

Return plist with :char, :len and :label keys, or nil if LINE is not a marker.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-conflict.el
(defun majutsu-conflict--parse-marker-line (line expected-len)
  "Parse LINE as a conflict marker of at least EXPECTED-LEN.
Return plist with :char, :len and :label keys, or nil if LINE is not a marker."
  (when (and (stringp line)
             (> (length line) 0)
             (memq (aref line 0) majutsu-conflict--marker-chars))
    (let* ((char (aref line 0))
           (line-len (length line))
           (idx 1))
      (while (and (< idx line-len)
                  (= (aref line idx) char))
        (setq idx (1+ idx)))
      (when (>= idx expected-len)
        (if (= idx line-len)
            (list :char char :len idx :label nil)
          (let ((next (aref line idx)))
            (when (memq next '(?\s ?\t))
              (let* ((suffix (substring line idx))
                     (label (replace-regexp-in-string "\\`[ \t]+" "" suffix)))
                (list :char char
                      :len idx
                      :label (unless (string-match-p "\\`[ \t]*\\'" label)
                               label))))))))))