Function: hlink:parse-label-and-file

hlink:parse-label-and-file is a byte-compiled function defined in hibtypes.el.

Signature

(hlink:parse-label-and-file LABEL-AND-FILE)

Documentation

Parse colon-separated string LABEL-AND-FILE into a list of label and file path.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hibtypes.el
(defun hlink:parse-label-and-file (label-and-file)
  "Parse colon-separated string LABEL-AND-FILE into a list of label and file path."
  ;; Can't use split-string here because file path may contain colons;
  ;; we want to split only on the first colon.
  (let ((i 0)
        (len (length label-and-file))
        label
        file)
    (while (< i len)
      (when (= ?: (aref label-and-file i))
        (when (zerop i)
          (error "(hlink:parse-label-and-file): Missing label: '%s'" label-and-file))
        (setq label (hpath:trim (substring label-and-file 0 i))
              file (hpath:trim (substring label-and-file (1+ i))))
        (when (string-empty-p label) (setq label nil))
        (when (string-empty-p file) (setq file nil))
        (setq i len))
      (setq i (1+ i)))
    (unless (or label (string-empty-p label-and-file))
      (setq label label-and-file))
    (delq nil (list label file))))