2019-03-02 01:12:48 -05:00
|
|
|
;;; core/autoload/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2019-12-13 15:23:23 -05:00
|
|
|
(defvar doom-bin-dir (concat doom-emacs-dir "bin/"))
|
|
|
|
(defvar doom-bin (concat doom-bin-dir "doom"))
|
|
|
|
|
2019-07-18 15:27:20 +02:00
|
|
|
;;;###autoload
|
|
|
|
(defvar doom-reload-hook nil
|
|
|
|
"A list of hooks to run when `doom/reload' is called.")
|
|
|
|
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
;;;###autoload
|
|
|
|
(defvar doom-reloading-p nil
|
|
|
|
"TODO")
|
|
|
|
|
2019-03-02 01:12:48 -05:00
|
|
|
;;;###autoload
|
|
|
|
(defun doom/open-private-config ()
|
2019-04-23 22:10:41 -04:00
|
|
|
"Browse your `doom-private-dir'."
|
2019-03-02 01:12:48 -05:00
|
|
|
(interactive)
|
|
|
|
(unless (file-directory-p doom-private-dir)
|
|
|
|
(make-directory doom-private-dir t))
|
|
|
|
(doom-project-browse doom-private-dir))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom/find-file-in-private-config ()
|
2019-04-23 22:10:41 -04:00
|
|
|
"Search for a file in `doom-private-dir'."
|
2019-03-02 01:12:48 -05:00
|
|
|
(interactive)
|
|
|
|
(doom-project-find-file doom-private-dir))
|
|
|
|
|
2019-10-25 18:19:33 -04:00
|
|
|
;;;###autoload
|
2019-12-29 18:22:44 -05:00
|
|
|
(defun doom/goto-private-init-file ()
|
|
|
|
"Open your private init.el file.
|
|
|
|
And jumps to your `doom!' block."
|
2019-10-25 18:19:33 -04:00
|
|
|
(interactive)
|
|
|
|
(find-file (expand-file-name "init.el" doom-private-dir))
|
|
|
|
(goto-char
|
|
|
|
(or (save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(search-forward "(doom!" nil t))
|
|
|
|
(point))))
|
|
|
|
|
|
|
|
;;;###autoload
|
2019-12-29 18:22:44 -05:00
|
|
|
(defun doom/goto-private-config-file ()
|
2019-10-25 18:19:33 -04:00
|
|
|
"Open your private config.el file."
|
|
|
|
(interactive)
|
|
|
|
(find-file (expand-file-name "config.el" doom-private-dir)))
|
|
|
|
|
|
|
|
;;;###autoload
|
2019-12-29 18:22:44 -05:00
|
|
|
(defun doom/goto-private-packages-file ()
|
2019-10-25 18:19:33 -04:00
|
|
|
"Open your private packages.el file."
|
|
|
|
(interactive)
|
|
|
|
(find-file (expand-file-name "packages.el" doom-private-dir)))
|
|
|
|
|
2019-12-13 15:23:23 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
;;; Managements
|
|
|
|
|
|
|
|
(cl-defmacro doom--compile (command &key on-success on-failure)
|
|
|
|
(declare (indent defun))
|
|
|
|
`(with-current-buffer (compile ,command)
|
|
|
|
(add-hook
|
|
|
|
'compilation-finish-functions
|
|
|
|
(lambda (_buf status)
|
|
|
|
(if (equal status "finished\n")
|
|
|
|
,on-success
|
|
|
|
,on-failure))
|
|
|
|
nil 'local)))
|
|
|
|
|
2019-03-02 01:12:48 -05:00
|
|
|
;;;###autoload
|
2019-07-28 14:16:33 +02:00
|
|
|
(defun doom/reload ()
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
"Reloads your private config.
|
2019-03-02 01:12:48 -05:00
|
|
|
|
2020-02-19 23:34:16 -05:00
|
|
|
This is experimental! It will try to do as `bin/doom sync' does, but from within
|
|
|
|
this Emacs session. i.e. it reload autoloads files (if necessary), reloads your
|
|
|
|
package list, and lastly, reloads your private config.el.
|
2019-03-02 01:12:48 -05:00
|
|
|
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
Runs `doom-reload-hook' afterwards."
|
2019-07-28 14:16:33 +02:00
|
|
|
(interactive)
|
2019-03-02 01:12:48 -05:00
|
|
|
(require 'core-cli)
|
2019-12-15 21:53:26 -05:00
|
|
|
(when (and IS-WINDOWS (file-exists-p doom-env-file))
|
|
|
|
(warn "Can't regenerate envvar file from within Emacs. Run 'doom env' from the console"))
|
2020-02-19 23:34:16 -05:00
|
|
|
(doom--compile (format "%s sync -e" doom-bin)
|
2019-12-13 15:23:23 -05:00
|
|
|
:on-success
|
|
|
|
(let ((doom-reloading-p t))
|
|
|
|
(doom-initialize 'force)
|
|
|
|
(with-demoted-errors "PRIVATE CONFIG ERROR: %s"
|
|
|
|
(general-auto-unbind-keys)
|
|
|
|
(unwind-protect
|
|
|
|
(doom-initialize-modules 'force)
|
|
|
|
(general-auto-unbind-keys t)))
|
|
|
|
(run-hook-wrapped 'doom-reload-hook #'doom-try-run-hook)
|
|
|
|
(print! (success "Config successfully reloaded!")))
|
|
|
|
:on-failure
|
|
|
|
(user-error "Failed to reload your config")))
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
|
2019-07-07 13:12:35 +02:00
|
|
|
;;;###autoload
|
2019-07-27 17:03:44 +02:00
|
|
|
(defun doom/reload-autoloads ()
|
2019-07-07 13:12:35 +02:00
|
|
|
"Reload only `doom-autoload-file' and `doom-package-autoload-file'.
|
|
|
|
|
|
|
|
This is much faster and safer than `doom/reload', but not as comprehensive. This
|
2019-10-25 18:22:19 -04:00
|
|
|
reloads your package and module visibility, but does not install new packages or
|
|
|
|
remove orphaned ones. It also doesn't reload your private config.
|
2019-07-07 13:12:35 +02:00
|
|
|
|
2020-02-19 23:34:16 -05:00
|
|
|
It is useful to only pull in changes performed by 'doom sync' on the command
|
2019-07-07 13:12:35 +02:00
|
|
|
line."
|
2019-07-27 17:03:44 +02:00
|
|
|
(interactive)
|
|
|
|
(require 'core-cli)
|
|
|
|
(require 'core-packages)
|
|
|
|
(doom-initialize-packages)
|
2019-12-30 06:44:16 -05:00
|
|
|
(doom-cli-reload-autoloads))
|
2019-07-07 13:12:35 +02:00
|
|
|
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
;;;###autoload
|
2019-12-13 15:23:23 -05:00
|
|
|
(defun doom/reload-env (&optional arg)
|
|
|
|
"Regenerates and/or reloads your envvar file.
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
|
2019-12-13 15:23:23 -05:00
|
|
|
If passed the prefix ARG, clear the envvar file. Uses the same mechanism as
|
|
|
|
'bin/doom env'.
|
|
|
|
|
|
|
|
An envvar file contains a snapshot of your shell environment, which can be
|
|
|
|
imported into Emacs."
|
|
|
|
(interactive "P")
|
2019-12-15 21:53:26 -05:00
|
|
|
(when IS-WINDOWS
|
|
|
|
(user-error "Cannot reload envvar file from within Emacs on Windows, run it from cmd.exe"))
|
2019-12-15 21:42:56 -05:00
|
|
|
(doom--compile
|
2019-12-15 21:54:01 -05:00
|
|
|
(format "%s -ic '%s env%s'"
|
|
|
|
(string-trim
|
|
|
|
(shell-command-to-string
|
|
|
|
(format "getent passwd %S | cut -d: -f7"
|
|
|
|
(user-login-name))))
|
|
|
|
doom-bin (if arg " -c" ""))
|
2019-12-13 15:23:23 -05:00
|
|
|
:on-success
|
|
|
|
(let ((doom-reloading-p t))
|
|
|
|
(unless arg
|
|
|
|
(doom-load-envvars-file doom-env-file)))
|
|
|
|
:on-failure
|
|
|
|
(error "Failed to generate env file")))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun doom/upgrade ()
|
|
|
|
"Run 'doom upgrade' then prompt to restart Emacs."
|
:boom: Replace exec-path-from-shell w/ 'bin/doom env'
IMPORTANT: This is a breaking update for Mac users, as your shell
environment will no longer be inherited correctly (with the removal of
exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also,
the set-env! autodef now does nothing (and is deprecated), be sure to
remove calls to it in your config.
Smaller changes:
+ This update also adds --no-* switches to doom quickstart
+ Includes general improvements to the documentation of several bin/doom
commands.
+ Moves doom/reload* commands to core/autoload/config.el
+ doom/reload-project has been removed (it didn't actually do anything)
The breaking change:
This update adds an "envvar file" to Doom Emacs. This file is generated
by `doom env refresh`, populated with variables scraped from your shell
environment (from both non-interactive and interactive sessions). This
file is then (inexpensively) loaded at startup, if it exists.
+ The file is manually generated with `doom env refresh`.
+ It can be regenerated automatically whenever `doom refresh` is run by
running `doom env enable` (`doom env clear` will reverse this and
delete the env file).
+ `doom quickstart` will ask if you want to auto-generate this envvar
file. You won't need it if you're confident Emacs will always be
started from the correct environment, however.
+ Your env file can be reloaded from a running Emacs session with `M-x
doom/reload-env`. Note: this won't work if the Emacs session you're
running it in doesn't have a correct SHELL set. i.e. don't use this to
create your first env file!
The idea isn't mine -- it's borrowed from Spacemacs -- and was
introduced to me in #1053 by @yurimx. I was impressed with it. Prior to
this, I was unhappy with exec-path-from-shell (no hate to the dev, I
understand its necessity), and 'doom patch-macos' wasn't ideal for mac
users (needed to be reapplied every time you update Emacs). What's more,
many users (even Linux users) had to install exec-path-from-shell
anyway.
This solution suffers from none of their shortcomings. More reliable
than patch-macos, more performant and complete than
exec-path-from-shell, and easily handled by bin/doom.
2019-03-28 00:06:10 -04:00
|
|
|
(interactive)
|
2019-12-13 15:23:23 -05:00
|
|
|
(doom--compile (format "%s upgrade" doom-bin)
|
|
|
|
:on-success
|
|
|
|
(when (y-or-n-p "You must restart Emacs for the upgrade to take effect.\n\nRestart Emacs?")
|
|
|
|
(doom/restart-and-restore))))
|