doomemacs/modules/lang/php/autoload.el
Henrik Lissner 31a4244686
Rethink what Doom loads at startup and manually
Better to simply load what we need, when we need it, rather than set up
autoloads for every litte thing.
2018-01-07 00:15:57 -05:00

16 lines
741 B
EmacsLisp

;;; lang/php/autoload.el -*- lexical-binding: t; -*-
(defvar +php-composer-conf (make-hash-table :test 'equal))
;;;###autoload
(defun +php-composer-conf (&optional project-root refresh-p)
"Retrieve the contents of composer.json as an alist. If REFRESH-P is non-nil
ignore the cache."
(let ((project-root (or project-root (doom-project-root))))
(or (and (not refresh-p) (gethash project-root +php-composer-conf))
(let ((package-file (expand-file-name "composer.json" project-root)))
(when-let* ((data (and (file-exists-p package-file)
(require 'json)
(json-read-file package-file))))
(puthash project-root data +php-composer-conf))))))