autoload/packages: more reliable self-parser for doom-read-packages

This commit is contained in:
Henrik Lissner 2017-02-08 01:58:56 -05:00
parent e342994307
commit 83f4abe100

View file

@ -98,15 +98,17 @@ fed to `doom/packages-delete'."
(unless (symbolp sym) (unless (symbolp sym)
(error "%s is not a valid symbol" sym)) (error "%s is not a valid symbol" sym))
(with-temp-buffer (with-temp-buffer
(insert-file-contents file) (buffer-disable-undo)
(emacs-lisp-mode)
(insert-file-contents file nil nil nil t)
(goto-char (point-min)) (goto-char (point-min))
(let ((regexp (concat "\\(^\\|\\s-\\)(" (symbol-name sym) " ")) (let ((regexp (concat "\\(^\\|\\s-\\)(" (symbol-name sym) " "))
sexps) sexps)
(while (re-search-forward regexp nil t) (while (re-search-forward regexp nil t)
(let ((sexp (cdr-safe (save-excursion (unless (nth 4 (syntax-ppss))
(beginning-of-defun) (save-excursion
(sexp-at-point))))) (beginning-of-defun)
(push sexp sexps))) (push (cdr (sexp-at-point)) sexps))))
(reverse sexps)))) (reverse sexps))))
;;;###autoload ;;;###autoload