Function: treemacs--read-projects
treemacs--read-projects is a byte-compiled function defined in
treemacs-persistence.el.
Signature
(treemacs--read-projects ITER)
Documentation
Read a list of projects from ITER until another section is found.
ITER: Treemacs-Iter Struct
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-persistence.el
(defun treemacs--read-projects (iter)
"Read a list of projects from ITER until another section is found.
ITER: Treemacs-Iter Struct"
(let (projects)
(while (s-matches? treemacs--persist-project-name-regex (treemacs-iter->peek iter))
(let ((kv-lines nil)
(project (treemacs-project->create!))
(project-name (substring (treemacs-iter->next! iter) 3))
(comment-prefix "COMMENT "))
(when (s-starts-with? comment-prefix project-name)
(setf project-name (substring project-name (length comment-prefix))
(treemacs-project->is-disabled? project) t))
(setf (treemacs-project->name project) project-name)
(while (s-matches? treemacs--persist-kv-regex (treemacs-iter->peek iter))
(push (treemacs-iter->next! iter) kv-lines))
(if (null kv-lines)
(treemacs-log-failure "Project %s has no path and will be ignored."
(propertize (treemacs-project->name project)
'face 'font-lock-type-face))
(dolist (kv-line kv-lines)
(-let [(key val) (s-split " :: " kv-line)]
(pcase (s-trim key)
("- path"
(setf (treemacs-project->path project) (treemacs-canonical-path val)))
(_
(treemacs-log-failure "Encountered unknown project key-value in line [%s]" kv-line)))))
(let ((action 'retry))
(while (eq action 'retry)
(setf (treemacs-project->path-status project)
(-> (treemacs-project->path project)
(treemacs--get-path-status)))
(setq action
(cond
((or (treemacs-project->is-disabled? project)
(not (treemacs-project->is-unreadable? project)))
'keep)
((eq treemacs-missing-project-action 'ask)
(let ((completions
'(("Keep the project in the project list" . keep)
("Retry" . retry)
("Remove the project from the project list" . remove))))
(cdr (assoc (completing-read
(format "Project %s at %s cannot be read."
(treemacs-project->name project)
(treemacs-project->path project))
completions nil t)
completions))))
(treemacs-missing-project-action))))
(if (eq action 'remove)
(treemacs-log-failure "The location of project %s at %s cannot be read. Project was removed from the project list."
(propertize (treemacs-project->name project) 'face 'font-lock-type-face)
(propertize (treemacs-project->path project) 'face 'font-lock-string-face))
(push project projects))))))
(nreverse projects)))