From 4ea47541626d77dbbd11031637bd7b3fa35a3524 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 27 Sep 2018 23:05:04 -0400 Subject: [PATCH] Add commands for using bin/doom from inside Emacs This is experimental. I'd eventually like users to be able to management Doom from inside Emacs, if they desire. This may be the only way to have a decent user experience on Windows, for that matter. Also adds a popup rule for it. --- core/autoload/cli.el | 66 ++++++++++++++++++++++++++++++++++++++ core/autoload/help.el | 21 ------------ modules/ui/popup/config.el | 4 ++- 3 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 core/autoload/cli.el diff --git a/core/autoload/cli.el b/core/autoload/cli.el new file mode 100644 index 000000000..5ab0f66d0 --- /dev/null +++ b/core/autoload/cli.el @@ -0,0 +1,66 @@ +;;; core/autoload/cli.el -*- lexical-binding: t; -*- + +(require 'core-cli) + +(defun doom--run (command &optional yes) + (let ((default-directory doom-emacs-dir) + (doom-auto-accept yes)) + (let ((compilation-buffer-name-function (lambda (_) "*bin/doom*"))) + (compile (format "bin/doom %s" command) t)) + (while compilation-in-progress + (sit-for 1)) + (when (y-or-n-p "Reload Doom config?") + (doom/reload)) + (message "Done"))) + + +;;;###autoload +(defun doom//update (&optional yes) + "TODO" + (interactive "P") + (doom--run "update" yes)) + +;;;###autoload +(defun doom//upgrade (&optional yes) + "TODO" + (interactive "P") + (doom--run "upgrade" yes)) + +;;;###autoload +(defun doom//install (&optional yes) + "TODO" + (interactive "P") + (doom--run "install" yes)) + +;;;###autoload +(defun doom//autoremove (&optional yes) + "TODO" + (interactive "P") + (doom--run "autoremove" yes)) + +;;;###autoload +(defun doom//refresh (&optional yes) + "TODO" + (interactive "P") + (doom--run "refresh" yes)) + +;;;###autoload +(defun doom/reload (&optional force-p) + "Reloads your config. This is experimental! + +If called from a noninteractive session, this will try to communicate with a +live server (if one is found) to tell it to run this function. + +If called from an interactive session, tries to reload autoloads files (if +necessary), reinistalize doom (via `doom-initialize') and reloads your private +init.el and config.el. Then runs `doom-reload-hook'." + (interactive "P") + (require 'core-cli) + (doom-reload-autoloads force-p) + (setq load-path doom-site-load-path) + (let (doom-init-p) + (doom-initialize)) + (with-demoted-errors "PRIVATE CONFIG ERROR: %s" + (doom-initialize-modules 'force)) + (run-hook-wrapped 'doom-reload-hook #'doom-try-run-hook) + (message "Finished!")) diff --git a/core/autoload/help.el b/core/autoload/help.el index c30be5e94..75d4d1a69 100644 --- a/core/autoload/help.el +++ b/core/autoload/help.el @@ -220,24 +220,3 @@ whose car is the list of faces and cadr is the list of overlay faces." "TODO" (interactive) (find-file (expand-file-name "index.org" doom-docs-dir))) - -;;;###autoload -(defun doom/reload (&optional force-p) - "Reloads your config. This is experimental! - -If called from a noninteractive session, this will try to communicate with a -live server (if one is found) to tell it to run this function. - -If called from an interactive session, tries to reload autoloads files (if -necessary), reinistalize doom (via `doom-initialize') and reloads your private -init.el and config.el. Then runs `doom-reload-hook'." - (interactive "P") - (require 'core-cli) - (doom-reload-autoloads force-p) - (setq load-path doom-site-load-path) - (let (doom-init-p) - (doom-initialize)) - (with-demoted-errors "PRIVATE CONFIG ERROR: %s" - (doom-initialize-modules 'force)) - (run-hook-wrapped 'doom-reload-hook #'doom-try-run-hook) - (message "Finished!")) diff --git a/modules/ui/popup/config.el b/modules/ui/popup/config.el index 583ef3122..e2dbf8958 100644 --- a/modules/ui/popup/config.el +++ b/modules/ui/popup/config.el @@ -132,7 +132,9 @@ prevent the popup(s) from messing up the UI (or vice versa)." '(("^\\*" :slot 1 :vslot -1 :select t) ("^ \\*" :slot 1 :vslot -1 :size +popup-shrink-to-fit))) (when (featurep! +defaults) - '(("^\\*Completions" + '(("^\\*bin/doom\\*$" + :vslot 9999 :size 0.75 :quit 'current :select t :ttl 0) + ("^\\*Completions" :slot -1 :vslot -2 :ttl 0) ("^\\*Compil\\(?:ation\\|e-Log\\)" :size 0.3 :ttl 0 :quit t)