Ensure envvars at top of envvar file are checked
The regexp expects there to be at least one newline at the top of the file, otherwise the very first envvar is skipped.
This commit is contained in:
parent
597ef77c20
commit
0dfdbd471c
1 changed files with 20 additions and 20 deletions
|
@ -108,19 +108,6 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
|
||||||
(unless (string-empty-p errors)
|
(unless (string-empty-p errors)
|
||||||
(print! (info "Error output:\n\n%s") (indent 4 errors))))
|
(print! (info "Error output:\n\n%s") (indent 4 errors))))
|
||||||
;; Remove undesireable variables
|
;; Remove undesireable variables
|
||||||
(while (re-search-forward "\n\\([^= \n]+\\)=" nil t)
|
|
||||||
(save-excursion
|
|
||||||
(let* ((valend (or (save-match-data
|
|
||||||
(when (re-search-forward "^\\([^= ]+\\)=" nil t)
|
|
||||||
(line-beginning-position)))
|
|
||||||
(point-max)))
|
|
||||||
(var (match-string 1)))
|
|
||||||
(when (cl-loop for regexp in doom-env-ignored-vars
|
|
||||||
if (string-match-p regexp var)
|
|
||||||
return t)
|
|
||||||
(print! (info "Ignoring %s") var)
|
|
||||||
(delete-region (match-beginning 0) (1- valend)))))))
|
|
||||||
(goto-char (point-min))
|
|
||||||
(insert
|
(insert
|
||||||
(concat
|
(concat
|
||||||
"# -*- mode: dotenv -*-\n"
|
"# -*- mode: dotenv -*-\n"
|
||||||
|
@ -140,6 +127,19 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
|
||||||
"# To auto-regenerate this file when `doom reload` is run, use `doom env auto' or\n"
|
"# To auto-regenerate this file when `doom reload` is run, use `doom env auto' or\n"
|
||||||
"# set DOOMENV=1 in your shell environment/config.\n"
|
"# set DOOMENV=1 in your shell environment/config.\n"
|
||||||
"# ---------------------------------------------------------------------------\n\n"))
|
"# ---------------------------------------------------------------------------\n\n"))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (re-search-forward "\n\\([^= \n]+\\)=" nil t)
|
||||||
|
(save-excursion
|
||||||
|
(let* ((valend (or (save-match-data
|
||||||
|
(when (re-search-forward "^\\([^= ]+\\)=" nil t)
|
||||||
|
(line-beginning-position)))
|
||||||
|
(point-max)))
|
||||||
|
(var (match-string 1)))
|
||||||
|
(when (cl-loop for regexp in doom-env-ignored-vars
|
||||||
|
if (string-match-p regexp var)
|
||||||
|
return t)
|
||||||
|
(print! (info "Ignoring %s") var)
|
||||||
|
(delete-region (match-beginning 0) (1- valend)))))))
|
||||||
(print! (success "Successfully generated %S")
|
(print! (success "Successfully generated %S")
|
||||||
(relpath doom-env-file doom-emacs-dir))
|
(relpath doom-env-file doom-emacs-dir))
|
||||||
t)))))
|
t)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue