Restore comment header in envvar files
`shell-command` erases the target buffer before piping output to it. Which means the envvar file comment header was wiped out. This causes trouble for the envvar file parser, which expects the envvar list to start with two newlines.
This commit is contained in:
parent
331a53c0a1
commit
9311744f7f
1 changed files with 20 additions and 19 deletions
|
@ -94,25 +94,6 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
|
|||
"Generating")
|
||||
(relpath doom-env-file doom-emacs-dir))
|
||||
(let ((process-environment doom--initial-process-environment))
|
||||
(insert
|
||||
(concat
|
||||
"# -*- mode: dotenv -*-\n"
|
||||
(format "# Generated with: %s %s %s\n"
|
||||
shell-file-name
|
||||
doom-env-switches
|
||||
doom-env-executable)
|
||||
"# ---------------------------------------------------------------------------\n"
|
||||
"# This file was auto-generated by `doom env refresh'. It contains a list of\n"
|
||||
"# environment variables scraped from your default shell (excluding variables\n"
|
||||
"# blacklisted in doom-env-ignored-vars).\n"
|
||||
"#\n"
|
||||
"# It is NOT safe to edit this file. Changes will be overwritten next time that\n"
|
||||
"# `doom env refresh` is executed. Alternatively, create your own env file and\n"
|
||||
"# load it with `(doom-load-envvars-file FILE)`.\n"
|
||||
"#\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"
|
||||
"# ---------------------------------------------------------------------------\n\n"))
|
||||
(let ((shell-command-switch doom-env-switches)
|
||||
(error-buffer (get-buffer-create "*env errors*")))
|
||||
(print! (info "Scraping shell environment with '%s %s %s'")
|
||||
|
@ -138,6 +119,26 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
|
|||
return t)
|
||||
(print! (info "Ignoring %s") var)
|
||||
(delete-region (match-beginning 0) (1- valend)))))))
|
||||
(goto-char (point-min))
|
||||
(insert
|
||||
(concat
|
||||
"# -*- mode: dotenv -*-\n"
|
||||
(format "# Generated with: %s %s %s\n"
|
||||
shell-file-name
|
||||
doom-env-switches
|
||||
doom-env-executable)
|
||||
"# ---------------------------------------------------------------------------\n"
|
||||
"# This file was auto-generated by `doom env refresh'. It contains a list of\n"
|
||||
"# environment variables scraped from your default shell (excluding variables\n"
|
||||
"# blacklisted in doom-env-ignored-vars).\n"
|
||||
"#\n"
|
||||
"# It is NOT safe to edit this file. Changes will be overwritten next time that\n"
|
||||
"# `doom env refresh` is executed. Alternatively, create your own env file and\n"
|
||||
"# load it with `(doom-load-envvars-file FILE)`.\n"
|
||||
"#\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"
|
||||
"# ---------------------------------------------------------------------------\n\n"))
|
||||
(print! (success "Successfully generated %S")
|
||||
(relpath doom-env-file doom-emacs-dir))
|
||||
t)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue