From a9d7fc099d02257434598a6c905552860445d4c7 Mon Sep 17 00:00:00 2001 From: Steven vanZyl Date: Fri, 17 Apr 2020 15:48:54 -0400 Subject: [PATCH 001/103] Improved Eshell module part 1 Added a README file detailing the Eshell module, a few minor tweaks to the config, some keybindings, and the eshell-did-you-mean package. More to come! --- modules/term/eshell/README.org | 45 +++++++++++++++++++++++++++++++++ modules/term/eshell/config.el | 16 +++++++++++- modules/term/eshell/packages.el | 1 + 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 modules/term/eshell/README.org diff --git a/modules/term/eshell/README.org b/modules/term/eshell/README.org new file mode 100644 index 000000000..8d9f63adf --- /dev/null +++ b/modules/term/eshell/README.org @@ -0,0 +1,45 @@ +#+TITLE: term/eshell +#+DATE: April 17, 2020 +#+SINCE: {replace with next tagged release version} +#+STARTUP: inlineimages nofold + +* Table of Contents :TOC_3:noexport: + +* Description +This module provides additional features for the built-in [[https://www.gnu.org/software/emacs/manual/html_mono/eshell.html][Emacs Shell]] + +The Emacs Shell or =eshell= is a shell-like command interpreter implemented in +Emacs Lisp. It is an alternative to traditional shells such as =bash=, =zsh=, +=fish=, etc. that is built into Emacs and entirely cross-platform. + +** Maintainers +This module has no dedicated maintainers. + +** Module Flags +This module provides no flags, but does gain auto-completion if =:completion +company= is enabled. + +** Plugins ++ [[https://github.com/peterwvj/eshell-up][eshell-up]] ++ [[https://github.com/xuchunyang/eshell-z][eshell-z]] ++ [[https://github.com/tom-tan/esh-help][esh-help]] ++ [[https://gitlab.com/bennya/shrink-path.el][shrink-path]] ++ [[https://github.com/xuchunyang/eshell-did-you-mean][eshell-did-you-mean]] ++ =:completion company= + + [[https://gitlab.com/ambrevar/emacs-fish-completion][fish-completion]] + + [[https://github.com/szermatt/emacs-bash-completion][bash-completion]] + +* Prerequisites +This module has no prerequisites. + +* Features ++ Command completion with Company ++ =fish=-style prompt with Git integration ++ [[https://github.com/rupa/z][=z=]]-like directory jumping ++ Command-not-found recommendations + +* TODO Configuration +# How to configure this module, including common problems and how to address them. + +* TODO Troubleshooting +# Common issues and their solution, or places to look for help. diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 412d69bdc..0b923faff 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -82,6 +82,10 @@ You should use `set-eshell-alias!' to change this.") ;; Enable autopairing in eshell (add-hook 'eshell-mode-hook #'smartparens-mode) + ;; Comapny completion integration + (when (featurep! :completion company) + (add-hook 'eshell-mode-hook #'company-mode)) + ;; Persp-mode/workspaces integration (when (featurep! :ui workspaces) (add-hook 'persp-activated-functions #'+eshell-switch-workspace-fn) @@ -152,7 +156,13 @@ You should use `set-eshell-alias!' to change this.") [remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input [remap evil-delete-back-to-indentation] #'eshell-kill-input [remap evil-window-split] #'+eshell/split-below - [remap evil-window-vsplit] #'+eshell/split-right)))) + [remap evil-window-vsplit] #'+eshell/split-right + + ;; Local-leader keybindings + (:localleader + "b" #'eshell-insert-buffer-name + "e" #'eshell-insert-envvar + "s" #'+eshell/search-history))))) (use-package! eshell-up @@ -183,3 +193,7 @@ You should use `set-eshell-alias!' to change this.") (defadvice! +eshell--fallback-to-bash-a (&rest _) :before-while #'fish-completion--list-completions-with-desc (executable-find "fish"))) + +;; Active eshell-did-you-mean using its setup function which provides +;; its own hooks. +(eshell-did-you-mean-setup) diff --git a/modules/term/eshell/packages.el b/modules/term/eshell/packages.el index 82a18ed14..0d287a889 100644 --- a/modules/term/eshell/packages.el +++ b/modules/term/eshell/packages.el @@ -5,6 +5,7 @@ (package! eshell-z :pin "337cb241e1") (package! shrink-path :pin "c14882c859") (package! esh-help :pin "417673ed18") +(package! eshell-did-you-mean :pin "7cb6ef") (when (featurep! :completion company) (package! fish-completion :pin "1038488181") From 85cf7a794b465ec4d0a9aa08552e81804072fb46 Mon Sep 17 00:00:00 2001 From: Steven vanZyl Date: Tue, 28 Apr 2020 09:35:06 -0400 Subject: [PATCH 002/103] Fixes from PR feedback This contains fixes suggested by Henrik as feedback from the initial PR, including updating and correcting the Eshell module README, and few tweaks to the module configuration, and properly pinning eshell-did-you-mean. --- modules/completion/company/config.el | 2 +- modules/term/eshell/README.org | 15 ++++++++++++--- modules/term/eshell/config.el | 10 +++------- modules/term/eshell/packages.el | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 62a1a4f52..c44adb444 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -10,7 +10,7 @@ company-tooltip-align-annotations t company-require-match 'never company-global-modes - '(not erc-mode message-mode help-mode gud-mode eshell-mode) + '(not erc-mode message-mode help-mode gud-mode) company-backends '(company-capf) company-frontends '(company-pseudo-tooltip-frontend company-echo-metadata-frontend)) diff --git a/modules/term/eshell/README.org b/modules/term/eshell/README.org index 8d9f63adf..de43e43f8 100644 --- a/modules/term/eshell/README.org +++ b/modules/term/eshell/README.org @@ -1,9 +1,17 @@ #+TITLE: term/eshell -#+DATE: April 17, 2020 -#+SINCE: {replace with next tagged release version} +#+DATE: May 18, 2020 +#+SINCE: v2.0 #+STARTUP: inlineimages nofold * Table of Contents :TOC_3:noexport: +- [[#description][Description]] + - [[#maintainers][Maintainers]] + - [[#module-flags][Module Flags]] + - [[#plugins][Plugins]] +- [[#prerequisites][Prerequisites]] +- [[#features][Features]] +- [[#configuration][Configuration]] +- [[#troubleshooting][Troubleshooting]] * Description This module provides additional features for the built-in [[https://www.gnu.org/software/emacs/manual/html_mono/eshell.html][Emacs Shell]] @@ -30,7 +38,8 @@ company= is enabled. + [[https://github.com/szermatt/emacs-bash-completion][bash-completion]] * Prerequisites -This module has no prerequisites. +[[https://fishshell.com/][=fish= shell]] for completions, falling back to [[https://www.gnu.org/software/bash/][=bash= shell]] if =fish= is not +found. If neither shell is found, completions may not be available. * Features + Command completion with Company diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 51afe2b15..d58ce2bd6 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -82,10 +82,6 @@ You should use `set-eshell-alias!' to change this.") ;; Enable autopairing in eshell (add-hook 'eshell-mode-hook #'smartparens-mode) - ;; Comapny completion integration - (when (featurep! :completion company) - (add-hook 'eshell-mode-hook #'company-mode)) - ;; Persp-mode/workspaces integration (when (featurep! :ui workspaces) (add-hook 'persp-activated-functions #'+eshell-switch-workspace-fn) @@ -157,8 +153,6 @@ You should use `set-eshell-alias!' to change this.") [remap evil-delete-back-to-indentation] #'eshell-kill-input [remap evil-window-split] #'+eshell/split-below [remap evil-window-vsplit] #'+eshell/split-right - - ;; Local-leader keybindings (:localleader "b" #'eshell-insert-buffer-name "e" #'eshell-insert-envvar @@ -196,4 +190,6 @@ You should use `set-eshell-alias!' to change this.") ;; Active eshell-did-you-mean using its setup function which provides ;; its own hooks. -(eshell-did-you-mean-setup) +(use-package! eshell-did-you-mean + :after eshell + :config (eshell-did-you-mean-setup)) diff --git a/modules/term/eshell/packages.el b/modules/term/eshell/packages.el index 0d287a889..1ca415927 100644 --- a/modules/term/eshell/packages.el +++ b/modules/term/eshell/packages.el @@ -5,7 +5,7 @@ (package! eshell-z :pin "337cb241e1") (package! shrink-path :pin "c14882c859") (package! esh-help :pin "417673ed18") -(package! eshell-did-you-mean :pin "7cb6ef") +(package! eshell-did-you-mean :pin "7cb6ef8e22") (when (featurep! :completion company) (package! fish-completion :pin "1038488181") From a82d93630ff140204efb5c4754c08e1f2d9de725 Mon Sep 17 00:00:00 2001 From: Steven vanZyl Date: Tue, 28 Apr 2020 16:54:34 -0400 Subject: [PATCH 003/103] Fix DYM and add aliases Fixed the use-package! declaration for eshell-did-you-mean since it needed a different mode in the :after than I thought. I also put together a quick hack to try and fix an issue with did-you-mean, but it doesn't seem to work reliably right now. More testing required. Also added two aliases, one `gg` for to open magit-status and one `ff` as an additional alias to find-file that follows the Doom keybindings better. --- modules/term/eshell/README.org | 7 +++++++ modules/term/eshell/config.el | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/modules/term/eshell/README.org b/modules/term/eshell/README.org index de43e43f8..ad3c5878b 100644 --- a/modules/term/eshell/README.org +++ b/modules/term/eshell/README.org @@ -8,6 +8,7 @@ - [[#maintainers][Maintainers]] - [[#module-flags][Module Flags]] - [[#plugins][Plugins]] + - [[#hacks][Hacks]] - [[#prerequisites][Prerequisites]] - [[#features][Features]] - [[#configuration][Configuration]] @@ -37,6 +38,12 @@ company= is enabled. + [[https://gitlab.com/ambrevar/emacs-fish-completion][fish-completion]] + [[https://github.com/szermatt/emacs-bash-completion][bash-completion]] +** Hacks ++ Even with =fish-completion-fallback-on-bash-p= non-nil, fish must be installed + for bash completion to work. Workaround in =config.el=. ++ =eshell-did-you-mean= does not work on first invocation, so we manually invoke + it once. + * Prerequisites [[https://fishshell.com/][=fish= shell]] for completions, falling back to [[https://www.gnu.org/software/bash/][=bash= shell]] if =fish= is not found. If neither shell is found, completions may not be available. diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index d58ce2bd6..b84b9016c 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -12,6 +12,10 @@ "Where to store eshell configuration files, as opposed to `eshell-directory-name', which is where Doom will store temporary/data files.") +(defvar eshell-directory-name (concat doom-etc-dir "eshell") + "Where to store temporary/data files, as opposed to `eshell-config-dir', +which is where Doom will store eshell configuration files.") + (defvar +eshell-enable-new-shell-on-split t "If non-nil, spawn a new eshell session after splitting from an eshell buffer.") @@ -22,11 +26,13 @@ buffer.") (defvar +eshell-aliases '(("q" "exit") ; built-in ("f" "find-file $1") + ("ff" "find-file $1") ("d" "dired $1") ("bd" "eshell-up $1") ("rg" "rg --color=always $*") ("l" "ls -lh $*") ("ll" "ls -lah $*") + ("gg" "magit-status") ("clear" "clear-scrollback")) ; more sensible than default "An alist of default eshell aliases, meant to emulate useful shell utilities, like fasd and bd. Note that you may overwrite these in your @@ -35,15 +41,11 @@ to define your aliases. You should use `set-eshell-alias!' to change this.") -;; -(defvar eshell-directory-name (concat doom-etc-dir "eshell")) - ;; These files are exceptions, because they may contain configuration (defvar eshell-aliases-file (concat +eshell-config-dir "aliases")) (defvar eshell-rc-script (concat +eshell-config-dir "profile")) (defvar eshell-login-script (concat +eshell-config-dir "login")) - (defvar +eshell--default-aliases nil) @@ -188,8 +190,14 @@ You should use `set-eshell-alias!' to change this.") :before-while #'fish-completion--list-completions-with-desc (executable-find "fish"))) -;; Active eshell-did-you-mean using its setup function which provides -;; its own hooks. + +;; Activate eshell-did-you-mean using its setup function (lazily) (use-package! eshell-did-you-mean - :after eshell - :config (eshell-did-you-mean-setup)) + :after esh-mode ; Specifically esh-mode, not eshell + :config + (eshell-did-you-mean-setup) + ;; HACK There is a known issue with `eshell-did-you-mean' where it does not + ;; work on first invocation, so we invoke it once manually by setting + ;; the last command and then calling the output filter. + (setq eshell-last-command-name "catt") + (eshell-did-you-mean-output-filter "catt: command not found")) From 4a3aacb2198056f8dc9b4c68c83ecfe3d55042e4 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Sat, 9 May 2020 20:58:15 -0500 Subject: [PATCH 004/103] Update mu4e home-manager config to permalink --- modules/email/mu4e/README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/email/mu4e/README.org b/modules/email/mu4e/README.org index 93f2ab37c..ca88d65b5 100644 --- a/modules/email/mu4e/README.org +++ b/modules/email/mu4e/README.org @@ -80,7 +80,7 @@ environment.systemPackages = with pkgs; [ ]; #+END_SRC -[[https://github.com/Emiller88/dotfiles/blob/master/modules/shell/mail.nix][An example of setting up mbsync with home-manager]] +[[https://github.com/Emiller88/dotfiles/blob/5eaabedf1b141c80a8d32e1b496055231476f65e/modules/shell/mail.nix][An example of setting up mbsync and mu with home-manager]] ** openSUSE Remove ~#~ in ~#sync_program=offlineimap~ to choose ~offlineimap~ instead of From c30f5cefb8e10628b3981177ae47b33ae3787f9c Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Sat, 9 May 2020 21:41:30 -0500 Subject: [PATCH 005/103] Add initial notmuch README --- modules/email/notmuch/README.org | 110 +++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 modules/email/notmuch/README.org diff --git a/modules/email/notmuch/README.org b/modules/email/notmuch/README.org new file mode 100644 index 000000000..5fe167b42 --- /dev/null +++ b/modules/email/notmuch/README.org @@ -0,0 +1,110 @@ +#+TITLE: email/notmuch +#+DATE: July 31, 2018 +#+SINCE: v2.0.9 +#+STARTUP: inlineimages + +* Table of Contents :TOC: +- [[#description][Description]] + - [[#module-flags][Module Flags]] + - [[#plugins][Plugins]] +- [[#prerequisites][Prerequisites]] + - [[#macos][MacOS]] + - [[#arch-linux][Arch Linux]] + - [[#nixos][NixOS]] + - [[#opensuse][openSUSE]] + - [[#debianubuntu][Debian/Ubuntu]] +- [[#features][Features]] +- [[#configuration][Configuration]] + - [[#gmailier][Gmailier]] + - [[#offlineimap][offlineimap]] + - [[#mbsync][mbsync]] + - [[#notmuch][notmuch]] +- [[#troubleshooting][Troubleshooting]] + +* Description +This module makes Emacs an email client, using ~notmuch~. + +** Module Flags ++ This module install no module flags. + + +** Plugins ++ [[https://notmuchmail.org/][notmuch]] ++ [[https://github.com/org-mime/org-mime][org-mime]] + +* Prerequisites +This module requires: + ++ Either ~gmailieer~ (default), ~mbsync~ or ~offlineimap~ (to sync mail with) ++ ~notmuch~, to index and tag your downloaded messages. ++ ~afew~, optionally to initially tag your downloaded messages. + +** TODO MacOS + +** TODO Arch Linux +** NixOS +#+BEGIN_SRC nix +environment.systemPackages = with pkgs; [ + notmuch + # And one of the following + gmailieer + isync + offlineimap +]; +#+END_SRC + +[[https://github.com/Emiller88/dotfiles/blob/319841bd3b89e59b01d169137cceee3183aba4fc/modules/shell/mail.nix][An example of setting up mbsync and notmuch with home-manager]] + +** TODO openSUSE +** TODO Debian/Ubuntu +* TODO Features + +* Configuration +** TODO Gmailier +** offlineimap +This module uses =Gmailier= by default. To use =offlineimap=, change ~+notmuch-sync-backend~: + +#+BEGIN_SRC emacs-lisp +(setq +notmuch-sync-backend 'offlineimap) +#+END_SRC + +Next, you need to write a configuration file for =offlineimap=. Mine can be found +[[https://github.com/hlissner/dotfiles/tree/master/shell/mu][in my dotfiles repository]]. It is configured to download mail to ~\~/.mail~. I +use [[https://www.passwordstore.org/][unix pass]] to securely store my login credentials. You can find a *very* +detailed configuration [[https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf][here]]. + +Next you can download your email with ~offlineimap -o~. This may take a while, +especially if you have thousands of mails. + +You can now proceed with the [[*mu and mu4e][mu and mu4e]] section. + +** mbsync +This module uses =Gmailier= by default. To use =mbsync=, change ~+notmuch-sync-backend~: + +#+BEGIN_SRC emacs-lisp +(setq +notmuch-sync-backend 'mbsync) +#+END_SRC + +The steps needed to set up =mu4e= with =mbsync= are very similar to the ones for +[[*offlineimap][offlineimap]]. + +Start with writing a ~\~/.mbsyncrc~. An example for GMAIL can be found on +[[http://pragmaticemacs.com/emacs/migrating-from-offlineimap-to-mbsync-for-mu4e/][pragmaticemacs.com]]. A non-GMAIL example is available as a gist [[https://gist.github.com/agraul/60977cc497c3aec44e10591f94f49ef0][here]]. The [[http://isync.sourceforge.net/mbsync.html][manual +page]] contains all needed information to set up your own. + +Next you can download your email with ~mbsync --all~. This may take a while, but +should be quicker than =offlineimap= ;). + +You can now proceed with the [[*mu and mu4e][mu and mu4e]] section. + +** notmuch +You should have your email downloaded already. If you have not, you need to set +=Gmailier=, =offlineimap= or =mbsync= up before you proceed. + +Before you can use =notmuch=, you need to index your email initially. + +#+BEGIN_SRC sh +notmuch new +#+END_SRC + +* Troubleshooting From 1fccec181c4b773761a9c0a263a73604121ba0f6 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 10 May 2020 16:09:45 +0200 Subject: [PATCH 006/103] Unify org-agenda-clock bindings with org-clock Following b40d85e9b --- modules/lang/org/config.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 1e556547a..2079b5d01 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -707,12 +707,12 @@ between the two." :localleader "d" #'org-agenda-deadline (:prefix ("c" . "clock") - "c" #'org-agenda-clock-in - "C" #'org-agenda-clock-out + "c" #'org-agenda-clock-cancel "g" #'org-agenda-clock-goto + "i" #'org-agenda-clock-in + "o" #'org-agenda-clock-out "r" #'org-agenda-clockreport-mode - "s" #'org-agenda-show-clocking-issues - "x" #'org-agenda-clock-cancel) + "s" #'org-agenda-show-clocking-issues) "q" #'org-agenda-set-tags "r" #'org-agenda-refile "s" #'org-agenda-schedule From 58377e01c45b10f69508b25bb380233b83d0a45b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 May 2020 18:26:33 -0400 Subject: [PATCH 007/103] Correct DATE and SINCE --- modules/email/notmuch/README.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/email/notmuch/README.org b/modules/email/notmuch/README.org index 5fe167b42..9125f8dd4 100644 --- a/modules/email/notmuch/README.org +++ b/modules/email/notmuch/README.org @@ -1,6 +1,6 @@ #+TITLE: email/notmuch -#+DATE: July 31, 2018 -#+SINCE: v2.0.9 +#+DATE: May 5, 2019 +#+SINCE: v2.0 #+STARTUP: inlineimages * Table of Contents :TOC: From a634aaa4e8af510c9d9f90431d0b7c76c517d0b5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 May 2020 17:21:18 -0400 Subject: [PATCH 008/103] Bump :lang markdown jrblevin/markdown-mode@c927a11 -> jrblevin/markdown-mode@f47a2e9 ardumont/markdown-toc@eda9650 -> ardumont/markdown-toc@a9f13ee Somelauw/evil-markdown@46cd81b -> Somelauw/evil-markdown@685d7fb Reverts 35f18c5e74 because Somelauw/evil-markdown#1 was merged --- modules/lang/markdown/config.el | 4 ---- modules/lang/markdown/packages.el | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/lang/markdown/config.el b/modules/lang/markdown/config.el index 448710520..d82e396db 100644 --- a/modules/lang/markdown/config.el +++ b/modules/lang/markdown/config.el @@ -92,10 +92,6 @@ capture, the end position, and the output buffer.") (use-package! evil-markdown :when (featurep! :editor evil +everywhere) :hook (markdown-mode . evil-markdown-mode) - :init - ;; REVIEW Until Somelauw/evil-markdown#1 is resolved: - (defun evil-disable-insert-state-bindings () - evil-disable-insert-state-bindings) :config (add-hook 'evil-markdown-mode-hook #'evil-normalize-keymaps) (map! :map evil-markdown-mode-map diff --git a/modules/lang/markdown/packages.el b/modules/lang/markdown/packages.el index dfe2f4572..9b7e2f921 100644 --- a/modules/lang/markdown/packages.el +++ b/modules/lang/markdown/packages.el @@ -1,8 +1,8 @@ ;; -*- no-byte-compile: t; -*- ;;; lang/markdown/packages.el -(package! markdown-mode :pin "c927a114b1b23cf7538181d62fd14679cce7fa25") -(package! markdown-toc :pin "eda9650a1bf0015e52e9678bd92b0a8beb1d7d71") +(package! markdown-mode :pin "f47a2e9796dfdde6fae7920af23647fe027dc34e") +(package! markdown-toc :pin "a9f13eecd0c7d8be960055dbc2d6f5d3fe6f40ca") (package! edit-indirect :pin "935ded353b9ed3da67bc61abf245c21b58d88864") (when (featurep! +grip) @@ -11,4 +11,4 @@ (when (featurep! :editor evil +everywhere) (package! evil-markdown :recipe (:host github :repo "Somelauw/evil-markdown") - :pin "46cd81b37991c4325fc24015a610f832b0ff995d")) + :pin "685d7fbb81bc02fa32779d2a127b99a0c8c7436b")) From e08b0d600ef18d150a020e59573064f061d6c853 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 10 May 2020 23:47:44 +0000 Subject: [PATCH 009/103] lookup: Update docs --- modules/tools/lookup/README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tools/lookup/README.org b/modules/tools/lookup/README.org index b4ecf508e..6ccbf35be 100644 --- a/modules/tools/lookup/README.org +++ b/modules/tools/lookup/README.org @@ -82,7 +82,7 @@ export PATH="/usr/local/opt/sqlite/bin:$PATH" ** Arch Linux #+BEGIN_SRC sh sudo pacman -S sqlite ripgrep -sudo yay -S wordnet-cli +yay -S wordnet-cli #+END_SRC ** NixOS From 9662523fba6c29d91ca35d8f22106e3e4ae07c46 Mon Sep 17 00:00:00 2001 From: John Hamelink Date: Mon, 11 May 2020 02:19:26 +0100 Subject: [PATCH 010/103] UPDATE: "Contribute" link in toc of README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 755b648e6..bdac8ddf2 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ - [Install](#install) - [Roadmap](#roadmap) - [Getting help](#getting-help) -- [Contributing](#contributing) +- [Contribute](#contribute) # Introduction From 395c4e593b085e56164564c7298a989144415b7a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 May 2020 18:46:44 -0400 Subject: [PATCH 011/103] Bump :lang emacs-lisp Fanael/highlight-quoted@2410347 -> Fanael/highlight-quoted@2410347 jorgenschaefer/emacs-buttercup@a91f282 -> jorgenschaefer/emacs-buttercup@532d082 xuchunyang/elisp-demos@57dd4ae -> xuchunyang/elisp-demos@4cd55a3 We're also transitioning from abbreviated SHA1 hashes to full ones. See 45cdfb125 for why. --- modules/lang/emacs-lisp/packages.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/lang/emacs-lisp/packages.el b/modules/lang/emacs-lisp/packages.el index a72ea6124..f4b918316 100644 --- a/modules/lang/emacs-lisp/packages.el +++ b/modules/lang/emacs-lisp/packages.el @@ -3,15 +3,16 @@ (package! elisp-mode :built-in t) -(package! highlight-quoted :pin "2410347815") +;; Fontification plugins +(package! highlight-quoted :pin "24103478158cd19fbcfb4339a3f1fa1f054f1469") ;; Tools -(package! macrostep :pin "424e3734a1") -(package! overseer :pin "02d49f582e") -(package! elisp-def :pin "368b04da68") -(package! elisp-demos :pin "57dd4ae3e4") +(package! macrostep :pin "424e3734a1ee526a1bd7b5c3cd1d3ef19d184267") +(package! overseer :pin "02d49f582e80e36b4334c9187801c5ecfb027789") +(package! elisp-def :pin "368b04da68783601b52e3169312183381871cf9e") +(package! elisp-demos :pin "4cd55a30d5dbd8d36a0e6f87261c4fef17fc6db0") (when (featurep! :checkers syntax) - (package! flycheck-cask :pin "3457ae553c")) + (package! flycheck-cask :pin "3457ae553c4feaf8168008f063d78fdde8fb5f94")) ;; Libraries -(package! buttercup :pin "a91f282025") +(package! buttercup :pin "532d082a363add4f6d9838ca3f924a773ce12136") From 91d7747c0bf9f60156d2f72ec3e2f079a9c16555 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 00:17:16 -0400 Subject: [PATCH 012/103] Bump :lang ruby arthurnn/minitest-emacs@97d7d17 -> arthurnn/minitest-emacs@ddd152c asok/projectile-rails@0398d94 -> asok/projectile-rails@11980b2 We're also transitioning from abbreviated SHA1 hashes to full ones. See 45cdfb125 for why. --- modules/lang/ruby/packages.el | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/lang/ruby/packages.el b/modules/lang/ruby/packages.el index 22060e9b3..69dd672a3 100644 --- a/modules/lang/ruby/packages.el +++ b/modules/lang/ruby/packages.el @@ -3,34 +3,34 @@ ;; Major modes (package! ruby-mode :built-in t) -(package! yard-mode :pin "ba74a47463") +(package! yard-mode :pin "ba74a47463b0320ae152bd42a7dd7aeecd7b5748") ;; REPL -(package! inf-ruby :pin "41e5ed3a88") +(package! inf-ruby :pin "41e5ed3a886fca56990486f1987bb3bae0dbd54b") (when (featurep! :completion company) - (package! company-inf-ruby :pin "fe3e4863bc")) + (package! company-inf-ruby :pin "fe3e4863bc971fbb81edad447efad5795ead1b17")) ;; Programming environment -(package! rubocop :pin "03bf15558a") -(package! robe :pin "68503b32bb") +(package! rubocop :pin "03bf15558a6eb65e4f74000cab29412efd46660e") +(package! robe :pin "68503b32bb3a005787ecb7a7fdeb3bb4a2317e2b") ;; Project tools -(package! bundler :pin "43efb6be4e") -(package! rake :pin "9c204334b0") +(package! bundler :pin "43efb6be4ed118b06d787ce7fbcffd68a31732a7") +(package! rake :pin "9c204334b03b4e899fadae6e59c20cf105404128") ;; Environment management (when (featurep! +rbenv) - (package! rbenv :pin "2ea1a5bdc1")) + (package! rbenv :pin "2ea1a5bdc1266caef1dd77700f2c8f42429b03f1")) (when (featurep! +rvm) - (package! rvm :pin "134497bc46")) + (package! rvm :pin "134497bc460990c71ab8fa75431156e62c17da2d")) (when (featurep! +chruby) - (package! chruby :pin "42bc6d521f")) + (package! chruby :pin "42bc6d521f832eca8e2ba210f30d03ad5529788f")) ;; Testing frameworks -(package! rspec-mode :pin "9a2a9d2935") -(package! minitest :pin "97d7d1760b") +(package! rspec-mode :pin "9a2a9d2935ae17b8570485bdea7c347533b464f6") +(package! minitest :pin "ddd152c990a528ad09a696bfad23afa4330ea4d7") ;; Rails (when (featurep! +rails) - (package! projectile-rails :pin "0398d940a2") - (package! inflections :pin "e4f1372cf2")) + (package! projectile-rails :pin "11980b2bcb99208888856a9b8666ff329b6f0142") + (package! inflections :pin "e4f1372cf22e811faca52fc86bdd5d817498a4d8")) From 05e1c0d782c1db40a58e88d725bf115b68538509 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 02:58:31 -0400 Subject: [PATCH 013/103] Bump :lang org Kungsgeten/org-brain@ae7fe0f -> Kungsgeten/org-brain@ed99f7e emacs-straight/org-mode@b171ff0 -> emacs-straight/org-mode@20c1322 jethrokuan/company-org-roam@0913d86 -> jethrokuan/company-org-roam@3da3821 jethrokuan/org-roam@689f559 -> jethrokuan/org-roam@ad5fca5 --- modules/lang/org/packages.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/lang/org/packages.el b/modules/lang/org/packages.el index 62af344b5..55db471a0 100644 --- a/modules/lang/org/packages.el +++ b/modules/lang/org/packages.el @@ -27,7 +27,7 @@ :recipe (:host github :repo "emacs-straight/org-mode" :files ("*.el" "lisp/*.el" "contrib/lisp/*.el")) - :pin "b171ff02f6e69bcce0dec56ea23e11c75e558704") + :pin "20c13221942183290dc440ca6ba91597f243b9e7") ;; ...And prevent other packages from pulling org; org-plus-contrib satisfies ;; the dependency already: https://github.com/raxod502/straight.el/issues/352 (package! org :recipe (:local-repo nil)) @@ -51,7 +51,7 @@ (when (featurep! :tools magit) (package! orgit :pin "e147f055772cc934fe1f1d8619059badeb647c93")) (when (featurep! +brain) - (package! org-brain :pin "ae7fe0f628bd093526786ece6917f7a4310e5e4d")) + (package! org-brain :pin "ed99f7e38dd687800fb898f8934a0da0541ebcd9")) (when (featurep! +dragndrop) (package! org-download :pin "d248fcb8f2592a40507682e91eed9a31ead4e4a6")) (when (featurep! +gnuplot) @@ -74,9 +74,9 @@ (package! org-tree-slide :pin "7bf09a02bd2d8f1ccfcb5209bfb18fbe02d1f44e") (package! org-re-reveal :pin "61549f4c00284a30e34caa3d76001b233ea5d2ad")) (when (featurep! +roam) - (package! org-roam :pin "689f55908048eede3cb65aa30ab990be3ac93263") + (package! org-roam :pin "ad5fca5440e5c8a6b8078013684df43b3e43d773") (when (featurep! :completion company) - (package! company-org-roam :pin "0913d86f167164e18831206e611f44bb8e7297e3"))) + (package! company-org-roam :pin "3da3821d1736e0d05a042bd944b74ea1da4a021b"))) ;;; Babel (package! ob-async :pin "80a30b96a007d419ece12c976a81804ede340311") From 84dce5d4ea35c70db7dffda187b82423caaf3d87 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 May 2020 18:44:50 -0400 Subject: [PATCH 014/103] Persist current page number for PDFs --- modules/tools/pdf/config.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index b1c74e782..c4bf24860 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -25,6 +25,18 @@ (setq pdf-view-use-scaling t pdf-view-use-imagemagick nil) + ;; Persist current page for PDF files viewed in Emacs + (add-hook! 'pdf-view-change-page-hook + (defun +pdf-remember-page-number-h () + (when buffer-file-name + (doom-store-put buffer-file-name (pdf-view-current-page) nil "pdf-view-page")))) + (add-hook! 'pdf-view-mode-hook + (defun +pdf-restore-page-number-h () + (when-let (page (doom-store-get buffer-file-name "pdf-view-page")) + (or (and (< page 1) + (> page (pdf-cache-number-of-pages))) + (pdf-view-goto-page page))))) + ;; Add retina support for MacOS users (when IS-MAC (advice-add #'pdf-util-frame-scale-factor :around #'+pdf--util-frame-scale-factor-a) From 037345cfd9859f6dc493d60ec00602c667f9759e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 May 2020 18:45:40 -0400 Subject: [PATCH 015/103] lang/emacs-lisp: reformat autoloads --- modules/lang/emacs-lisp/autoload.el | 125 ++++++++++++++-------------- 1 file changed, 61 insertions(+), 64 deletions(-) diff --git a/modules/lang/emacs-lisp/autoload.el b/modules/lang/emacs-lisp/autoload.el index 080bfbd02..2191695c2 100644 --- a/modules/lang/emacs-lisp/autoload.el +++ b/modules/lang/emacs-lisp/autoload.el @@ -67,6 +67,9 @@ library/userland functions" (byte-compile #'+emacs-lisp-highlight-vars-and-faces))) +;; +;;; Handlers + (defun +emacs-lisp--module-at-point () (let ((origin (point))) (save-excursion @@ -126,11 +129,52 @@ if it's callable, `apropos' otherwise." (thing (helpful-symbol (intern thing))) ((call-interactively #'helpful-at-point)))) -;; FIXME -;; (defun +emacs-lisp-lookup-file (thing) -;; (when-let (module (+emacs-lisp--module-at-point thing)) -;; (doom/help-modules (car module) (cadr module) 'visit-dir) -;; t)) +;;;###autoload +(defun +emacs-lisp-indent-function (indent-point state) + "A replacement for `lisp-indent-function'. + +Indents plists more sensibly. Adapted from +https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned" + (let ((normal-indent (current-column)) + (orig-point (point)) + ;; TODO Refactor `target' usage (ew!) + target) + (goto-char (1+ (elt state 1))) + (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) + (cond ((and (elt state 2) + (or (not (looking-at-p "\\sw\\|\\s_")) + (eq (char-after) ?:))) + (unless (> (save-excursion (forward-line 1) (point)) + calculate-lisp-indent-last-sexp) + (goto-char calculate-lisp-indent-last-sexp) + (beginning-of-line) + (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)) + (backward-prefix-chars) + (current-column)) + ((and (save-excursion + (goto-char indent-point) + (skip-syntax-forward " ") + (not (eq (char-after) ?:))) + (save-excursion + (goto-char orig-point) + (and (eq (char-after) ?:) + (eq (char-before) ?\() + (setq target (current-column))))) + (save-excursion + (move-to-column target t) + target)) + ((let* ((function (buffer-substring (point) (progn (forward-sexp 1) (point)))) + (method (or (function-get (intern-soft function) 'lisp-indent-function) + (get (intern-soft function) 'lisp-indent-hook)))) + (cond ((or (eq method 'defun) + (and (null method) + (> (length function) 3) + (string-match-p "\\`def" function))) + (lisp-indent-defform state indent-point)) + ((integerp method) + (lisp-indent-specform method state indent-point normal-indent)) + (method + (funcall method indent-point state)))))))) ;; @@ -170,6 +214,18 @@ if it's callable, `apropos' otherwise." load-path))) (buttercup-run-discover))) +;;;###autoload +(defun +emacs-lisp/edebug-instrument-defun-on () + "Toggle on instrumentalisation for the function under `defun'." + (interactive) + (eval-defun 'edebugit)) + +;;;###autoload +(defun +emacs-lisp/edebug-instrument-defun-off () + "Toggle off instrumentalisation for the function under `defun'." + (interactive) + (eval-defun nil)) + ;; ;;; Hooks @@ -234,62 +290,3 @@ verbosity when editing a file in `doom-private-dir' or `doom-emacs-dir'." (when (and start finish) (put-text-property start finish 'display "..."))))) nil) - -;;;###autoload -(defun +emacs-lisp-indent-function (indent-point state) - "A replacement for `lisp-indent-function'. - -Indents plists more sensibly. Adapted from -https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned" - (let ((normal-indent (current-column)) - (orig-point (point)) - ;; TODO Refactor `target' usage (ew!) - target) - (goto-char (1+ (elt state 1))) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) - (cond ((and (elt state 2) - (or (not (looking-at-p "\\sw\\|\\s_")) - (eq (char-after) ?:))) - (unless (> (save-excursion (forward-line 1) (point)) - calculate-lisp-indent-last-sexp) - (goto-char calculate-lisp-indent-last-sexp) - (beginning-of-line) - (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)) - (backward-prefix-chars) - (current-column)) - ((and (save-excursion - (goto-char indent-point) - (skip-syntax-forward " ") - (not (eq (char-after) ?:))) - (save-excursion - (goto-char orig-point) - (and (eq (char-after) ?:) - (eq (char-before) ?\() - (setq target (current-column))))) - (save-excursion - (move-to-column target t) - target)) - ((let* ((function (buffer-substring (point) (progn (forward-sexp 1) (point)))) - (method (or (function-get (intern-soft function) 'lisp-indent-function) - (get (intern-soft function) 'lisp-indent-hook)))) - (cond ((or (eq method 'defun) - (and (null method) - (> (length function) 3) - (string-match-p "\\`def" function))) - (lisp-indent-defform state indent-point)) - ((integerp method) - (lisp-indent-specform method state indent-point normal-indent)) - (method - (funcall method indent-point state)))))))) - -;;;###autoload -(defun +emacs-lisp/edebug-instrument-defun-on () - "Toggle on instrumentalisation for the function under `defun'." - (interactive) - (eval-defun 'edebugit)) - -;;;###autoload -(defun +emacs-lisp/edebug-instrument-defun-off () - "Toggle off instrumentalisation for the function under `defun'." - (interactive) - (eval-defun nil)) From 6c01d1a5acda57ca4ca5a96db9e3a002d9d96bf6 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 00:16:17 -0400 Subject: [PATCH 016/103] Increase read-process-output-max for robe-mode It appears robe, like LSP, is very chatty, which can slow down Emacs. --- modules/lang/ruby/config.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/lang/ruby/config.el b/modules/lang/ruby/config.el index 125891497..ebd431c7f 100644 --- a/modules/lang/ruby/config.el +++ b/modules/lang/ruby/config.el @@ -50,6 +50,11 @@ (set-lookup-handlers! 'ruby-mode :definition #'robe-jump :documentation #'robe-doc) + (when (boundp 'read-process-output-max) + ;; Robe can over saturate IPC, making interacting with it slow/clobbering + ;; the GC, so increase the amount of data Emacs reads from it at a time. + (setq-hook! '(robe-mode-hook inf-ruby-mode-hook) + read-process-output-max (* 1024 1024))) (when (featurep! :editor evil) (add-hook 'robe-mode-hook #'evil-normalize-keymaps)) (map! :localleader From 31e4bfb2d4084ebcd2659472db9569b5cf8d84dd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 02:50:45 -0400 Subject: [PATCH 017/103] Don't unfold to 2nd level in org-mode by default This is too opinionated to be a default, and has thus been replaced with "unfold subtree around point when opening an org file", in case saveplace has restored the point to a folded region. --- modules/lang/org/autoload/org.el | 22 ++++++++-------------- modules/lang/org/config.el | 5 +---- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index e66d03a09..c6266d55d 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -434,20 +434,14 @@ with `org-cycle')." t)) ;;;###autoload -(defun +org-unfold-to-2nd-level-or-point-h () - "Alters '#+STARTUP overview' to only expand first-level headings. -Expands the first level, but no further. If a different startup option was -provided, do that instead." - (unless org-agenda-inhibit-startup - ;; TODO Implement a custom #+STARTUP option? - (when (eq org-startup-folded t) - (outline-hide-sublevels +org-initial-fold-level)) - ;; If point was left somewhere deeper, unfold to point on startup. - (when (outline-invisible-p) - (ignore-errors - (save-excursion - (outline-previous-visible-heading 1) - (org-show-subtree)))))) +(defun +org-make-last-point-visible-h () + "Unfold subtree around point if saveplace places it to a folded region." + (and (not org-agenda-inhibit-startup) + (outline-invisible-p) + (ignore-errors + (save-excursion + (outline-previous-visible-heading 1) + (org-show-subtree))))) ;;;###autoload (defun +org-remove-occur-highlights-h () diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 2079b5d01..f358a39c7 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -50,9 +50,6 @@ Is relative to `org-directory', unless it is absolute. Is used in Doom's default (defvar +org-capture-projects-file "projects.org" "Default, centralized target for org-capture templates.") -(defvar +org-initial-fold-level 2 - "The initial fold level of org files when no #+STARTUP options for it.") - (defvar +org-habit-graph-padding 2 "The padding added to the end of the consistency graph") @@ -991,7 +988,7 @@ compelling reason, so..." #'doom-disable-show-trailing-whitespace-h #'+org-enable-auto-reformat-tables-h #'+org-enable-auto-update-cookies-h - #'+org-unfold-to-2nd-level-or-point-h) + #'+org-make-last-point-visible-h) (add-hook! 'org-load-hook #'+org-init-org-directory-h From 23b5a6c1421bc4dd200d9b53c6ec3152733867b9 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 02:53:18 -0400 Subject: [PATCH 018/103] lang/org: refactor how module loads flag features --- modules/lang/org/config.el | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index f358a39c7..78121f800 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -968,15 +968,8 @@ compelling reason, so..." )) ;;; Custom org modules - (if (featurep! +brain) (load! "contrib/brain")) - (if (featurep! +dragndrop) (load! "contrib/dragndrop")) - (if (featurep! +ipython) (load! "contrib/ipython")) - (if (featurep! +journal) (load! "contrib/journal")) - (if (featurep! +jupyter) (load! "contrib/jupyter")) - (if (featurep! +pomodoro) (load! "contrib/pomodoro")) - (if (featurep! +present) (load! "contrib/present")) - (if (featurep! +roam) (load! "contrib/roam")) - (if (featurep! +noter) (load! "contrib/noter")) + (dolist (flag doom--current-flags) + (load! (concat "contrib/" (substring (symbol-name flag) 1)))) ;; Add our general hooks after the submodules, so that any hooks the ;; submodules add run after them, and can overwrite any defaults if necessary. From bae9f916364128a4522329294a9e8ac3ab2bf863 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 02:57:45 -0400 Subject: [PATCH 019/103] Speed up +default/{find-in,browse}-notes This removes the 2-3s wait when using these two commands when the user has defined `org-directory` early. --- modules/config/default/autoload/files.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/config/default/autoload/files.el b/modules/config/default/autoload/files.el index e49e8255f..c672b69cb 100644 --- a/modules/config/default/autoload/files.el +++ b/modules/config/default/autoload/files.el @@ -28,13 +28,15 @@ (defun +default/browse-notes () "Browse files from `org-directory'." (interactive) - (require 'org) + (unless (boundp 'org-directory) + (require 'org)) (doom-project-browse org-directory)) ;;;###autoload (defun +default/find-in-notes () "Find a file under `org-directory', recursively." (interactive) - (require 'org) + (unless (boundp 'org-directory) + (require 'org)) (doom-project-find-file org-directory)) ;;;###autoload From 129eebcf2afa8132c843e047cf86450d362f6c62 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 03:03:41 -0400 Subject: [PATCH 020/103] Only configure org-habit if in org-modules Rather than force org-habit even on folks that don't use it. --- modules/lang/org/config.el | 40 +++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 78121f800..8e37a6116 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -436,27 +436,6 @@ underlying, modified buffer. This fixes that." (variable . "revealjs-url=https://revealjs.com"))))) -(defun +org-init-habit-h () - "TODO" - (add-hook! 'org-agenda-mode-hook - (defun +org-habit-resize-graph-h () - "Right align and resize the consistency graphs based on -`+org-habit-graph-window-ratio'" - (require 'org-habit) - (let* ((total-days (float (+ org-habit-preceding-days org-habit-following-days))) - (preceding-days-ratio (/ org-habit-preceding-days total-days)) - (graph-width (floor (* (window-width) +org-habit-graph-window-ratio))) - (preceding-days (floor (* graph-width preceding-days-ratio))) - (following-days (- graph-width preceding-days)) - (graph-column (- (window-width) (+ preceding-days following-days))) - (graph-column-adjusted (if (> graph-column +org-habit-min-width) - (- graph-column +org-habit-graph-padding) - nil))) - (setq-local org-habit-preceding-days preceding-days) - (setq-local org-habit-following-days following-days) - (setq-local org-habit-graph-column graph-column-adjusted))))) - - (defun +org-init-hacks-h () "Getting org to behave." ;; Open file links in current window, rather than new ones @@ -994,7 +973,6 @@ compelling reason, so..." #'+org-init-capture-frame-h #'+org-init-custom-links-h #'+org-init-export-h - #'+org-init-habit-h #'+org-init-hacks-h #'+org-init-keybinds-h #'+org-init-popup-rules-h @@ -1030,6 +1008,24 @@ compelling reason, so..." (setq org-id-track-globally t org-id-locations-file-relative t) + (add-hook! 'org-agenda-mode-hook + (defun +org-habit-resize-graph-h () + "Right align and resize the consistency graphs based on +`+org-habit-graph-window-ratio'" + (when (featurep 'org-habit) + (let* ((total-days (float (+ org-habit-preceding-days org-habit-following-days))) + (preceding-days-ratio (/ org-habit-preceding-days total-days)) + (graph-width (floor (* (window-width) +org-habit-graph-window-ratio))) + (preceding-days (floor (* graph-width preceding-days-ratio))) + (following-days (- graph-width preceding-days)) + (graph-column (- (window-width) (+ preceding-days following-days))) + (graph-column-adjusted (if (> graph-column +org-habit-min-width) + (- graph-column +org-habit-graph-padding) + nil))) + (setq-local org-habit-preceding-days preceding-days) + (setq-local org-habit-following-days following-days) + (setq-local org-habit-graph-column graph-column-adjusted))))) + ;; HACK `org-id' doesn't check if `org-id-locations-file' exists or is ;; writeable before trying to read/write to it. (defadvice! +org--fail-gracefully-a (&rest _) From f9a677427e480be5b89ea5072ee1148ee1f6ba1f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 03:08:37 -0400 Subject: [PATCH 021/103] Replace save-after-refile advice with hook A hook is better than an advice, which could break with an update. Also, reformat org-mks advice. --- modules/lang/org/config.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 8e37a6116..be195e05f 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -319,11 +319,17 @@ I like: (after! org-capture (org-capture-put :kill-buffer t)) + ;; Fix #462: when refiling from org-capture, Emacs prompts to kill the + ;; underlying, modified buffer. This fixes that. + (add-hook 'org-after-refile-insert-hook #'save-buffer) + ;; HACK Doom doesn't support `customize'. Best not to advertise it as an ;; option in `org-capture's menu. (defadvice! +org--remove-customize-option-a (orig-fn table title &optional prompt specials) :around #'org-mks - (funcall orig-fn table title prompt (remove '("C" "Customize org-capture-templates") specials))) + (funcall orig-fn table title prompt + (remove '("C" "Customize org-capture-templates") + specials))) (defadvice! +org--capture-expand-variable-file-a (file) "If a variable is used for a file path in `org-capture-template', it is used @@ -334,13 +340,6 @@ relative to `org-directory', unless it is an absolute path." (expand-file-name (symbol-value file) org-directory) file)) - (defadvice! +org--prevent-save-prompts-when-refiling-a (&rest _) - "Fix #462: when refiling from org-capture, Emacs prompts to kill the -underlying, modified buffer. This fixes that." - :after #'org-refile - (when (bound-and-true-p org-capture-is-refiling) - (org-save-all-org-buffers))) - (add-hook! 'org-capture-mode-hook (defun +org-show-target-in-capture-header-h () (setq header-line-format From 7cf2109b1a0ca43f2a8567db1da0c426477c6cab Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 04:53:39 -0400 Subject: [PATCH 022/103] Don't error on missing org contrib feature --- modules/lang/org/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index be195e05f..88f43cf32 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -947,7 +947,7 @@ compelling reason, so..." ;;; Custom org modules (dolist (flag doom--current-flags) - (load! (concat "contrib/" (substring (symbol-name flag) 1)))) + (load! (concat "contrib/" (substring (symbol-name flag) 1)) nil t)) ;; Add our general hooks after the submodules, so that any hooks the ;; submodules add run after them, and can overwrite any defaults if necessary. From 1529dcaaf57fc8a7ba3681931bb03cfad222fac6 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 05:32:51 -0400 Subject: [PATCH 023/103] Fix #3007: wrong-type-arg stringp on eshell completion --- modules/term/eshell/config.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 217fa6ff4..595b17248 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -181,5 +181,5 @@ You should use `set-eshell-alias!' to change this.") ;; installed for bash completion to work. How frustrating. This way we ;; can at least get bash completion whether or not fish is present. (defadvice! +eshell--fallback-to-bash-a (&rest _) - :before-while #'fish-completion--list-completions-with-desc - (executable-find "fish"))) + :before-until #'fish-completion--list-completions-with-desc + (unless (executable-find "fish") ""))) From 13134726dca553460c5d836afaa19f58e5888578 Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Tue, 12 May 2020 00:43:16 +0900 Subject: [PATCH 024/103] tools/lookup: Support implementations lookup handlers --- modules/tools/lookup/autoload/lookup.el | 26 +++++++++++++++++++++---- modules/tools/lookup/config.el | 11 +++++++++++ modules/tools/lsp/config.el | 2 ++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/modules/tools/lookup/autoload/lookup.el b/modules/tools/lookup/autoload/lookup.el index a77ace491..25fa41305 100644 --- a/modules/tools/lookup/autoload/lookup.el +++ b/modules/tools/lookup/autoload/lookup.el @@ -15,6 +15,9 @@ properties: :definition FN Run when jumping to a symbol's definition. Used by `+lookup/definition'. +:implementations FN + Run when looking for implementations of a symbol in the current project. Used + by `+lookup/implementations'. :references FN Run when looking for usage references of a symbol in the current project. Used by `+lookup/references'. @@ -46,8 +49,8 @@ change the current buffer or window or return non-nil when it succeeds. If it doesn't change the current buffer, or it returns nil, the lookup module will fall back to the next handler in `+lookup-definition-functions', -`+lookup-references-functions', `+lookup-file-functions' or -`+lookup-documentation-functions'. +`+lookup-implementations-functions', `+lookup-references-functions', +`+lookup-file-functions' or `+lookup-documentation-functions'. Consecutive `set-lookup-handlers!' calls will overwrite previously defined handlers for MODES. If used on minor modes, they are stacked onto handlers @@ -57,7 +60,7 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g. (set-lookup-handlers! 'python-mode nil) -\(fn MODES &key DEFINITION REFERENCES DOCUMENTATION FILE XREF-BACKEND ASYNC)" +\(fn MODES &key DEFINITION IMPLEMENTATIONS REFERENCES DOCUMENTATION FILE XREF-BACKEND ASYNC)" (declare (indent defun)) (dolist (mode (doom-enlist modes)) (let ((hook (intern (format "%s-hook" mode))) @@ -69,15 +72,17 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g. (fset fn (lambda () - (cl-destructuring-bind (&key definition references documentation file xref-backend async) + (cl-destructuring-bind (&key definition implementations references documentation file xref-backend async) plist (cl-mapc #'+lookup--set-handler (list definition + implementations references documentation file xref-backend) (list '+lookup-definition-functions + '+lookup-implementations-functions '+lookup-references-functions '+lookup-documentation-functions '+lookup-file-functions @@ -133,6 +138,7 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g. (let* ((origin (point-marker)) (handlers (plist-get (list :definition '+lookup-definition-functions + :implementations '+lookup-implementations-functions :references '+lookup-references-functions :documentation '+lookup-documentation-functions :file '+lookup-file-functions) @@ -241,6 +247,18 @@ evil-mode is active." ((+lookup--jump-to :definition identifier nil arg)) ((error "Couldn't find the definition of %S" identifier)))) +;;;###autoload +(defun +lookup/implementations (identifier &optional arg) + "Jump to the implementations of IDENTIFIER (defaults to the symbol at point). + +Each function in `+lookup-implementations-functions' is tried until one changes +the point or current buffer." + (interactive (list (doom-thing-at-point-or-region) + current-prefix-arg)) + (cond ((null identifier) (user-error "Nothing under point")) + ((+lookup--jump-to :implementations identifier nil arg)) + ((error "Couldn't find the implementations of %S" identifier)))) + ;;;###autoload (defun +lookup/references (identifier &optional arg) "Show a list of usages of IDENTIFIER (defaults to the symbol at point) diff --git a/modules/tools/lookup/config.el b/modules/tools/lookup/config.el index 8f392cd76..ba631536f 100644 --- a/modules/tools/lookup/config.el +++ b/modules/tools/lookup/config.el @@ -3,6 +3,8 @@ ;; "What am I looking at?" This module helps you answer this question. ;; ;; + `+lookup/definition': a jump-to-definition that should 'just work' +;; + `+lookup/implementations': find a symbol's implementations in the current +;; project ;; + `+lookup/references': find a symbol's references in the current project ;; + `+lookup/file': open the file referenced at point ;; + `+lookup/online'; look up a symbol on online resources @@ -52,6 +54,15 @@ If the argument is interactive (satisfies `commandp'), it is called with argument: the identifier at point. See `set-lookup-handlers!' about adding to this list.") +(defvar +lookup-implementations-functions () + "Function for `+lookup/implementations' to try. Stops at the first function to +return non-nil or change the current window/point. + +If the argument is interactive (satisfies `commandp'), it is called with +`call-interactively' (with no arguments). Otherwise, it is called with one +argument: the identifier at point. See `set-lookup-handlers!' about adding to +this list.") + (defvar +lookup-references-functions '(+lookup-xref-references-backend-fn +lookup-project-search-backend-fn) diff --git a/modules/tools/lsp/config.el b/modules/tools/lsp/config.el index 51f18346e..e6d9373f1 100644 --- a/modules/tools/lsp/config.el +++ b/modules/tools/lsp/config.el @@ -54,6 +54,7 @@ working on that project after closing the last buffer.") (set-lookup-handlers! 'lsp-mode :async t :documentation #'lsp-describe-thing-at-point :definition #'lsp-find-definition + :implementations #'lsp-find-implementation :references #'lsp-find-references) ;; TODO Lazy load these. They don't need to be loaded all at once unless the @@ -189,6 +190,7 @@ auto-killed (which is a potentially expensive process)." (when (featurep! +peek) (set-lookup-handlers! 'lsp-ui-mode :async t :definition 'lsp-ui-peek-find-definitions + :implementations 'lsp-ui-peek-find-implementation :references 'lsp-ui-peek-find-references))) From d08f2dd8888b2c600795b0544c8db55ddd555f1e Mon Sep 17 00:00:00 2001 From: Seong Yong-ju Date: Tue, 12 May 2020 01:06:23 +0900 Subject: [PATCH 025/103] tools/lookup: Support type definition lookup handlers --- modules/tools/lookup/autoload/lookup.el | 27 +++++++++++++++++++++---- modules/tools/lookup/config.el | 9 +++++++++ modules/tools/lsp/config.el | 1 + 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/modules/tools/lookup/autoload/lookup.el b/modules/tools/lookup/autoload/lookup.el index 25fa41305..33d5818f8 100644 --- a/modules/tools/lookup/autoload/lookup.el +++ b/modules/tools/lookup/autoload/lookup.el @@ -18,6 +18,9 @@ properties: :implementations FN Run when looking for implementations of a symbol in the current project. Used by `+lookup/implementations'. +:type-definition FN + Run when jumping to a symbol's type definition. Used by + `+lookup/type-definition'. :references FN Run when looking for usage references of a symbol in the current project. Used by `+lookup/references'. @@ -49,8 +52,9 @@ change the current buffer or window or return non-nil when it succeeds. If it doesn't change the current buffer, or it returns nil, the lookup module will fall back to the next handler in `+lookup-definition-functions', -`+lookup-implementations-functions', `+lookup-references-functions', -`+lookup-file-functions' or `+lookup-documentation-functions'. +`+lookup-implementations-functions', `+lookup-type-definition-functions', +`+lookup-references-functions', `+lookup-file-functions' or +`+lookup-documentation-functions'. Consecutive `set-lookup-handlers!' calls will overwrite previously defined handlers for MODES. If used on minor modes, they are stacked onto handlers @@ -60,7 +64,7 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g. (set-lookup-handlers! 'python-mode nil) -\(fn MODES &key DEFINITION IMPLEMENTATIONS REFERENCES DOCUMENTATION FILE XREF-BACKEND ASYNC)" +\(fn MODES &key DEFINITION IMPLEMENTATIONS TYPE-DEFINITION REFERENCES DOCUMENTATION FILE XREF-BACKEND ASYNC)" (declare (indent defun)) (dolist (mode (doom-enlist modes)) (let ((hook (intern (format "%s-hook" mode))) @@ -72,17 +76,19 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g. (fset fn (lambda () - (cl-destructuring-bind (&key definition implementations references documentation file xref-backend async) + (cl-destructuring-bind (&key definition implementations type-definition references documentation file xref-backend async) plist (cl-mapc #'+lookup--set-handler (list definition implementations + type-definition references documentation file xref-backend) (list '+lookup-definition-functions '+lookup-implementations-functions + '+lookup-type-definition-functions '+lookup-references-functions '+lookup-documentation-functions '+lookup-file-functions @@ -139,6 +145,7 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g. (handlers (plist-get (list :definition '+lookup-definition-functions :implementations '+lookup-implementations-functions + :type-definition '+lookup-type-definition-functions :references '+lookup-references-functions :documentation '+lookup-documentation-functions :file '+lookup-file-functions) @@ -259,6 +266,18 @@ the point or current buffer." ((+lookup--jump-to :implementations identifier nil arg)) ((error "Couldn't find the implementations of %S" identifier)))) +;;;###autoload +(defun +lookup/type-definition (identifier &optional arg) + "Jump to the type definition of IDENTIFIER (defaults to the symbol at point). + +Each function in `+lookup-type-definition-functions' is tried until one changes +the point or current buffer." + (interactive (list (doom-thing-at-point-or-region) + current-prefix-arg)) + (cond ((null identifier) (user-error "Nothing under point")) + ((+lookup--jump-to :type-definition identifier nil arg)) + ((error "Couldn't find the definition of %S" identifier)))) + ;;;###autoload (defun +lookup/references (identifier &optional arg) "Show a list of usages of IDENTIFIER (defaults to the symbol at point) diff --git a/modules/tools/lookup/config.el b/modules/tools/lookup/config.el index ba631536f..22f944972 100644 --- a/modules/tools/lookup/config.el +++ b/modules/tools/lookup/config.el @@ -63,6 +63,15 @@ If the argument is interactive (satisfies `commandp'), it is called with argument: the identifier at point. See `set-lookup-handlers!' about adding to this list.") +(defvar +lookup-type-definition-functions () + "Functions for `+lookup/type-definition' to try. Stops at the first function to +return non-nil or change the current window/point. + +If the argument is interactive (satisfies `commandp'), it is called with +`call-interactively' (with no arguments). Otherwise, it is called with one +argument: the identifier at point. See `set-lookup-handlers!' about adding to +this list.") + (defvar +lookup-references-functions '(+lookup-xref-references-backend-fn +lookup-project-search-backend-fn) diff --git a/modules/tools/lsp/config.el b/modules/tools/lsp/config.el index e6d9373f1..3657b82ef 100644 --- a/modules/tools/lsp/config.el +++ b/modules/tools/lsp/config.el @@ -55,6 +55,7 @@ working on that project after closing the last buffer.") :documentation #'lsp-describe-thing-at-point :definition #'lsp-find-definition :implementations #'lsp-find-implementation + :type-definition #'lsp-find-type-definition :references #'lsp-find-references) ;; TODO Lazy load these. They don't need to be loaded all at once unless the From f586ae76631203b8ccc63e2d67d19f6bd965e358 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Mon, 11 May 2020 11:20:09 -0500 Subject: [PATCH 026/103] Add open email bindings --- modules/config/default/+emacs-bindings.el | 9 ++++++++- modules/config/default/+evil-bindings.el | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/config/default/+emacs-bindings.el b/modules/config/default/+emacs-bindings.el index ac6310c75..f85c6850b 100644 --- a/modules/config/default/+emacs-bindings.el +++ b/modules/config/default/+emacs-bindings.el @@ -202,7 +202,14 @@ :desc "Send to Launchbar" "l" #'+macos/send-to-launchbar :desc "Send project to Launchbar" "L" #'+macos/send-project-to-launchbar) (:when (featurep! :tools docker) - :desc "Docker" "D" #'docker)) + :desc "Docker" "D" #'docker) + (:when (featurep! :email mu4e) + :desc "mu4e" "m" #'=mu4e) + (:when (featurep! :email notmuch) + :desc "notmuch" "m" #'=notmuch) + (:when (featurep! :email wanderlust) + :desc "wanderlust" "m" #'=wanderlust)) + ;;; p --- project (:prefix ("p" . "project") diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 2cc5d3f40..5b7834829 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -549,7 +549,13 @@ :desc "Send to Launchbar" "l" #'+macos/send-to-launchbar :desc "Send project to Launchbar" "L" #'+macos/send-project-to-launchbar) (:when (featurep! :tools docker) - :desc "Docker" "D" #'docker)) + :desc "Docker" "D" #'docker) + (:when (featurep! :email mu4e) + :desc "mu4e" "m" #'=mu4e) + (:when (featurep! :email notmuch) + :desc "notmuch" "m" #'=notmuch) + (:when (featurep! :email wanderlust) + :desc "wanderlust" "m" #'=wanderlust)) ;;; p --- project (:prefix-map ("p" . "project") From f8eb30653417919898da730c4852f3f8ecb6d967 Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Mon, 11 May 2020 11:17:23 -0600 Subject: [PATCH 027/103] Update README to point to new elixir-ls org Now that the JakeBecker project has been [moved](https://github.com/JakeBecker/elixir-ls/commit/9d4c1485e951b7ebdc0ed5b4f521451c5c99ad68), update the README. --- modules/lang/elixir/README.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lang/elixir/README.org b/modules/lang/elixir/README.org index 1ae98cf91..b1a703e2f 100644 --- a/modules/lang/elixir/README.org +++ b/modules/lang/elixir/README.org @@ -16,10 +16,10 @@ * Description This module provides support for [[https://elixir-lang.org/][Elixir programming language]] via [[https://github.com/tonini/alchemist.el][alchemist.el]] -or [[https://github.com/JakeBecker/elixir-ls/][elixir-ls]]. +or [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]. ** Module flags -+ ~+lsp~ Enable LSP support. Requires [[https://github.com/JakeBecker/elixir-ls/][elixir-ls]]. ++ ~+lsp~ Enable LSP support. Requires [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]]. ** Plugins + [[https://github.com/elixir-editors/emacs-elixir][elixir-mode]] From 5e7d6849273079c39030c3a00f86c511ef70e0d6 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 15:31:16 -0400 Subject: [PATCH 028/103] Fix #3089: undo-fu-mode not enabled early enough --- modules/emacs/undo/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/emacs/undo/config.el b/modules/emacs/undo/config.el index 9a289f922..f66e89153 100644 --- a/modules/emacs/undo/config.el +++ b/modules/emacs/undo/config.el @@ -2,7 +2,7 @@ (use-package! undo-fu :unless (featurep! +tree) - :after-call doom-switch-buffer after-find-file + :after-call doom-switch-buffer-hook after-find-file :init (after! undo-tree (global-undo-tree-mode -1)) From 24164f48692f25edd2d607c5f7917d58318898ab Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 16:16:58 -0400 Subject: [PATCH 029/103] Disable use-package's :ensure t property by default Many packages recommend setting up their packages with something like: (use-package PACKAGE :ensure t ...) New users will frequently copy these into their config, then experience long startup times or a cryptic error about the package failing to install. This is because `:ensure t`, by default, uses package.el (Emacs' built-in package manager) to check for and install packages, but Doom doesn't use package.el, it uses straight.el. So we disable `:ensure`. On the other hand, if the user has loaded `package` by hand, then we should assume that they know what they're doing, and restore the old behavior. --- core/core-modules.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/core-modules.el b/core/core-modules.el index c866e1289..b50fdd33c 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -254,6 +254,17 @@ This value is cached. If REFRESH-P, then don't use the cached value." ;; Macros are already fontified, no need for this (font-lock-remove-keywords 'emacs-lisp-mode use-package-font-lock-keywords) + ;; A common mistake for new users is that they inadvertantly try to install + ;; their packages with package.el, by copying over old `use-package' + ;; declarations with an :ensure t property. Doom doesn't use package.el, so + ;; this will throw an error that will confuse beginners. + (setq use-package-ensure-function #'ignore) + ;; ...On the other hand, if the user has loaded `package', then we should + ;; assume they know what they're doing and restore the old behavior: + (add-transient-hook! 'package-initialize + (when (eq use-package-ensure-function #'ignore) + (setq use-package-ensure-function #'use-package-ensure-elpa))) + ;; We define :minor and :magic-minor from the `auto-minor-mode' package here ;; so we don't have to load `auto-minor-mode' so early. (dolist (keyword '(:minor :magic-minor)) From 63ab88105f7c64b9b3e59546906ec5fe5857303a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 16:22:15 -0400 Subject: [PATCH 030/103] Fix #3090: distinguish C-i from TAB --- core/core-keybinds.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/core-keybinds.el b/core/core-keybinds.el index 0e89a270c..634493c30 100644 --- a/core/core-keybinds.el +++ b/core/core-keybinds.el @@ -30,6 +30,14 @@ and Emacs states, and for non-evil users.") (setq mac-command-modifier 'super mac-option-modifier 'meta)) +;; HACK Emacs cannot distinguish C-i from TAB, which is disturbing. Instead, +;; let's at least make GUI Emacs aware of this distinction: +(define-key key-translation-map [?\C-i] + (λ! (if (and (not (cl-position 'tab (this-single-command-raw-keys))) + (not (cl-position 'kp-tab (this-single-command-raw-keys))) + (display-graphic-p)) + [C-i] [?\C-i]))) + ;; ;;; Universal, non-nuclear escape From 487b1927e207750580363b0a0ef963cd8d16238f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 17:11:36 -0400 Subject: [PATCH 031/103] Bump :lang go dominikh/go-mode.el@10d6ab4 -> dominikh/go-mode.el@734d523 We're also transitioning from abbreviated SHA1 hashes to full ones. See 45cdfb125 for why. --- modules/lang/go/packages.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/lang/go/packages.el b/modules/lang/go/packages.el index fe58f0329..2008ca56c 100644 --- a/modules/lang/go/packages.el +++ b/modules/lang/go/packages.el @@ -1,15 +1,15 @@ ;; -*- no-byte-compile: t; -*- ;;; lang/go/packages.el -(package! go-eldoc :pin "cbbd2ea1e9") -(package! go-guru :pin "10d6ab43d9") -(package! go-mode :pin "10d6ab43d9") -(package! gorepl-mode :pin "6a73bf352e") -(package! go-tag :pin "59b243f2fa") -(package! go-gen-test :pin "44c202ac97") +(package! go-eldoc :pin "cbbd2ea1e94a36004432a9ac61414cb5a95a39bd") +(package! go-guru :pin "734d5232455ffde088021ea5908849ac570e890f") +(package! go-mode :pin "734d5232455ffde088021ea5908849ac570e890f") +(package! gorepl-mode :pin "6a73bf352e8d893f89cad36c958c4db2b5e35e07") +(package! go-tag :pin "59b243f2fa079d9de9d56f6e2d94397e9560310a") +(package! go-gen-test :pin "44c202ac97e728e93a35cee028a0ea8dd6e4292c") (when (featurep! :completion company) - (package! company-go :pin "4acdcbdea7")) + (package! company-go :pin "4acdcbdea79de6b3dee1c637eca5cbea0fdbe37c")) (when (featurep! :checkers syntax) - (package! flycheck-golangci-lint :pin "8e446c6831")) + (package! flycheck-golangci-lint :pin "8e446c68311048f0b87febf8ef0379e29d358851")) From 24aabfc8e025f1c51e9b6f5907288b6a40d2d33d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 19:43:52 -0400 Subject: [PATCH 032/103] Fix #3098: wrong-number-of-args on some interactive closures It appears key-translation-map keybinds are passed an argument, but `lambda!` and `lambda!!` produce 0-arity closures. Closes #3099 --- core/core-lib.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 0dd055f72..85146ea4c 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -157,7 +157,7 @@ at the values with which this function was called." A factory for quickly producing interaction commands, particularly for keybinds or aliases." (declare (doc-string 1) (pure t) (side-effect-free t)) - `(lambda () (interactive) ,@body)) + `(lambda (&rest _) (interactive) ,@body)) (defalias 'lambda! 'λ!) (defun λ!! (command &optional arg) @@ -165,7 +165,7 @@ or aliases." A factory for quickly producing interactive, prefixed commands for keybinds or aliases." (declare (doc-string 1) (pure t) (side-effect-free t)) - (lambda () (interactive) + (lambda (&rest _) (interactive) (let ((current-prefix-arg arg)) (call-interactively command)))) (defalias 'lambda!! 'λ!!) From de27b2c041db991401677b82d3b1515027ca6c3f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 22:09:17 -0400 Subject: [PATCH 033/103] Preserve current directory when splitting eshell Fixes #3091 --- modules/term/eshell/autoload/eshell.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/term/eshell/autoload/eshell.el b/modules/term/eshell/autoload/eshell.el index 2468012e9..0a4604a0b 100644 --- a/modules/term/eshell/autoload/eshell.el +++ b/modules/term/eshell/autoload/eshell.el @@ -21,13 +21,15 @@ t)) (defun +eshell--bury-buffer (&optional dedicated-p) - (unless (switch-to-prev-buffer nil 'bury) - (switch-to-buffer (doom-fallback-buffer))) - (when (eq major-mode 'eshell-mode) - (switch-to-buffer (doom-fallback-buffer))) - (when +eshell-enable-new-shell-on-split - (when-let (win (get-buffer-window (+eshell/here))) - (set-window-dedicated-p win dedicated-p)))) + (let ((directory default-directory)) + (unless (switch-to-prev-buffer nil 'bury) + (switch-to-buffer (doom-fallback-buffer))) + (when (eq major-mode 'eshell-mode) + (switch-to-buffer (doom-fallback-buffer))) + (when +eshell-enable-new-shell-on-split + (let ((default-directory directory)) + (when-let (win (get-buffer-window (+eshell/here t))) + (set-window-dedicated-p win dedicated-p)))))) (defun +eshell--setup-window (window &optional flag) (when (window-live-p window) From 272d8867af02c57967abdfc3b1838c45f6a1913c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 11 May 2020 22:11:33 -0400 Subject: [PATCH 034/103] Rename file to store last pdf page Creating a new convention for Doom modules: values stored with the `doom-store` library should be kept in a file named after the package that uses it. --- modules/tools/pdf/config.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index c4bf24860..f18e86f31 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -29,10 +29,10 @@ (add-hook! 'pdf-view-change-page-hook (defun +pdf-remember-page-number-h () (when buffer-file-name - (doom-store-put buffer-file-name (pdf-view-current-page) nil "pdf-view-page")))) + (doom-store-put buffer-file-name (pdf-view-current-page) nil "pdf-view")))) (add-hook! 'pdf-view-mode-hook (defun +pdf-restore-page-number-h () - (when-let (page (doom-store-get buffer-file-name "pdf-view-page")) + (when-let (page (doom-store-get buffer-file-name "pdf-view")) (or (and (< page 1) (> page (pdf-cache-number-of-pages))) (pdf-view-goto-page page))))) From 066119849d69c7edbc3150cb6d6ee4d647009439 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 04:53:27 -0400 Subject: [PATCH 035/103] Speed up IPC for windows users --- core/core.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/core.el b/core/core.el index 1ce4c6967..68422c0fe 100644 --- a/core/core.el +++ b/core/core.el @@ -291,7 +291,9 @@ users).") ;; Performance on Windows is considerably worse than elsewhere, especially if ;; WSL is involved. We'll need everything we can get. (when IS-WINDOWS - (setq w32-get-true-file-attributes nil)) ; slightly faster IO + (setq w32-get-true-file-attributes nil ; slightly faster IO + w32-pipe-read-delay 0 ; faster ipc + w32-pipe-buffer-size (* 64 1024))) ; read more at a time (was 4K) ;; Remove command line options that aren't relevant to our current OS; means ;; slightly less to process at startup. From bc5bbb177065fa9ea6968c0f6200295b5660f976 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 05:15:55 -0400 Subject: [PATCH 036/103] Fix #3102: move org-habit init back into hook --- modules/lang/org/config.el | 39 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 88f43cf32..44482e8f5 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -435,6 +435,26 @@ relative to `org-directory', unless it is an absolute path." (variable . "revealjs-url=https://revealjs.com"))))) +(defun +org-init-habit-h () + (add-hook! 'org-agenda-mode-hook + (defun +org-habit-resize-graph-h () + "Right align and resize the consistency graphs based on +`+org-habit-graph-window-ratio'" + (when (featurep 'org-habit) + (let* ((total-days (float (+ org-habit-preceding-days org-habit-following-days))) + (preceding-days-ratio (/ org-habit-preceding-days total-days)) + (graph-width (floor (* (window-width) +org-habit-graph-window-ratio))) + (preceding-days (floor (* graph-width preceding-days-ratio))) + (following-days (- graph-width preceding-days)) + (graph-column (- (window-width) (+ preceding-days following-days))) + (graph-column-adjusted (if (> graph-column +org-habit-min-width) + (- graph-column +org-habit-graph-padding) + nil))) + (setq-local org-habit-preceding-days preceding-days) + (setq-local org-habit-following-days following-days) + (setq-local org-habit-graph-column graph-column-adjusted)))))) + + (defun +org-init-hacks-h () "Getting org to behave." ;; Open file links in current window, rather than new ones @@ -972,6 +992,7 @@ compelling reason, so..." #'+org-init-capture-frame-h #'+org-init-custom-links-h #'+org-init-export-h + #'+org-init-habit-h #'+org-init-hacks-h #'+org-init-keybinds-h #'+org-init-popup-rules-h @@ -1007,24 +1028,6 @@ compelling reason, so..." (setq org-id-track-globally t org-id-locations-file-relative t) - (add-hook! 'org-agenda-mode-hook - (defun +org-habit-resize-graph-h () - "Right align and resize the consistency graphs based on -`+org-habit-graph-window-ratio'" - (when (featurep 'org-habit) - (let* ((total-days (float (+ org-habit-preceding-days org-habit-following-days))) - (preceding-days-ratio (/ org-habit-preceding-days total-days)) - (graph-width (floor (* (window-width) +org-habit-graph-window-ratio))) - (preceding-days (floor (* graph-width preceding-days-ratio))) - (following-days (- graph-width preceding-days)) - (graph-column (- (window-width) (+ preceding-days following-days))) - (graph-column-adjusted (if (> graph-column +org-habit-min-width) - (- graph-column +org-habit-graph-padding) - nil))) - (setq-local org-habit-preceding-days preceding-days) - (setq-local org-habit-following-days following-days) - (setq-local org-habit-graph-column graph-column-adjusted))))) - ;; HACK `org-id' doesn't check if `org-id-locations-file' exists or is ;; writeable before trying to read/write to it. (defadvice! +org--fail-gracefully-a (&rest _) From f2d6230736ef78545c2fadf19d046254d04ebf1f Mon Sep 17 00:00:00 2001 From: Justin Smestad Date: Tue, 12 May 2020 13:41:13 -0600 Subject: [PATCH 037/103] Fix use-packages! typo in getting started --- docs/getting_started.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started.org b/docs/getting_started.org index 389f551ed..98b59e6e7 100644 --- a/docs/getting_started.org +++ b/docs/getting_started.org @@ -755,7 +755,7 @@ The ~package!~ macro possesses a ~:disable~ property: (package! rtags :disable t) #+END_SRC -Once a package is disabled, ~use-packages!~ and ~after!~ blocks for it will be +Once a package is disabled, ~use-package!~ and ~after!~ blocks for it will be ignored, and the package is removed the next time you run ~bin/doom sync~. Use this to disable Doom's packages that you don't want or need. From 82ddc863353294e5ce7f6ff21ec80238ed0cc534 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 19:38:56 -0400 Subject: [PATCH 038/103] Move RET & backspace fixes out of +smartparens feature Neither of these are tied to smartparens, and should be available to folks that have disabled +smartparens. --- modules/config/default/autoload/text.el | 24 ++++---- modules/config/default/config.el | 82 ++++++++++++------------- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/modules/config/default/autoload/text.el b/modules/config/default/autoload/text.el index 01141cc6e..6d28f224b 100644 --- a/modules/config/default/autoload/text.el +++ b/modules/config/default/autoload/text.el @@ -50,8 +50,8 @@ If `buffer-file-name' isn't set, uses `default-directory'." (abbreviate-file-name path) (file-name-nondirectory path))))) - -(defun doom--backward-delete-whitespace-to-column () +;;;###autoload +(defun doom/backward-delete-whitespace-to-column () "Delete back to the previous column of whitespace, or as much whitespace as possible, or just one char if that's not possible." (interactive) @@ -74,7 +74,7 @@ possible, or just one char if that's not possible." ;; point and bol. ((and (not indent-tabs-mode) (not (bolp)) - (not (sp-point-in-string)) + (not (doom-point-in-string-p)) (save-excursion (>= (- (skip-chars-backward " \t")) tab-width))) (let ((movement (% (current-column) tab-width))) (when (= movement 0) @@ -97,7 +97,7 @@ possible, or just one char if that's not possible." { | } => {|} -+ Otherwise, resort to `doom--backward-delete-whitespace-to-column'. ++ Otherwise, resort to `doom/backward-delete-whitespace-to-column'. + Resorts to `delete-char' if n > 1" (interactive "p\nP") (or (integerp n) @@ -120,12 +120,14 @@ possible, or just one char if that's not possible." (save-excursion (insert-char ?\s (- ocol (current-column)) nil)))) ;; - ((and (= n 1) (bound-and-true-p smartparens-mode)) - (cond ((and (memq (char-before) (list ?\ ?\t)) - (save-excursion - (and (/= (skip-chars-backward " \t" (line-beginning-position)) 0) - (bolp)))) - (doom--backward-delete-whitespace-to-column)) + ((= n 1) + (cond ((or (not (featurep! +smartparens)) + (not (bound-and-true-p smartparens-mode)) + (and (memq (char-before) (list ?\ ?\t)) + (save-excursion + (and (/= (skip-chars-backward " \t" (line-beginning-position)) 0) + (bolp))))) + (doom/backward-delete-whitespace-to-column)) ((let* ((pair (ignore-errors (sp-get-thing))) (op (plist-get pair :op)) (cl (plist-get pair :cl)) @@ -144,6 +146,6 @@ possible, or just one char if that's not possible." (sp-insert-pair op) t) ((run-hook-with-args-until-success 'doom-delete-backward-functions)) - ((doom--backward-delete-whitespace-to-column))))))) + ((doom/backward-delete-whitespace-to-column))))))) ;; Otherwise, do simple deletion. ((delete-char (- n) killflag)))) diff --git a/modules/config/default/config.el b/modules/config/default/config.el index bbfc1ade7..d941890ee 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -204,52 +204,52 @@ ;; This keybind allows * to skip over **. (map! :map markdown-mode-map - :ig "*" (λ! (if (looking-at-p "\\*\\* *$") - (forward-char 2) - (call-interactively 'self-insert-command))))) - - ;; Highjacks backspace to: - ;; a) balance spaces inside brackets/parentheses ( | ) -> (|) - ;; b) delete up to nearest column multiple of `tab-width' at a time - ;; c) close empty multiline brace blocks in one step: - ;; { - ;; | - ;; } - ;; becomes {|} - ;; d) refresh smartparens' :post-handlers, so SPC and RET expansions work - ;; even after a backspace. - ;; e) properly delete smartparen pairs when they are encountered, without - ;; the need for strict mode. - ;; f) do none of this when inside a string - (advice-add #'delete-backward-char :override #'+default--delete-backward-char-a)) - - ;; HACK Makes `newline-and-indent' continue comments (and more reliably). - ;; Consults `doom-point-in-comment-functions' to detect a commented - ;; region and uses that mode's `comment-line-break-function' to continue - ;; comments. If neither exists, it will fall back to the normal behavior - ;; of `newline-and-indent'. - ;; - ;; We use an advice here instead of a remapping because many modes define - ;; and remap to their own newline-and-indent commands, and tackling all - ;; those cases was judged to be more work than dealing with the edge - ;; cases on a case by case basis. - (defadvice! +default--newline-indent-and-continue-comments-a (&rest _) - "A replacement for `newline-and-indent'. - -Continues comments if executed from a commented line. Consults -`doom-point-in-comment-functions' to determine if in a comment." - :before-until #'newline-and-indent - (interactive "*") - (when (and +default-want-RET-continue-comments - (doom-point-in-comment-p) - (fboundp comment-line-break-function)) - (funcall comment-line-break-function nil) - t))) + :ig "*" (general-predicate-dispatch nil + (looking-at-p "\\*\\* *") + (λ! (forward-char 2))))))) ;; ;;; Keybinding fixes +;; Highjacks backspace to delete up to nearest column multiple of `tab-width' at +;; a time. If you have smartparens enabled, it will also: +;; a) balance spaces inside brackets/parentheses ( | ) -> (|) +;; b) close empty multiline brace blocks in one step: +;; { +;; | +;; } +;; becomes {|} +;; c) refresh smartparens' :post-handlers, so SPC and RET expansions work even +;; after a backspace. +;; d) properly delete smartparen pairs when they are encountered, without the +;; need for strict mode. +;; e) do none of this when inside a string +(advice-add #'delete-backward-char :override #'doom/backward-delete-whitespace-to-column) + +;; HACK Makes `newline-and-indent' continue comments (and more reliably). +;; Consults `doom-point-in-comment-functions' to detect a commented region +;; and uses that mode's `comment-line-break-function' to continue comments. +;; If neither exists, it will fall back to the normal behavior of +;; `newline-and-indent'. +;; +;; We use an advice here instead of a remapping because many modes define +;; and remap to their own newline-and-indent commands, and tackling all +;; those cases was judged to be more work than dealing with the edge cases +;; on a case by case basis. +(defadvice! +default--newline-indent-and-continue-comments-a (&rest _) + "A replacement for `newline-and-indent'. + +Continues comments if executed from a commented line. Consults +`doom-point-in-comment-functions' to determine if in a comment." + :before-until #'newline-and-indent + (interactive "*") + (when (and +default-want-RET-continue-comments + (doom-point-in-comment-p) + (fboundp comment-line-break-function)) + (funcall comment-line-break-function nil) + t)) + ;; This section is dedicated to "fixing" certain keys so that they behave ;; sensibly (and consistently with similar contexts). From 717d53c6665229a731c55b23f9786c86111b3474 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 19:59:14 -0400 Subject: [PATCH 039/103] Tweak GC settings, particularly for org & lsp These two modes are particularly expensive. This needs more testing. --- core/core.el | 12 ++++++------ modules/lang/org/config.el | 6 ++++++ modules/tools/lsp/config.el | 4 ++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/core.el b/core/core.el index 68422c0fe..bddab71ce 100644 --- a/core/core.el +++ b/core/core.el @@ -307,14 +307,14 @@ users).") ;; Adopt a sneaky garbage collection strategy of waiting until idle time to ;; collect; staving off the collector while the user is working. (when doom-interactive-mode - (setq gc-cons-percentage 0.6) + (setq gcmh-idle-delay 5 + gcmh-high-cons-threshold 16777216 ; 16mb + gcmh-verbose doom-debug-mode + gc-cons-percentage 0.6) (add-transient-hook! 'pre-command-hook (gcmh-mode +1)) (with-eval-after-load 'gcmh - (setq gcmh-idle-delay 10 - gcmh-high-cons-threshold 16777216 - gcmh-verbose doom-debug-mode ; 16mb - gc-cons-percentage 0.1) - (add-hook 'focus-out-hook #'gcmh-idle-garbage-collect))) + (setq gc-cons-percentage 0.1) + (add-hook 'focus-out-hook #'gcmh-idle-garbage-collect)) ;; HACK `tty-run-terminal-initialization' is *tremendously* slow for some ;; reason. Disabling it completely could have many side-effects, so we diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 44482e8f5..e685b74bb 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -462,6 +462,12 @@ relative to `org-directory', unless it is an absolute path." ;; Open directory links in dired (add-to-list 'org-file-apps '(directory . emacs)) + ;; HACK Org is known to use a lot of unicode symbols (and large org files tend + ;; to be especially memory hungry). Compounded with + ;; `inhibit-compacting-font-caches' being non-nil, org needs more memory + ;; to be performant. + (setq-hook! 'org-mode-hook gcmh-high-cons-threshold (* 2 gcmh-high-cons-threshold)) + ;; When you create a sparse tree and `org-indent-mode' is enabled, the ;; highlighting destroys the invisibility added by `org-indent-mode'. ;; Therefore, don't highlight when creating a sparse tree. diff --git a/modules/tools/lsp/config.el b/modules/tools/lsp/config.el index 51f18346e..d6a432146 100644 --- a/modules/tools/lsp/config.el +++ b/modules/tools/lsp/config.el @@ -91,6 +91,10 @@ This also logs the resolved project root, if found, so we know where we are." ;; development builds of Emacs 27 and above (or (not (boundp 'read-process-output-max)) (setq-local read-process-output-max (* 1024 1024))) + ;; REVIEW LSP causes a lot of allocations, with or without Emacs 27+'s + ;; native JSON library, so we up the GC threshold to stave off + ;; GC-induced slowdowns/freezes. + (setq-local gcmh-high-cons-threshold (* 2 gcmh-high-cons-threshold)) (prog1 (lsp-mode 1) (setq-local lsp-buffer-uri (lsp--buffer-uri)) ;; Announce what project root we're using, for diagnostic purposes From d7061c86630d82b34323a19d1bd00097c120d3dd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 20:07:11 -0400 Subject: [PATCH 040/103] Remap haskell-mode-jump-to-def-or-tag to +lookup/definition --- modules/lang/haskell/config.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/lang/haskell/config.el b/modules/lang/haskell/config.el index eab9a2adf..a65ce74fb 100644 --- a/modules/lang/haskell/config.el +++ b/modules/lang/haskell/config.el @@ -31,7 +31,9 @@ (map! :map haskell-mode-map :n "o" #'+haskell/evil-open-below - :n "O" #'+haskell/evil-open-above) + :n "O" #'+haskell/evil-open-above + (:when (featurep! :tools lookup) + [remap haskell-mode-jump-to-def-or-tag] #'+lookup/definition)) (map! :localleader :map haskell-mode-map From 2419990caadf707a89418892d22da3dbf3d5a32e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 20:19:41 -0400 Subject: [PATCH 041/103] s/doom-store-set/doom-store-put This was renamed in 4b28e9ce8 --- docs/api.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.org b/docs/api.org index 9c3f8e1c5..350249303 100644 --- a/docs/api.org +++ b/docs/api.org @@ -546,7 +546,7 @@ These are side-by-side comparisons, showing how to bind keys with and without (fullscreen . ,fullscreen)))))) (defun save-frame-dimensions () - (doom-store-set 'last-frame-size + (doom-store-put 'last-frame-size (list (frame-position) (frame-width) (frame-height) From 6d52baeb57c624db2d5724b9b4c83da1fd5c0b55 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 21:33:13 -0400 Subject: [PATCH 042/103] Fix end-of-file error Because I was a derp lord in 717d53c66, and always will be. --- core/core.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.el b/core/core.el index bddab71ce..f4d5aa9c6 100644 --- a/core/core.el +++ b/core/core.el @@ -314,7 +314,7 @@ users).") (add-transient-hook! 'pre-command-hook (gcmh-mode +1)) (with-eval-after-load 'gcmh (setq gc-cons-percentage 0.1) - (add-hook 'focus-out-hook #'gcmh-idle-garbage-collect)) + (add-hook 'focus-out-hook #'gcmh-idle-garbage-collect))) ;; HACK `tty-run-terminal-initialization' is *tremendously* slow for some ;; reason. Disabling it completely could have many side-effects, so we From cbd05afcc8810a7de0147f65fcf1ee3ed42fa909 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 21:39:00 -0400 Subject: [PATCH 043/103] Bump :emacs undo ideasman42/emacs-undo-fu-session@b808ef0 -> ideasman42/emacs-undo-fu-session@0400f15 ideasman42/emacs-undo-fu@0ce9ac3 -> ideasman42/emacs-undo-fu@2b1e532 --- modules/emacs/undo/packages.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/emacs/undo/packages.el b/modules/emacs/undo/packages.el index 8c21f4904..b40326f1e 100644 --- a/modules/emacs/undo/packages.el +++ b/modules/emacs/undo/packages.el @@ -3,5 +3,5 @@ (if (featurep! +tree) (package! undo-tree :pin "5b6df03781495d8a25695d846b0cce496d3d3058") - (package! undo-fu :pin "0ce9ac36144e80316fff50bfe1bc5dd7e5e7ded6") - (package! undo-fu-session :pin "b808ef0cdcdd2eef221c67eda567eed7fcb3d4af")) + (package! undo-fu :pin "2b1e53285a55ce50ca6fd60b050f2171e235d8f9") + (package! undo-fu-session :pin "0400f15f2a0cfcedb69c06c3ff62f3f8814b62fb")) From a63ee13f01480668233c3a2d39370ef957fb8f82 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 21:41:05 -0400 Subject: [PATCH 044/103] Bump :core Wilfred/helpful@c54e9dd -> Wilfred/helpful@c0662aa bbatsov/projectile@5cd261d -> bbatsov/projectile@768f057 domtronn/all-the-icons.el@0b74fc3 -> domtronn/all-the-icons.el@d6cb6d4 jscheid/dtrt-indent@9163cd9 -> jscheid/dtrt-indent@50c440c --- core/packages.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/packages.el b/core/packages.el index 4d6494314..986d1459a 100644 --- a/core/packages.el +++ b/core/packages.el @@ -6,7 +6,7 @@ (package! gcmh :pin "b1bde5089169a74f62033d027e06e98cbeedd43f") ;; core-ui.el -(package! all-the-icons :pin "0b74fc361817e885580c3f3408079f949f5830e1") +(package! all-the-icons :pin "d6cb6d4a779eaa3570d8e451fd4d38b2b4554860") (package! hide-mode-line :pin "88888825b5b27b300683e662fa3be88d954b1cea") (package! highlight-numbers :pin "8b4744c7f46c72b1d3d599d4fb75ef8183dee307") (package! rainbow-delimiters :pin "5125f4e47604ad36c3eb4706310fcafac729ca8c") @@ -14,8 +14,8 @@ ;; core-editor.el (package! better-jumper :pin "6d240032ca213ccb3347e25f26c29b6822bf03a7") -(package! dtrt-indent :pin "9163cd990fb1f43dafed3948c6e406c13a45a6be") -(package! helpful :pin "c54e9ddbd6a77858048c1a4c4b549de98af8f88e") +(package! dtrt-indent :pin "50c440c80e0d15303d8ab543bce4c56e9c2bf407") +(package! helpful :pin "c0662aa07266fe204f4e6d72ccaa6af089400556") (when IS-MAC (package! ns-auto-titlebar :pin "1efc30d38509647b417f05587fd7003457719256")) (package! pcre2el :pin "0b5b2a2c173aab3fd14aac6cf5e90ad3bf58fa7d") @@ -38,7 +38,7 @@ :pin "01b39044b9b65fa4ea7d3166f8b1ffab6f740362")) ;; core-projects.el -(package! projectile :pin "5cd261dd75f4d711c0016617621349e2a98b43aa") +(package! projectile :pin "768f0570cad57b6885c4472df803906d097cbc1a") ;; core-keybinds.el (package! general :pin "42e38034cd2305fa7432866323c923979d8f9b06") From a7c2cbab9042d0f19ff88efbdcf5a50e8a317035 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 22:40:07 -0400 Subject: [PATCH 045/103] Fix #3110: wrong-number-of-args on backspace Due to a regression in 82ddc8633. --- modules/config/default/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/config/default/config.el b/modules/config/default/config.el index d941890ee..bb6c3a70d 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -225,7 +225,7 @@ ;; d) properly delete smartparen pairs when they are encountered, without the ;; need for strict mode. ;; e) do none of this when inside a string -(advice-add #'delete-backward-char :override #'doom/backward-delete-whitespace-to-column) +(advice-add #'delete-backward-char :override #'+default--delete-backward-char-a) ;; HACK Makes `newline-and-indent' continue comments (and more reliably). ;; Consults `doom-point-in-comment-functions' to detect a commented region From bc0db09a285e21202b73dc0eddff444365181bab Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 12 May 2020 23:22:50 -0400 Subject: [PATCH 046/103] Fix #1703: dired not listing files over TRAMP --- modules/emacs/dired/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index 3da7048bd..6b619607b 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -40,7 +40,7 @@ This is because there's no guarantee the remote system has GNU ls, which is the only variant that supports --group-directories-first." (when (file-remote-p default-directory) - (setq-local dired-listing-switches (car args)))))) + (setq-local dired-actual-switches "-ahl"))))) ;; Don't complain about this command being disabled when we use it (put 'dired-find-alternate-file 'disabled nil) From a036513241e64a6df52a1d383b498cd46959a9be Mon Sep 17 00:00:00 2001 From: nobv <6e6f6275@gmail.com> Date: Wed, 13 May 2020 17:32:20 +0900 Subject: [PATCH 047/103] Added +lsp flag to lang/purescript --- modules/lang/purescript/config.el | 3 +++ modules/tools/lsp/README.org | 1 + 2 files changed, 4 insertions(+) diff --git a/modules/lang/purescript/config.el b/modules/lang/purescript/config.el index 02c83c4b0..96ebd48fb 100644 --- a/modules/lang/purescript/config.el +++ b/modules/lang/purescript/config.el @@ -1,6 +1,9 @@ ;;; lang/purescript/config.el -*- lexical-binding: t; -*- (after! purescript-mode + (when (featurep! +lsp) + (add-hook 'purescript-mode-local-vars-hook #'lsp!)) + (add-hook! 'purescript-mode-hook #'purescript-indentation-mode #'rainbow-delimiters-mode) diff --git a/modules/tools/lsp/README.org b/modules/tools/lsp/README.org index 6b2992bd0..91256111c 100644 --- a/modules/tools/lsp/README.org +++ b/modules/tools/lsp/README.org @@ -51,6 +51,7 @@ As of this writing, this is the state of LSP support in Doom Emacs: | [[../../lang/sh/README.org][:lang sh]] | sh-mode | bash-language-server | | [[../../lang/swift/README.org][:lang swift]] | swift-mode | sourcekit | | [[../../lang/web/README.org][:lang web]] | web-mode, css-mode, scss-mode, sass-mode, less-css-mode | vscode-css-languageserver-bin, vscode-html-languageserver-bin | +| [[../../lang/web/README.org][:lang purescript]] | purescript-mode | purescript-language-server | ** Module Flags + =+peek= Use =lsp-ui-peek= when looking up definitions and references with From caf45044e8a9f1a59d54f5f5ed20a14904ab4fee Mon Sep 17 00:00:00 2001 From: nobv <6e6f6275@gmail.com> Date: Wed, 13 May 2020 17:39:56 +0900 Subject: [PATCH 048/103] Fixed README --- modules/tools/lsp/README.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tools/lsp/README.org b/modules/tools/lsp/README.org index 91256111c..8144e8138 100644 --- a/modules/tools/lsp/README.org +++ b/modules/tools/lsp/README.org @@ -51,7 +51,7 @@ As of this writing, this is the state of LSP support in Doom Emacs: | [[../../lang/sh/README.org][:lang sh]] | sh-mode | bash-language-server | | [[../../lang/swift/README.org][:lang swift]] | swift-mode | sourcekit | | [[../../lang/web/README.org][:lang web]] | web-mode, css-mode, scss-mode, sass-mode, less-css-mode | vscode-css-languageserver-bin, vscode-html-languageserver-bin | -| [[../../lang/web/README.org][:lang purescript]] | purescript-mode | purescript-language-server | +| [[../../lang/purescript/README.org][:lang purescript]] | purescript-mode | purescript-language-server | ** Module Flags + =+peek= Use =lsp-ui-peek= when looking up definitions and references with From 5c493541a9bfbf7889236fd7d7fb565e41e6d4fa Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 13 May 2020 14:05:58 -0400 Subject: [PATCH 049/103] Fix #3089: load unfo-fu a little sooner --- modules/emacs/undo/config.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/emacs/undo/config.el b/modules/emacs/undo/config.el index f66e89153..5b86f9605 100644 --- a/modules/emacs/undo/config.el +++ b/modules/emacs/undo/config.el @@ -2,8 +2,9 @@ (use-package! undo-fu :unless (featurep! +tree) - :after-call doom-switch-buffer-hook after-find-file + :after-call pre-command-hook after-find-file :init + ;; `evil' activates undo-tree, so we must pre-emptively disable it. (after! undo-tree (global-undo-tree-mode -1)) :config From f83499c7a76ff822b3364784d89d63b91cd08fae Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 13 May 2020 14:41:57 -0400 Subject: [PATCH 050/103] Revert 63ab88105 With this fix we're forced to rebind all C-i keybinds plugins bind. This is too much of a maintenance nightmare. This "fix" doesn't really fix anything really, so users can reinstate it themselves, if they prefer it. Relevant to #3090 --- core/core-keybinds.el | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core/core-keybinds.el b/core/core-keybinds.el index 634493c30..0e89a270c 100644 --- a/core/core-keybinds.el +++ b/core/core-keybinds.el @@ -30,14 +30,6 @@ and Emacs states, and for non-evil users.") (setq mac-command-modifier 'super mac-option-modifier 'meta)) -;; HACK Emacs cannot distinguish C-i from TAB, which is disturbing. Instead, -;; let's at least make GUI Emacs aware of this distinction: -(define-key key-translation-map [?\C-i] - (λ! (if (and (not (cl-position 'tab (this-single-command-raw-keys))) - (not (cl-position 'kp-tab (this-single-command-raw-keys))) - (display-graphic-p)) - [C-i] [?\C-i]))) - ;; ;;; Universal, non-nuclear escape From abb9ab7674601c2e90ecf1ca29f575a1effe9a4c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 13 May 2020 15:23:19 -0400 Subject: [PATCH 051/103] Fix :mc/REGEXP not placing real cursor in correct position With ':mc/abc' we should get a b c a b [a]bc a [a]bc c [a]bc b c a b c Instead, we got a b c a b abc a [a]bc c [a]bc b c a b c And the real cursor would be somewhere else (on the same column it was left in when you were in visual mode). --- modules/editor/multiple-cursors/autoload/evil-mc.el | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/editor/multiple-cursors/autoload/evil-mc.el b/modules/editor/multiple-cursors/autoload/evil-mc.el index 886ca9c0d..cab055caa 100644 --- a/modules/editor/multiple-cursors/autoload/evil-mc.el +++ b/modules/editor/multiple-cursors/autoload/evil-mc.el @@ -56,6 +56,7 @@ PATTERN as literal. PATTERN is a delimited regexp (the same that :g or :s uses). FLAGS can be g and/or i; which mean the same thing they do in `evil-ex-substitute'." :evil-mc t + :keep-visual t (interactive "") (unless (and (stringp pattern) (not (string-empty-p pattern))) From 7bbb52f17cfdac7d5a5defa29852cb4fcca140e3 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 13 May 2020 16:06:25 -0400 Subject: [PATCH 052/103] No longer disable org-highlight-sparse-tree-matches The original issue it was meant to fix no longer occurs in recent versions of org. --- modules/lang/org/config.el | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index e685b74bb..388b165a7 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -468,11 +468,6 @@ relative to `org-directory', unless it is an absolute path." ;; to be performant. (setq-hook! 'org-mode-hook gcmh-high-cons-threshold (* 2 gcmh-high-cons-threshold)) - ;; When you create a sparse tree and `org-indent-mode' is enabled, the - ;; highlighting destroys the invisibility added by `org-indent-mode'. - ;; Therefore, don't highlight when creating a sparse tree. - (setq org-highlight-sparse-tree-matches nil) - (add-hook! 'org-follow-link-hook (defun +org-delayed-recenter-h () "`recenter', but after a tiny delay. Necessary to prevent certain race From a10c157d87ac5beb8c3224e4c8fc00e2bdbc7266 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 13 May 2020 19:29:10 -0400 Subject: [PATCH 053/103] Fix zr, zm, zR & zM vimmish folding in org-mode Fixes the following keybinds for evil users: z r open next level of headings buffer-wide z m close next level of headings buffer-wide z R open all folded headings z M close all folded headings [N] z R open all headings at level N and above [N] z M close all headings at level N and below --- modules/lang/org/autoload/org.el | 28 ++++++++++++++++++++-------- modules/lang/org/config.el | 3 ++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index c6266d55d..c984372cf 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -306,6 +306,20 @@ the prefix ARG changes this command's behavior." ;;;###autoload (defalias #'+org/close-fold #'outline-hide-subtree) +;;;###autoload +(defun +org/close-all-folds (&optional level) + "Close all folds in the buffer (or below LEVEL)." + (interactive "p") + (outline-hide-sublevels (or level 1))) + +;;;###autoload +(defun +org/open-all-folds (&optional level) + "Open all folds in the buffer (or up to LEVEL)." + (interactive "P") + (if (integerp level) + (outline-hide-sublevels level) + (outline-show-all))) + (defun +org--get-foldlevel () (let ((max 1)) (save-restriction @@ -321,22 +335,20 @@ the prefix ARG changes this command's behavior." max))) ;;;###autoload -(defun +org/show-next-fold-level () +(defun +org/show-next-fold-level (&optional count) "Decrease the fold-level of the visible area of the buffer. This unfolds another level of headings on each invocation." - (interactive) - (let* ((current-level (+org--get-foldlevel)) - (new-level (1+ current-level))) + (interactive "p") + (let ((new-level (+ (+org--get-foldlevel) (or count 1)))) (outline-hide-sublevels new-level) (message "Folded to level %s" new-level))) ;;;###autoload -(defun +org/hide-next-fold-level () +(defun +org/hide-next-fold-level (&optional count) "Increase the global fold-level of the visible area of the buffer. This folds another level of headings on each invocation." - (interactive) - (let* ((current-level (+org--get-foldlevel)) - (new-level (max 1 (1- current-level)))) + (interactive "p") + (let ((new-level (max 1 (- (+org--get-foldlevel) (or count 1))))) (outline-hide-sublevels new-level) (message "Folded to level %s" new-level))) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 388b165a7..79cb3177e 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -907,11 +907,12 @@ compelling reason, so..." :n "zc" #'+org/close-fold :n "zC" #'outline-hide-subtree :n "zm" #'+org/hide-next-fold-level + :n "zM" #'+org/close-all-folds :n "zn" #'org-tree-to-indirect-buffer :n "zo" #'+org/open-fold :n "zO" #'outline-show-subtree :n "zr" #'+org/show-next-fold-level - :n "zR" #'outline-show-all + :n "zR" #'+org/open-all-folds :n "zi" #'org-toggle-inline-images :map org-read-date-minibuffer-local-map From 06b3439627688e29470d573b24dba87e412026c3 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 13 May 2020 19:33:23 -0400 Subject: [PATCH 054/103] Load org on +default/{browse,find-in}-notes if org-directory isn't set --- modules/config/default/autoload/files.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/config/default/autoload/files.el b/modules/config/default/autoload/files.el index c672b69cb..35a224681 100644 --- a/modules/config/default/autoload/files.el +++ b/modules/config/default/autoload/files.el @@ -28,14 +28,14 @@ (defun +default/browse-notes () "Browse files from `org-directory'." (interactive) - (unless (boundp 'org-directory) + (unless (bound-and-true-p 'org-directory) (require 'org)) (doom-project-browse org-directory)) ;;;###autoload (defun +default/find-in-notes () "Find a file under `org-directory', recursively." (interactive) - (unless (boundp 'org-directory) + (unless (bound-and-true-p 'org-directory) (require 'org)) (doom-project-find-file org-directory)) From 558ea084115b6a5a07072ea9aa4d31f950094839 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 13 May 2020 22:48:42 -0400 Subject: [PATCH 055/103] Disable slow smartparens-org defaults in org-mode But keep its base defaults. Relevant to #452 --- modules/lang/org/config.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 79cb3177e..fcba6249e 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -766,6 +766,11 @@ compelling reason, so..." ) +(defun +org-init-smartparens-h () + ;; Disable the slow defaults + (provide 'smartparens-org)) + + ;; ;;; Packages @@ -999,7 +1004,8 @@ compelling reason, so..." #'+org-init-keybinds-h #'+org-init-popup-rules-h #'+org-init-protocol-h - #'+org-init-protocol-lazy-loader-h) + #'+org-init-protocol-lazy-loader-h + #'+org-init-smartparens-h) ;; (Re)activate eldoc-mode in org-mode a little later, because it disables ;; itself if started too soon (which is the case with `global-eldoc-mode'). From 92174200aa78adbb22896405fbece6b9faa8c8d3 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 00:07:26 -0400 Subject: [PATCH 056/103] Prevent pdf page being persisted too many times --- modules/tools/pdf/config.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index f18e86f31..b1a739685 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -26,16 +26,18 @@ pdf-view-use-imagemagick nil) ;; Persist current page for PDF files viewed in Emacs + (defvar +pdf--page-restored-p nil) (add-hook! 'pdf-view-change-page-hook (defun +pdf-remember-page-number-h () - (when buffer-file-name - (doom-store-put buffer-file-name (pdf-view-current-page) nil "pdf-view")))) + (when-let (page (and buffer-file-name (pdf-view-current-page))) + (doom-store-put buffer-file-name page nil "pdf-view")))) (add-hook! 'pdf-view-mode-hook (defun +pdf-restore-page-number-h () - (when-let (page (doom-store-get buffer-file-name "pdf-view")) - (or (and (< page 1) - (> page (pdf-cache-number-of-pages))) - (pdf-view-goto-page page))))) + (when-let (page (and buffer-file-name (doom-store-get buffer-file-name "pdf-view"))) + (and (not +pdf--page-restored-p) + (<= page (or (pdf-cache-number-of-pages) 1)) + (pdf-view-goto-page page) + (setq-local +pdf--page-restored-p t))))) ;; Add retina support for MacOS users (when IS-MAC From b1d9e39a8aae226fa68260373cb0dc0ee4ed9c64 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 00:08:40 -0400 Subject: [PATCH 057/103] Bump :tools debugger lsp pdf emacs-lsp/dap-mode@cc2eb2f -> emacs-lsp/dap-mode@8f69dc2 emacs-lsp/lsp-mode@11750e7 -> emacs-lsp/lsp-mode@bac42c5 emacs-lsp/lsp-ui@1288be9 -> emacs-lsp/lsp-ui@ab55e30 politza/pdf-tools@d971298 -> politza/pdf-tools@c510442 realgud/realgud@e03446f -> realgud/realgud@1238d8e --- modules/tools/debugger/packages.el | 4 ++-- modules/tools/lsp/packages.el | 4 ++-- modules/tools/pdf/packages.el | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/tools/debugger/packages.el b/modules/tools/debugger/packages.el index 9c0c5e9f7..40d021f1f 100644 --- a/modules/tools/debugger/packages.el +++ b/modules/tools/debugger/packages.el @@ -1,10 +1,10 @@ ;; -*- no-byte-compile: t; -*- ;;; tools/debugger/packages.el -(when (package! realgud :pin "e03446f54c7ee0b4ed3ec7300597046cf1de2bb8") +(when (package! realgud :pin "1238d8e72945a84bb06cd39d7ded75f37105d4d2") (when (featurep! :lang javascript) (package! realgud-trepan-ni :pin "6e9cac5e8097018aadf41c88de541168036cc227"))) (when (featurep! +lsp) - (package! dap-mode :pin "cc2eb2fc1b2958ef01dad8c004d2f3bc4dc38bc3") + (package! dap-mode :pin "8f69dc2e3c850571758744d271061549c19e11fc") (package! posframe :pin "093b29a53cbeda6d637ccc9ef4dfc47123e79b9e")) diff --git a/modules/tools/lsp/packages.el b/modules/tools/lsp/packages.el index c9c9e43cd..80abb7217 100644 --- a/modules/tools/lsp/packages.el +++ b/modules/tools/lsp/packages.el @@ -1,8 +1,8 @@ ;; -*- no-byte-compile: t; -*- ;;; tools/lsp/packages.el -(package! lsp-mode :pin "11750e7b118858b38417a538c1c6eff8759c12f3") -(package! lsp-ui :pin "1288be94b4c37f89e80a03b1cff1b81aba9560bb") +(package! lsp-mode :pin "bac42c50b370f3716f258506dc1ae9f62906313f") +(package! lsp-ui :pin "ab55e306af9dd9eb62fe7463e4e05d948ad3dfc6") (when (featurep! :completion ivy) (package! lsp-ivy :pin "81e81ced99829358674c5a6bbe2c3e15cecd4ed8")) (when (featurep! :completion helm) diff --git a/modules/tools/pdf/packages.el b/modules/tools/pdf/packages.el index 046c2ea84..b2ea21233 100644 --- a/modules/tools/pdf/packages.el +++ b/modules/tools/pdf/packages.el @@ -1,4 +1,4 @@ ;; -*- no-byte-compile: t; -*- ;;; tools/pdf/packages.el -(package! pdf-tools :pin "d9712989fc4715443f674459199bdffa987054ac") +(package! pdf-tools :pin "c510442ab89c8a9e9881230eeb364f4663f59e76") From 694be5cbd8ada97d57731c31d5f92a760ec29047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ot=C3=A1vio=20Schwanck?= Date: Thu, 14 May 2020 01:59:24 -0300 Subject: [PATCH 058/103] bring back projectile-rails functionality --- modules/lang/ruby/config.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/lang/ruby/config.el b/modules/lang/ruby/config.el index 125891497..5135ac51d 100644 --- a/modules/lang/ruby/config.el +++ b/modules/lang/ruby/config.el @@ -91,7 +91,7 @@ (setq rake-cache-file (concat doom-cache-dir "rake.cache")) (map! :after ruby-mode :localleader - :map ruby-mode-map + :map ruby-mode-map :prefix "k" "k" #'rake "r" #'rake-rerun @@ -175,7 +175,9 @@ :when (featurep! +rails) :hook ((ruby-mode inf-ruby-mode projectile-rails-server-mode) . projectile-rails-mode) :hook (projectile-rails-server-mode . doom-mark-buffer-as-real-h) + :hook (projectile-rails-mode . auto-insert-mode) :init + (setq auto-insert-query nil) (setq inf-ruby-console-environment "development") (when (featurep! :lang web) (add-hook 'web-mode-hook #'projectile-rails-mode)) From a2393261658a2fc7ed9f4d4072d8fb409f6bb457 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 01:00:12 -0400 Subject: [PATCH 059/103] Activate save-place-mode when it loads --- core/core-editor.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/core-editor.el b/core/core-editor.el index d4638d5c6..6b76ffa5b 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -293,7 +293,9 @@ possible." `pp' can be expensive for longer lists, and there's no reason to prettify cache files, so we replace calls to `pp' with the much faster `prin1'." :around #'save-place-alist-to-file - (letf! ((#'pp #'prin1)) (funcall orig-fn)))) + (letf! ((#'pp #'prin1)) (funcall orig-fn))) + + (save-place-mode +1)) (use-package! server From 797660860318173fd687426d31e190e563ebb345 Mon Sep 17 00:00:00 2001 From: nobv <6e6f6275@gmail.com> Date: Thu, 14 May 2020 14:18:22 +0900 Subject: [PATCH 060/103] Updated :lang purescriipt flag in docs/modules.org --- docs/modules.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules.org b/docs/modules.org index 3957d7e30..ecb451857 100644 --- a/docs/modules.org +++ b/docs/modules.org @@ -128,7 +128,7 @@ Modules that bring support for a language or group of languages to Emacs. + [[file:../modules/lang/perl/README.org][perl]] - TODO + [[file:../modules/lang/php/README.org][php]] =+lsp= - TODO + plantuml - TODO -+ purescript - TODO ++ purescript =+lsp= - TODO + [[file:../modules/lang/python/README.org][python]] =+lsp +pyenv +conda +poetry= - TODO + qt - TODO + racket - TODO From f2c9e40d44cedd1efbb83dc02e83970f584e5d85 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 01:53:41 -0400 Subject: [PATCH 061/103] Load python on REPL commands To fix 'void-variable python-shell-interpreter' and similar errors. --- modules/lang/python/autoload/python.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lang/python/autoload/python.el b/modules/lang/python/autoload/python.el index 4f6ef7f3b..052db2a29 100644 --- a/modules/lang/python/autoload/python.el +++ b/modules/lang/python/autoload/python.el @@ -4,6 +4,7 @@ (defun +python/open-repl () "Open the Python REPL." (interactive) + (require 'python) (unless python-shell-interpreter (user-error "`python-shell-interpreter' isn't set")) (pop-to-buffer @@ -23,6 +24,7 @@ (defun +python/open-ipython-repl () "Open an IPython REPL." (interactive) + (require 'python) (let ((python-shell-interpreter (or (+python-executable-find "ipython") "ipython")) (python-shell-interpreter-args (string-join +python-ipython-repl-args " "))) (+python/open-repl))) @@ -31,6 +33,7 @@ (defun +python/open-jupyter-repl () "Open a Jupyter console." (interactive) + (require 'python) (add-to-list 'python-shell-completion-native-disabled-interpreters "jupyter") (let ((python-shell-interpreter (or (+python-executable-find "jupyter") "jupyter")) (python-shell-interpreter-args (format "console %s" (string-join +python-jupyter-repl-args " ")))) From 500e078e12a943aea7f230fb4ed36d8a7cc0d1de Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 02:07:25 -0400 Subject: [PATCH 062/103] Map windows key to super --- core/core-keybinds.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/core-keybinds.el b/core/core-keybinds.el index 0e89a270c..be5a93ce5 100644 --- a/core/core-keybinds.el +++ b/core/core-keybinds.el @@ -26,9 +26,12 @@ and Emacs states, and for non-evil users.") ;; ;;; Keybind settings -(when IS-MAC - (setq mac-command-modifier 'super - mac-option-modifier 'meta)) +(cond (IS-MAC + (setq mac-command-modifier 'super + mac-option-modifier 'meta)) + (IS-WINDOWS + (setq w32-lwindow-modifier 'super + w32-rwindow-modifier 'super))) ;; From 21fda9af600514f955b2271d2da55f4dd60aace9 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 02:54:56 -0400 Subject: [PATCH 063/103] Read & write envvar file as utf-8 #3044 --- core/cli/env.el | 1 + core/core-lib.el | 1 + 2 files changed, 2 insertions(+) diff --git a/core/cli/env.el b/core/cli/env.el index f13a838d3..0230ec9df 100644 --- a/core/cli/env.el +++ b/core/cli/env.el @@ -89,6 +89,7 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in doom-env-file))) (when (or force-p (not (file-exists-p env-file))) (with-temp-file env-file + (setq coding-system-for-write 'utf-8) (print! (start "%s envvars file at %S") (if (file-exists-p env-file) "Regenerating" diff --git a/core/core-lib.el b/core/core-lib.el index 85146ea4c..bf267c14e 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -118,6 +118,7 @@ unreadable. Returns the names of envvars that were changed." (env (with-temp-buffer (save-excursion + (setq coding-system-for-read 'utf-8) (insert "\0\n") ; to prevent off-by-one (insert-file-contents file)) (save-match-data From 8a70dd0379b8bf18663e5e9ecbb8a054ce07898f Mon Sep 17 00:00:00 2001 From: chuxubank Date: Tue, 12 May 2020 15:32:37 +0800 Subject: [PATCH 064/103] Change path separator on Windows when using fd Show slash instead of backslash --- core/core-projects.el | 5 +++-- modules/completion/ivy/config.el | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/core-projects.el b/core/core-projects.el index 04310ffe7..14ba77ac4 100644 --- a/core/core-projects.el +++ b/core/core-projects.el @@ -146,8 +146,9 @@ c) are not valid projectile projects." ;; .gitignore. This is recommended in the projectile docs. ((executable-find doom-projectile-fd-binary) (setq projectile-generic-command - (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow" - doom-projectile-fd-binary) + (concat (format "%s . -0 -H -E .git --color=never --type file --type symlink --follow" + doom-projectile-fd-binary) + (if IS-WINDOWS " --path-separator=/")) projectile-git-command projectile-generic-command projectile-git-submodule-command nil ;; ensure Windows users get fd's benefits diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index 2df48b827..f9dcab6c6 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -265,9 +265,9 @@ evil-ex-specific constructs, so we disable it solely in evil-ex." :override #'counsel--find-return-list (cl-destructuring-bind (find-program . args) (cond ((executable-find doom-projectile-fd-binary) - (cons doom-projectile-fd-binary - (list "--color=never" "-E" ".git" - "--type" "file" "--type" "symlink" "--follow"))) + (append (list doom-projectile-fd-binary + "--color=never" "-E" ".git" "--type" "file" "--type" "symlink" "--follow") + (if IS-WINDOWS '("--path-separator=/")))) ((executable-find "rg") (append (list "rg" "--files" "--follow" "--color=never" "--hidden" "--no-messages") (cl-loop for dir in projectile-globally-ignored-directories From a2011232a26661005b7f32efeb703d4b0f9f1adc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 04:13:05 -0400 Subject: [PATCH 065/103] Change envvar coding system buffer locally --- core/cli/env.el | 2 +- core/core-lib.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cli/env.el b/core/cli/env.el index 0230ec9df..d80414fed 100644 --- a/core/cli/env.el +++ b/core/cli/env.el @@ -89,7 +89,7 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in doom-env-file))) (when (or force-p (not (file-exists-p env-file))) (with-temp-file env-file - (setq coding-system-for-write 'utf-8) + (setq-local coding-system-for-write 'utf-8) (print! (start "%s envvars file at %S") (if (file-exists-p env-file) "Regenerating" diff --git a/core/core-lib.el b/core/core-lib.el index bf267c14e..5f5d311e2 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -118,7 +118,7 @@ unreadable. Returns the names of envvars that were changed." (env (with-temp-buffer (save-excursion - (setq coding-system-for-read 'utf-8) + (setq-local coding-system-for-read 'utf-8) (insert "\0\n") ; to prevent off-by-one (insert-file-contents file)) (save-match-data From 85fb59acca6fea5e6ee25dff86afbe202deb79f0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 15:16:34 -0400 Subject: [PATCH 066/103] Fix wrong-type-arg symbolp error from notes commands --- modules/config/default/autoload/files.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/config/default/autoload/files.el b/modules/config/default/autoload/files.el index 35a224681..73272354c 100644 --- a/modules/config/default/autoload/files.el +++ b/modules/config/default/autoload/files.el @@ -28,14 +28,14 @@ (defun +default/browse-notes () "Browse files from `org-directory'." (interactive) - (unless (bound-and-true-p 'org-directory) + (unless (bound-and-true-p org-directory) (require 'org)) (doom-project-browse org-directory)) ;;;###autoload (defun +default/find-in-notes () "Find a file under `org-directory', recursively." (interactive) - (unless (bound-and-true-p 'org-directory) + (unless (bound-and-true-p org-directory) (require 'org)) (doom-project-find-file org-directory)) From 043a561565a5184a6b11ea197f9f0781606d8823 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 15:41:45 -0400 Subject: [PATCH 067/103] Fix #3123: wrong-type-arg stringp error from org-encrypt-string Due to upstream issue (read comments). --- modules/lang/org/config.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index fcba6249e..7d34f4001 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -819,7 +819,19 @@ compelling reason, so..." (after! org (add-to-list 'org-tags-exclude-from-inheritance "crypt") (add-hook! 'org-mode-hook - (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) + (add-hook 'before-save-hook 'org-encrypt-entries nil t))) + :config + (after! epa + ;; HACK Fix #3123: `org-encrypt-string' expects `epa-file-encrypt-to' to be + ;; a string, but its docs say it can be a string or list of strings, + ;; and Doom sets it to a list of strings by default. Remove this when + ;; this is addressed upstream. + ;; TODO Report this upstream. + (unless org-crypt-key + (setq org-crypt-key + (if (listp epa-file-encrypt-to) + (car epa-file-encrypt-to) + epa-file-encrypt-to))))) (use-package! org-clock ; built-in From 0e851ace9ba48971f43af91b31af508381c38e13 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 15:00:23 -0400 Subject: [PATCH 068/103] Backport bits of CLI rewrite The rewrite for Doom's CLI is taking a while, so I've backported a few important changes in order to ease the transition and fix a couple bugs sooner. Fixes #2802, #2737, #2386 The big highlights are: - Fix #2802: We now update recipe repos *before* updating/installing any new packages. No more "Could not find package X in recipe repositories". - Fix #2737: An edge case where straight couldn't reach a pinned commit (particularly with agda). - Doom is now smarter about what option it recommends when straight prompts you to make a choice. - Introduces a new init path for Doom. The old way: - Launch in "minimal" CLI mode in non-interactive sessions - Launch a "full" interactive mode otherwise. The new way - Launch in "minimal" CLI mode *only* for bin/doom - Launch is a simple mode for non-interactive sessions that still need access to your interactive config (like async org export/babel). - Launch a "full" interactive mode otherwise. This should fix compatibility issues with plugins that use the async.el library or spawn child Emacs processes to fake parallelization (like org's async export and babel functionality). - Your private init.el is now loaded more reliably when running any bin/doom command. This gives you an opportunity to configure its settings. - Added doom-first-{input,buffer,file}-hook hooks, which we use to queue deferred activation of a number of packages. Users can remove these modes from these hooks; altogether preventing them from loading, rather than waiting for them to load to then disable them, e.g. (after! smartparens (smartparens-global-mode -1)) -> (remove-hook 'doom-first-buffer #'smartparens-global-mode) Hooks added to doom-first-*-hook variables will be removed once they run. This should also indirectly fix #2386, by preventing interactive modes from running in non-interactive session. - Added `doom/bump-*` commands to make bumping modules and packages easier, and `doom/bumpify-*` commands for converting package! statements into user/repo@sha1hash format for bump commits. - straight.el is now commit-pinned, like all other packages. We also more reliably install straight.el by cloning it ourselves, rather than relying on its bootstrap.el. This should prevent infinite "straight has diverged from master" prompts whenever we change branches (though, you might have to put up with it one more after this update -- see #2937 for workaround). All the other minor changes: - Moved core/autoload/cli.el to core/autoload/process.el - The package manager will log attempts to check out pinned commits - If package state is incomplete while rebuilding packages, emit a simpler error message instead of an obscure one! - Added -u switch to 'doom sync' to make it run 'doom update' afterwards - Added -p switch to 'doom sync' to make it run 'doom purge' afterwards - Replace doom-modules function with doom-modules-list - The `with-plist!` macro was removed, since `cl-destructuring-bind` already serves that purpose well enough. - core/autoload/packages.el was moved into core-packages.el - bin/doom will no longer die if DOOMDIR or DOOMLOCALDIR don't have a trailing slash - Introduces doom-debug-variables; a list of variables to toggle on doom/toggle-debug-mode. - The sandbox has been updated to reflect the above changes, also: 1. Child instances will no longer inherit the process environment of the host instance, 2. It will no longer produce an auto-save-list directory in ~/.emacs.d --- bin/doom | 114 +++---- core/autoload/config.el | 23 +- core/autoload/debug.el | 158 +++++---- core/autoload/help.el | 6 +- core/autoload/packages.el | 489 ++++++++++----------------- core/autoload/plist.el | 18 - core/autoload/{cli.el => process.el} | 9 +- core/autoload/sessions.el | 3 + core/cli/byte-compile.el | 272 ++++++++------- core/cli/debug.el | 5 +- core/cli/doctor.el | 1 - core/cli/env.el | 99 +++--- core/cli/install.el | 40 ++- core/cli/packages.el | 157 ++++++--- core/cli/upgrade.el | 23 +- core/core-cli.el | 255 +++++++------- core/core-editor.el | 54 ++- core/core-keybinds.el | 7 +- core/core-lib.el | 12 +- core/core-modules.el | 79 +++-- core/core-packages.el | 428 +++++++++++++++++------ core/core-projects.el | 1 - core/core-ui.el | 10 +- core/core.el | 142 ++++---- core/packages.el | 16 + init.el | 4 - modules/checkers/syntax/config.el | 6 +- modules/completion/helm/config.el | 4 +- modules/completion/ido/config.el | 8 +- modules/completion/ivy/config.el | 8 +- modules/lang/org/config.el | 14 +- 31 files changed, 1316 insertions(+), 1149 deletions(-) rename core/autoload/{cli.el => process.el} (88%) diff --git a/bin/doom b/bin/doom index 46a06bf8d..9da3f4c96 100755 --- a/bin/doom +++ b/bin/doom @@ -5,25 +5,25 @@ :; case "$VERSION" in *\ 2[0-5].[0-9]) echo "Detected Emacs $VERSION"; echo "Doom only supports Emacs 26.1 and newer"; echo; exit 2 ;; esac :; DOOMBASE="$(dirname "$0")/.." :; [ "$1" = -d ] || [ "$1" = --debug ] && { shift; export DEBUG=1; } -:; [ "$1" = run ] && { cd "$DOOMBASE"; shift; exec $EMACS -q --no-splash -l bin/doom "$@"; exit 0; } +:; [ "$1" = run ] && { cd "$DOOMBASE"; shift; exec $EMACS -q --no-splash -l init.el "$@"; exit 0; } :; exec $EMACS --no-site-file --script "$0" -- "$@" :; exit 0 -(let* ((load-prefer-newer t) - (loaddir (file-name-directory (file-truename load-file-name))) +(let* ((loaddir (file-name-directory (file-truename load-file-name))) (emacsdir (getenv "EMACSDIR")) (user-emacs-directory (abbreviate-file-name (or emacsdir (expand-file-name "../" loaddir))))) + ;; + (load (expand-file-name "core/core.el" user-emacs-directory) nil t) + ;; HACK Load `cl' and site files manually so we can stop them from polluting ;; CLI logs with deprecation and file load messages. - (let ((inhibit-message t)) - (when (> emacs-major-version 26) - (require 'cl)) - (load "site-start" t t)) + (quiet! (when (> emacs-major-version 26) + (require 'cl)) + (load "site-start" t t)) - (push (expand-file-name "core" user-emacs-directory) load-path) - (require 'core) + (doom-log "Initializing Doom CLI") (require 'core-cli) (defcli! :main @@ -45,10 +45,10 @@ with a different private module." (setq user-emacs-directory (file-name-as-directory emacsdir)) (print! (info "EMACSDIR=%s") localdir)) (when doomdir - (setenv "DOOMDIR" doomdir) + (setenv "DOOMDIR" (file-name-as-directory doomdir)) (print! (info "DOOMDIR=%s") localdir)) (when localdir - (setenv "DOOMLOCALDIR" localdir) + (setenv "DOOMLOCALDIR" (file-name-as-directory localdir)) (print! (info "DOOMLOCALDIR=%s") localdir)) (when debug-p (setenv "DEBUG" "1") @@ -75,54 +75,50 @@ with a different private module." (when (or emacsdir doomdir localdir) (load! "core/core.el" user-emacs-directory)) - (cond ((not noninteractive) - (print! "Doom launched out of %s (test mode)" (path user-emacs-directory)) - (load! "init.el" user-emacs-directory) - (doom-run-all-startup-hooks-h)) - - ((null command) - (doom-cli-execute "help")) - - ((condition-case e - (let ((start-time (current-time))) - (and (doom-cli-execute command args) - (print! (success "Finished! (%.4fs)") - (float-time - (time-subtract (current-time) - start-time))))) - (user-error - (print! (error "%s\n") (error-message-string e)) - (print! (yellow "See 'doom help %s' for documentation on this command.") (car args)) - (error "")) ; Ensure non-zero exit code - ((debug error) - (print! (error "There was an unexpected error:")) - (print-group! - (print! "%s %s" (bold "Type:") (car e)) - (print! (bold "Message:")) - (print-group! - (print! "%s" (get (car e) 'error-message))) - (print! (bold "Data:")) - (print-group! - (if (cdr e) - (dolist (item (cdr e)) - (print! "%S" item)) - (print! "n/a"))) - (when (featurep 'straight) - (when (string-match-p (regexp-quote straight-process-buffer) - (error-message-string e)) - (print! (bold "Straight output:")) - (print-group! (print! "%s" (straight--process-get-output)))))) - (unless debug-on-error - (terpri) - (print! - (concat "Run the command again with the -d (or --debug) switch to enable debug\n" - "mode and (hopefully) generate a backtrace from this error:\n" - "\n %s\n\n" - "If you file a bug report, please include it!") - (string-join (append (list (file-name-nondirectory load-file-name) "-d" command) - args) - " ")) - (error ""))))))) ; Ensure non-zero exit code + (let (print-level print-gensym print-length) + (condition-case e + (if (null command) + (doom-cli-execute "help") + (let ((start-time (current-time))) + (and (doom-cli-execute command args) + (print! (success "Finished! (%.4fs)") + (float-time + (time-subtract (current-time) + start-time)))))) + (user-error + (print! (error "%s\n") (error-message-string e)) + (print! (yellow "See 'doom help %s' for documentation on this command.") (car args)) + (error "")) ; Ensure non-zero exit code + ((debug error) + (print! (error "There was an unexpected error:")) + (print-group! + (print! "%s %s" (bold "Type:") (car e)) + (print! (bold "Message:")) + (print-group! + (print! "%s" (get (car e) 'error-message))) + (print! (bold "Data:")) + (print-group! + (if (cdr e) + (dolist (item (cdr e)) + (print! "%S" item)) + (print! "n/a"))) + (when (and (bound-and-true-p straight-process-buffer) + (string-match-p (regexp-quote straight-process-buffer) + (error-message-string e))) + (print! (bold "Straight output:")) + (print-group! (print! "%s" (straight--process-get-output))))) + (unless debug-on-error + (terpri) + (print! + (concat "Run the command again with the -d (or --debug) switch to enable debug\n" + "mode and (hopefully) generate a backtrace from this error:\n" + "\n %s\n\n" + "If you file a bug report, please include it!") + (string-join (append (list (file-name-nondirectory load-file-name) "-d" command) + args) + " ")) + ;; Ensure non-zero exit code + (error "")))))) (doom-cli-execute :main (cdr (member "--" argv))) (setq argv nil)) diff --git a/core/autoload/config.el b/core/autoload/config.el index cacd0d32d..02d78d725 100644 --- a/core/autoload/config.el +++ b/core/autoload/config.el @@ -55,14 +55,19 @@ And jumps to your `doom!' block." (defmacro doom--if-compile (command on-success &optional on-failure) (declare (indent 2)) - `(with-current-buffer (compile ,command) - (add-hook - 'compilation-finish-functions - (lambda (_buf status) - (if (equal status "finished\n") - ,on-success - ,on-failure)) - nil 'local))) + (let ((windowsym (make-symbol "doom-sync-window"))) + `(with-current-buffer (compile ,command t) + (let ((,windowsym (get-buffer-window (current-buffer)))) + (select-window ,windowsym) + (add-hook + 'compilation-finish-functions + (lambda (_buf status) + (if (equal status "finished\n") + (progn + (delete-window ,windowsym) + ,on-success) + ,on-failure)) + nil 'local))))) ;;;###autoload (defun doom/reload () @@ -89,7 +94,7 @@ Runs `doom-reload-hook' afterwards." (doom-initialize-modules 'force) (general-auto-unbind-keys t))) (run-hook-wrapped 'doom-reload-hook #'doom-try-run-hook) - (print! (success "Config successfully reloaded!"))) + (message "Config successfully reloaded!")) (user-error "Failed to reload your config"))) ;;;###autoload diff --git a/core/autoload/debug.el b/core/autoload/debug.el index c6d58e8f9..ed1683be7 100644 --- a/core/autoload/debug.el +++ b/core/autoload/debug.el @@ -1,5 +1,36 @@ ;;; core/autoload/debug.el -*- lexical-binding: t; -*- +;; +;;; Doom's debug mode + +;;;###autoload +(defvar doom-debug-variables + '(doom-debug-mode + init-file-debug + debug-on-error + garbage-collection-messages + use-package-verbose + jka-compr-verbose + lsp-log-io + gcmh-verbose + magit-refresh-verbose + url-debug) + "A list of variable to toggle on `doom/toggle-debug-mode'.") + +;;;###autoload +(defun doom/toggle-debug-mode (&optional arg) + "Toggle `debug-on-error' and `doom-debug-mode' for verbose logging." + (interactive (list (or current-prefix-arg 'toggle))) + (let ((value + (cond ((eq arg 'toggle) (not doom-debug-mode)) + ((> (prefix-numeric-value arg) 0))))) + (mapc (doom-rpartial #'set value) doom-debug-variables) + (message "Debug mode %s" (if value "on" "off")))) + + +;; +;;; Hooks + ;;;###autoload (defun doom-run-all-startup-hooks-h () "Run all startup Emacs hooks. Meant to be executed after starting Emacs with @@ -17,18 +48,12 @@ ;; ;;; Helpers -(defun doom-template-insert (template) - "TODO" - (let ((file (expand-file-name (format "templates/%s" template) doom-core-dir))) - (when (file-exists-p file) - (insert-file-contents file)))) - (defsubst doom--collect-forms-in (file form) (when (file-readable-p file) (let (forms) (with-temp-buffer (insert-file-contents file) - (delay-mode-hooks (emacs-lisp-mode)) + (let (emacs-lisp-mode) (emacs-lisp-mode)) (while (re-search-forward (format "(%s " (regexp-quote form)) nil t) (let ((ppss (syntax-ppss))) (unless (or (nth 4 ppss) @@ -45,7 +70,7 @@ ready to be pasted in a bug report on github." (require 'vc-git) (require 'core-packages) (let ((default-directory doom-emacs-dir) - (doom-modules (doom-modules))) + (doom-modules (doom-module-list))) (letf! (defun sh (&rest args) (cdr (apply #'doom-call-process args))) `((emacs (version . ,emacs-version) @@ -243,48 +268,62 @@ Some items are not supported by the `nsm.el' module." (file (make-temp-file "doom-sandbox-"))) (require 'package) (with-temp-file file - (insert - (prin1-to-string - (macroexp-progn - (append `((setq noninteractive nil - init-file-debug t - load-path ',load-path - package--init-file-ensured t - package-user-dir ,package-user-dir - package-archives ',package-archives - user-emacs-directory ,doom-emacs-dir) - (with-eval-after-load 'undo-tree - ;; undo-tree throws errors because `buffer-undo-tree' isn't - ;; corrrectly initialized - (setq-default buffer-undo-tree (make-undo-tree)))) - (pcase mode - (`vanilla-doom+ ; Doom core + modules - private config - `((load-file ,(expand-file-name "core.el" doom-core-dir)) - (doom-initialize) - (doom-initialize-core) - (add-hook 'window-setup-hook #'doom-display-benchmark-h) - (setq doom-modules ',doom-modules) - (maphash (lambda (key plist) - (let ((doom--current-module key) - (doom--current-flags (plist-get plist :flags))) - (load! "init" (doom-module-locate-path (car key) (cdr key)) t))) - doom-modules) - (maphash (lambda (key plist) - (let ((doom--current-module key) - (doom--current-flags (plist-get plist :flags))) - (load! "config" (doom-module-locate-path (car key) (cdr key)) t))) - doom-modules) - (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) - (doom-run-all-startup-hooks-h))) - (`vanilla-doom ; only Doom core - `((load-file ,(expand-file-name "core.el" doom-core-dir)) - (doom-initialize) - (doom-initialize-core) - (doom-run-all-startup-hooks-h))) - (`vanilla ; nothing loaded - `((package-initialize))))))) - "\n(unwind-protect (progn\n" contents "\n)\n" - (format "(delete-file %S))" file))) + (prin1 `(progn + (setq noninteractive nil + process-environment ',doom--initial-process-environment + exec-path ',doom--initial-exec-path + init-file-debug t + load-path ',load-path + package--init-file-ensured t + package-user-dir ,package-user-dir + package-archives ',package-archives + user-emacs-directory ,doom-emacs-dir) + (with-eval-after-load 'undo-tree + ;; undo-tree throws errors because `buffer-undo-tree' isn't + ;; correctly initialized + (setq-default buffer-undo-tree (make-undo-tree))) + (ignore-errors + (delete-directory ,(expand-file-name "auto-save-list" doom-emacs-dir) 'parents))) + (current-buffer)) + (prin1 `(unwind-protect + (defun --run-- () ,(read (concat "(progn\n" contents "\n)"))) + (delete-file ,file)) + (current-buffer)) + (prin1 (pcase mode + (`vanilla-doom+ ; Doom core + modules - private config + `(progn + (load-file ,(expand-file-name "core.el" doom-core-dir)) + (setq doom-modules-dirs (list doom-modules-dir)) + (let ((doom-init-modules-p t)) + (doom-initialize) + (doom-initialize-core-modules)) + (setq doom-modules ',doom-modules) + (--run--) + (maphash (lambda (key plist) + (let ((doom--current-module key) + (doom--current-flags (plist-get plist :flags))) + (load! "init" (doom-module-locate-path (car key) (cdr key)) t))) + doom-modules) + (maphash (lambda (key plist) + (let ((doom--current-module key) + (doom--current-flags (plist-get plist :flags))) + (load! "config" (doom-module-locate-path (car key) (cdr key)) t))) + doom-modules) + (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) + (doom-run-all-startup-hooks-h))) + (`vanilla-doom ; only Doom core + `(progn + (load-file ,(expand-file-name "core.el" doom-core-dir)) + (let ((doom-init-modules-p t)) + (doom-initialize) + (doom-initialize-core-modules)) + (--run--) + (doom-run-all-startup-hooks-h))) + (`vanilla ; nothing loaded + `(progn + (package-initialize) + (--run--)))) + (current-buffer))) (let ((args (if (eq mode 'doom) (list "-l" file) (list "-Q" "-l" file)))) @@ -343,7 +382,7 @@ to reproduce bugs and determine if Doom is to blame." (doom-sandbox-emacs-lisp-mode) (setq-local default-directory doom-emacs-dir) (unless (buffer-live-p exists) - (doom-template-insert "VANILLA_SANDBOX") + (insert-file-contents (doom-glob doom-core-dir "templates/VANILLA_SANDBOX")) (let ((contents (substitute-command-keys (buffer-string)))) (erase-buffer) (insert contents "\n"))) @@ -378,20 +417,3 @@ will be automatically appended to the result." (profiler-report) (profiler-stop)) (setq doom--profiler (not doom--profiler))) - -;;;###autoload -(defun doom/toggle-debug-mode (&optional arg) - "Toggle `debug-on-error' and `doom-debug-mode' for verbose logging." - (interactive (list (or current-prefix-arg 'toggle))) - (let ((value - (cond ((eq arg 'toggle) (not doom-debug-mode)) - ((> (prefix-numeric-value arg) 0))))) - (setq doom-debug-mode value - debug-on-error value - garbage-collection-messages value - use-package-verbose value - jka-compr-verbose value - lsp-log-io value - gcmh-verbose value - magit-refresh-verbose value) - (message "Debug mode %s" (if value "on" "off")))) diff --git a/core/autoload/help.el b/core/autoload/help.el index 060731b18..92f83f5d0 100644 --- a/core/autoload/help.el +++ b/core/autoload/help.el @@ -427,8 +427,8 @@ If prefix arg is present, refresh the cache." (let ((guess (or (function-called-at-point) (symbol-at-point)))) (require 'finder-inf nil t) - (require 'core-packages) - (doom-initialize-packages) + (require 'package) + (require 'straight) (let ((packages (delete-dups (append (mapcar #'car package-alist) (mapcar #'car package--builtins) @@ -503,7 +503,7 @@ If prefix arg is present, refresh the cache." (modules (if (gethash (symbol-name package) straight--build-cache) (doom-package-get package :modules) - (plist-get (cdr (assq package (doom-packages-list 'all))) + (plist-get (cdr (assq package (doom-package-list 'all))) :modules))) (package--print-help-section "Modules") (insert "Declared by the following Doom modules:\n") diff --git a/core/autoload/packages.el b/core/autoload/packages.el index 349f34805..7b677e129 100644 --- a/core/autoload/packages.el +++ b/core/autoload/packages.el @@ -1,276 +1,5 @@ ;;; core/autoload/packages.el -*- lexical-binding: t; -*- -;; -;;; Package metadata - -;;;###autoload -(defun doom-package-get (package &optional prop nil-value) - "Returns PACKAGE's `package!' recipe from `doom-packages'." - (let ((plist (cdr (assq package doom-packages)))) - (if prop - (if (plist-member plist prop) - (plist-get plist prop) - nil-value) - plist))) - -;;;###autoload -(defun doom-package-set (package prop value) - "Set PROPERTY in PACKAGE's recipe to VALUE." - (setf (alist-get package doom-packages) - (plist-put (alist-get package doom-packages) - prop value))) - -;;;###autoload -(defun doom-package-recipe (package &optional prop nil-value) - "Returns the `straight' recipe PACKAGE was registered with." - (let ((plist (gethash (symbol-name package) straight--recipe-cache))) - (if prop - (if (plist-member plist prop) - (plist-get plist prop) - nil-value) - plist))) - -;;;###autoload -(defun doom-package-recipe-repo (package) - "Resolve and return PACKAGE's (symbol) local-repo property." - (if-let* ((recipe (cdr (straight-recipes-retrieve package))) - (repo (straight-vc-local-repo-name recipe))) - repo - (symbol-name package))) - -;;;###autoload -(defun doom-package-build-recipe (package &optional prop nil-value) - "Returns the `straight' recipe PACKAGE was installed with." - (let ((plist (nth 2 (gethash (symbol-name package) straight--build-cache)))) - (if prop - (if (plist-member plist prop) - (plist-get plist prop) - nil-value) - plist))) - -;;;###autoload -(defun doom-package-build-time (package) - "TODO" - (car (gethash (symbol-name package) straight--build-cache))) - -;;;###autoload -(defun doom-package-dependencies (package &optional recursive _noerror) - "Return a list of dependencies for a package." - (let ((deps (nth 1 (gethash (symbol-name package) straight--build-cache)))) - (if recursive - (nconc deps (mapcan (lambda (dep) (doom-package-dependencies dep t t)) - deps)) - deps))) - -;;;###autoload -(defun doom-package-depending-on (package &optional noerror) - "Return a list of packages that depend on the package named NAME." - (cl-check-type name symbol) - ;; can't get dependencies for built-in packages - (unless (or (doom-package-build-recipe name) - noerror) - (error "Couldn't find %s, is it installed?" name)) - (cl-loop for pkg in (hash-table-keys straight--build-cache) - for deps = (doom-package-dependencies pkg) - if (memq package deps) - collect pkg - and append (doom-package-depending-on pkg t))) - - -;; -;;; Predicate functions - -;;;###autoload -(defun doom-package-built-in-p (package) - "Return non-nil if PACKAGE (a symbol) is built-in." - (eq (doom-package-build-recipe package :type) - 'built-in)) - -;;;###autoload -(defun doom-package-installed-p (package) - "Return non-nil if PACKAGE (a symbol) is installed." - (file-directory-p (straight--build-dir (symbol-name package)))) - -;;;###autoload -(defun doom-package-registered-p (package) - "Return non-nil if PACKAGE (a symbol) has been registered with `package!'. - -Excludes packages that have a non-nil :built-in property." - (when-let (plist (doom-package-get package)) - (not (plist-get plist :ignore)))) - -;;;###autoload -(defun doom-package-private-p (package) - "Return non-nil if PACKAGE was installed by the user's private config." - (assq :private (doom-package-get package :modules))) - -;;;###autoload -(defun doom-package-protected-p (package) - "Return non-nil if PACKAGE is protected. - -A protected package cannot be deleted and will be auto-installed if missing." - (memq package doom-core-packages)) - -;;;###autoload -(defun doom-package-core-p (package) - "Return non-nil if PACKAGE is a core Doom package." - (or (doom-package-protected-p package) - (assq :core (doom-package-get package :modules)))) - -;;;###autoload -(defun doom-package-backend (package) - "Return 'straight, 'builtin, 'elpa or 'other, depending on how PACKAGE is -installed." - (cond ((gethash (symbol-name package) straight--build-cache) - 'straight) - ((or (doom-package-built-in-p package) - (assq package package--builtins)) - 'builtin) - ((assq package package-alist) - 'elpa) - ((locate-library (symbol-name package)) - 'other))) - -;;;###autoload -(defun doom-package-different-recipe-p (name) - "Return t if a package named NAME (a symbol) has a different recipe than it -was installed with." - (cl-check-type name symbol) - ;; TODO - ;; (when (doom-package-installed-p name) - ;; (when-let* ((doom-recipe (assq name doom-packages)) - ;; (install-recipe (doom-package-recipe))) - ;; (not (equal (cdr quelpa-recipe) - ;; (cdr (plist-get (cdr doom-recipe) :recipe)))))) - ) - - -;; -;;; Package list getters - -(defun doom--read-module-packages-file (file &optional noeval noerror) - (with-temp-buffer ; prevent buffer-local settings from propagating - (condition-case e - (if (not noeval) - (load file noerror t t) - (when (file-readable-p file) - (insert-file-contents file) - (delay-mode-hooks (emacs-lisp-mode)) - (while (search-forward "(package! " nil t) - (save-excursion - (goto-char (match-beginning 0)) - (unless (let ((ppss (syntax-ppss))) - (or (nth 3 ppss) - (nth 4 ppss))) - (cl-destructuring-bind (name . plist) - (cdr (sexp-at-point)) - (push (cons - name (plist-put - plist :modules - (list (doom-module-from-path file)))) - doom-packages))))))) - ((debug error) - (signal 'doom-package-error - (list (doom-module-from-path file) - file - e)))))) - -;;;###autoload -(defun doom-package-list (&optional all-p) - "Retrieve a list of explicitly declared packages from enabled modules. - -This excludes core packages listed in `doom-core-packages'. - -If ALL-P, gather packages unconditionally across all modules, including disabled -ones." - (let ((doom-interactive-mode t) - (doom-modules (doom-modules)) - doom-packages) - (doom--read-module-packages-file - (doom-path doom-core-dir "packages.el") all-p t) - (let ((private-packages (doom-path doom-private-dir "packages.el"))) - (unless all-p - ;; We load the private packages file twice to ensure disabled packages - ;; are seen ASAP, and a second time to ensure privately overridden - ;; packages are properly overwritten. - (doom--read-module-packages-file private-packages nil t)) - (if all-p - (mapc #'doom--read-module-packages-file - (doom-files-in doom-modules-dir - :depth 2 - :match "/packages\\.el$")) - (cl-loop for key being the hash-keys of doom-modules - for path = (doom-module-path (car key) (cdr key) "packages.el") - for doom--current-module = key - do (doom--read-module-packages-file path nil t))) - (doom--read-module-packages-file private-packages all-p t)) - (nreverse doom-packages))) - -;;;###autoload -(defun doom-package-pinned-list () - "Return an alist mapping package names (strings) to pinned commits (strings)." - (let (alist) - (dolist (package doom-packages alist) - (cl-destructuring-bind (name &key disable ignore pin unpin &allow-other-keys) - package - (when (and (not ignore) - (not disable) - (or pin unpin)) - (setf (alist-get (doom-package-recipe-repo name) alist - nil 'remove #'equal) - (unless unpin pin))))))) - -;;;###autoload -(defun doom-package-unpinned-list () - "Return an alist mapping package names (strings) to pinned commits (strings)." - (let (alist) - (dolist (package doom-packages alist) - (cl-destructuring-bind - (_ &key recipe disable ignore pin unpin &allow-other-keys) - package - (when (and (not ignore) - (not disable) - (or unpin - (and (plist-member recipe :pin) - (null pin)))) - (cl-pushnew (doom-package-recipe-repo (car package)) alist - :test #'equal)))))) - -;;;###autoload -(defun doom-package-recipe-list () - "Return straight recipes for non-builtin packages with a local-repo." - (let (recipes) - (dolist (recipe (hash-table-values straight--recipe-cache)) - (cl-destructuring-bind (&key local-repo type no-build &allow-other-keys) - recipe - (unless (or (null local-repo) - (eq type 'built-in) - no-build) - (push recipe recipes)))) - (nreverse recipes))) - -;;;###autoload -(defmacro doom-with-package-recipes (recipes binds &rest body) - "TODO" - (declare (indent 2)) - (let ((recipe-var (make-symbol "recipe")) - (recipes-var (make-symbol "recipes"))) - `(let* ((,recipes-var ,recipes) - (built ()) - (straight-use-package-pre-build-functions - (cons (lambda (pkg) (cl-pushnew pkg built :test #'equal)) - straight-use-package-pre-build-functions))) - (dolist (,recipe-var ,recipes-var) - (cl-block nil - (straight--with-plist (append (list :recipe ,recipe-var) ,recipe-var) - ,(doom-enlist binds) - ,@body))) - (nreverse built)))) - - -;; -;;; Main functions - ;;;###autoload (defun doom/reload-packages () "Reload `doom-packages', `package' and `quelpa'." @@ -280,47 +9,185 @@ ones." (doom-initialize-packages t) (message "Reloading packages...DONE")) -;;;###autoload -(defun doom/update-pinned-package-form (&optional select) - "Inserts or updates a `:pin' for the `package!' statement at point. +;; +;;; Bump commands + +(defun doom--package-full-recipe (package plist) + (doom-plist-merge + (plist-get plist :recipe) + (or (cdr (straight-recipes-retrieve package)) + (plist-get (cdr (assq package doom-packages)) + :recipe)))) + +(defun doom--package-to-bump-string (package plist) + "Return a PACKAGE and its PLIST in 'username/repo@commit' format." + (format "%s@%s" + (plist-get (doom--package-full-recipe package plist) :repo) + (substring-no-properties (plist-get plist :pin) 0 7))) + +(defun doom--package-at-point (&optional point) + "Return the package and plist from the (package! PACKAGE PLIST...) at point." + (save-match-data + (save-excursion + (and point (goto-char point)) + (if (eq (sexp-at-point) 'package!) + (progn + (backward-sexp) + (backward-char) + t) + (while (and (search-backward "(package!" nil t) + (doom-point-in-string-or-comment-p)))) + (unless (or (doom-point-in-string-or-comment-p) + (not (eq (car-safe (sexp-at-point)) 'package!))) + (cl-destructuring-bind (beg . end) + (bounds-of-thing-at-point 'sexp) + (let ((package (let (doom-packages) + (eval (sexp-at-point) t)))) + (list :beg beg + :end end + :package (car package) + :plist (cdr package)))))))) + +;;;###autoload +(defun doom/bumpify-package-at-point () + "Convert `package!' call at point to a bump string." + (interactive) + (cl-destructuring-bind (&key package plist beg end) + (doom--package-at-point) + (when-let (str (doom--package-to-bump-string package plist)) + (goto-char beg) + (delete-region beg end) + (insert str)))) + +;;;###autoload +(defun doom/bumpify-packages-in-buffer () + "Convert all `package!' calls in buffer into bump strings." + (interactive) + (save-excursion + (goto-char (point-min)) + (while (search-forward "(package!" nil t) + (unless (doom-point-in-string-or-comment-p) + (doom/bumpify-package-at-point))))) + +;;;###autoload +(defun doom/bump-package-at-point (&optional select) + "Inserts or updates a `:pin' for the `package!' statement at point. +Grabs the latest commit id of the package using 'git'." + (interactive "P") + (doom-initialize-packages) + (cl-destructuring-bind (&key package plist beg end) + (or (doom--package-at-point) + (user-error "Not on a `package!' call")) + (let* ((recipe (doom--package-full-recipe package plist)) + (branch (or (plist-get recipe :branch) + straight-vc-git-default-branch)) + (oldid (or (plist-get plist :pin) + (doom-package-get package :pin))) + id url) + (when (or (eq (plist-get plist :built-in) t) + (and (eq (plist-get plist :built-in) 'prefer) + (locate-library (symbol-name package)))) + (user-error "%s: skipping built-in package" package)) + (setq url (straight-vc-git--destructure recipe (upstream-repo upstream-host) + (straight-vc-git--encode-url upstream-repo upstream-host)) + id (when url + (cdr (doom-call-process + "git" "ls-remote" url + (unless select + (or branch straight-vc-git-default-branch)))))) + (unless id + (user-error "%s: no id from %s" package url)) + (let* ((id (car (split-string + (if select + (completing-read "Commit: " (split-string id "\n" t)) + id))))) + (when (and oldid (equal oldid id)) + (user-error "%s: no update necessary" package)) + (save-excursion + (if (re-search-forward ":pin +\"\\([^\"]+\\)\"" end t) + (replace-match id t t nil 1) + (thing-at-point--end-of-sexp) + (backward-char) + (insert " :pin " (prin1-to-string id)))) + (message "Updated %S: %s -> %s" + package + (substring oldid 0 10) + (substring id 0 10)))))) + +;;;###autoload +(defun doom/bump-packages-in-buffer (&optional select) + "Inserts or updates a `:pin' for the `package!' statement at point. Grabs the latest commit id of the package using 'git'." (interactive "P") - ;; REVIEW Better error handling - ;; TODO Insert a new `package!' if no `package!' at poin - (require 'straight) - (ignore-errors - (while (and (atom (sexp-at-point)) - (not (bolp))) - (forward-sexp -1))) (save-excursion - (if (not (eq (sexp-at-point) 'package!)) - (user-error "Not on a `package!' call") - (backward-char) - (let* ((recipe (cdr (sexp-at-point))) - (package (car recipe)) - (oldid (doom-package-get package :pin)) - (id - (cdr (doom-call-process - "git" "ls-remote" - (straight-vc-git--destructure - (doom-plist-merge - (plist-get (cdr recipe) :recipe) - (or (cdr (straight-recipes-retrieve package)) - (plist-get (cdr (assq package doom-packages)) :recipe))) - (upstream-repo upstream-host) - (straight-vc-git--encode-url upstream-repo upstream-host)))))) - (unless id - (user-error "No id for %S package" package)) - (let* ((id (if select - (car (split-string (completing-read "Commit: " (split-string id "\n" t)))) - (car (split-string id)))) - (id (substring id 0 10))) - (if (and oldid (string-match-p (concat "^" oldid) id)) - (user-error "No update necessary") - (if (re-search-forward ":pin +\"\\([^\"]+\\)\"" (cdr (bounds-of-thing-at-point 'sexp)) t) - (replace-match id t t nil 1) - (thing-at-point--end-of-sexp) - (backward-char) - (insert " :pin " (prin1-to-string id))) - (message "Updated %S: %s -> %s" package oldid id))))))) + (goto-char (point-min)) + (doom-initialize-packages) + (let (packages) + (while (search-forward "(package! " nil t) + (unless (let ((ppss (syntax-ppss))) + (or (nth 4 ppss) + (nth 3 ppss) + (save-excursion + (and (goto-char (match-beginning 0)) + (not (plist-member (sexp-at-point) :pin)))))) + (condition-case e + (push (doom/bump-package-at-point) packages) + (user-error (message "%s" (error-message-string e)))))) + (if packages + (message "Updated %d packages\n- %s" (length packages) (string-join packages "\n- ")) + (message "No packages to update"))))) + +;;;###autoload +(defun doom/bump-module (category &optional module select) + "Bump packages in CATEGORY MODULE. +If SELECT (prefix arg) is non-nil, prompt you to choose a specific commit for +each package." + (interactive + (append + (mapcar #'intern + (split-string + (completing-read + "Bump module: " + (let ((modules (doom-module-list 'all))) + (mapcar (lambda (m) + (if (listp m) + (format "%s %s" (car m) (cdr m)) + (format "%s" m))) + (append (list ":private") + (delete-dups (mapcar #'car modules)) + modules))) + nil t nil nil) + " " t)) + (list current-prefix-arg))) + (if-let (packages-file (if (eq category :private) + (doom-glob doom-private-dir "packages.el") + (doom-module-locate-path category module "packages.el"))) + (with-current-buffer + (or (get-file-buffer packages-file) + (find-file-noselect packages-file)) + (doom/bump-packages-in-buffer select)) + (user-error "Module %s %s has no packages.el file"))) + +;;;###autoload +(defun doom/bump-package (package) + "Bump PACKAGE in all modules that install it." + (interactive + (list (completing-read "Bump package: " + (mapcar #'car (doom-package-list 'all))))) + + (let* ((packages (doom-package-list 'all)) + (modules (plist-get (alist-get package packages) :modules))) + (unless modules + (user-error "This package isn't installed by any Doom module")) + (dolist (module modules) + (when-let (packages-file (doom-module-locate-path (car module) (cdr module))) + (doom/bump-module (car module) (cdr module)))))) + + +;; +;;; Bump commits + +;;;###autoload +(defun doom/commit-bumps () + (interactive)) diff --git a/core/autoload/plist.el b/core/autoload/plist.el index 87f897598..fc291dee7 100644 --- a/core/autoload/plist.el +++ b/core/autoload/plist.el @@ -35,24 +35,6 @@ list, the pair is destructured into (CAR . CDR)." "Delete PROP from PLIST in-place." `(setq ,plist (doom-plist-delete ,plist ,prop))) -;;;###autoload -(defmacro with-plist! (plist props &rest body) - "With props bound from PLIST to PROPS, evaluate BODY. - -PROPS is a list of symbols. Each one is converted to a keyword and then its -value is looked up in the PLIST and bound to the symbol for the duration of -BODY." - (declare (indent 2)) - (let ((plist-sym (make-symbol "plist"))) - `(let* ((,plist-sym ,plist) - ,@(cl-loop for prop in props - collect - `(,prop - (plist-get - ,plist-sym - ,(doom-keyword-intern (symbol-name prop)))))) - ,@body))) - ;; ;;; Library diff --git a/core/autoload/cli.el b/core/autoload/process.el similarity index 88% rename from core/autoload/cli.el rename to core/autoload/process.el index f0582ef1c..66d5d6a8c 100644 --- a/core/autoload/cli.el +++ b/core/autoload/process.el @@ -1,7 +1,4 @@ -;;; core/autoload/cli.el -*- lexical-binding: t; -*- - -;; -;;; Library +;;; core/autoload/process.el -*- lexical-binding: t; -*- ;;;###autoload (defun doom-call-process (command &rest args) @@ -10,7 +7,7 @@ Returns (STATUS . OUTPUT) when it is done, where STATUS is the returned error code of the process and OUTPUT is its stdout output." (with-temp-buffer - (cons (or (apply #'call-process command nil t nil args) + (cons (or (apply #'call-process command nil t nil (remq nil args)) -1) (string-trim (buffer-string))))) @@ -28,7 +25,7 @@ Warning: freezes indefinitely on any stdin prompt." (cons (let ((process (make-process :name "doom-sh" :buffer (current-buffer) - :command (cons command args) + :command (cons command (remq nil args)) :connection-type 'pipe)) done-p) (set-process-filter diff --git a/core/autoload/sessions.el b/core/autoload/sessions.el index de08be93d..ece9fe2f9 100644 --- a/core/autoload/sessions.el +++ b/core/autoload/sessions.el @@ -71,6 +71,9 @@ "TODO" (add-hook 'window-setup-hook #'doom-load-session 'append)) +;;;###autoload +(add-to-list 'command-switch-alist (cons "--restore" #'doom-restore-session-handler)) + ;; ;;; Commands diff --git a/core/cli/byte-compile.el b/core/cli/byte-compile.el index 49121e0ff..b8831cd7c 100644 --- a/core/cli/byte-compile.el +++ b/core/cli/byte-compile.el @@ -2,7 +2,9 @@ (defcli! (compile c) ((recompile-p ["-r" "--recompile"]) - &rest targets) + (core-p ["-c" "--core"]) + (private-p ["-p" "--private"]) + (verbose-p ["-v" "--verbose"])) "Byte-compiles your config or selected modules. compile [TARGETS...] @@ -11,8 +13,23 @@ Accepts :core and :private as special arguments, which target Doom's core files and your private config files, respectively. To recompile your packages, use -'doom rebuild' instead." - (doom-cli-byte-compile targets recompile-p)) +'doom build' instead." + (doom-cli-byte-compile + (if (or core-p private-p) + (append (when core-p + (list (doom-glob doom-emacs-dir "init.el") + doom-core-dir)) + (when private-p + (list doom-private-dir))) + (append (list (doom-glob doom-emacs-dir "init.el") + doom-core-dir) + (cl-remove-if-not + ;; Only compile Doom's modules + (lambda (path) (file-in-directory-p path doom-emacs-dir)) + ;; Omit `doom-private-dir', which is always first + (cdr (doom-module-load-path))))) + recompile-p + verbose-p)) (defcli! clean () "Delete all *.elc files." @@ -25,17 +42,20 @@ and your private config files, respectively. To recompile your packages, use (defun doom--byte-compile-ignore-file-p (path) (let ((filename (file-name-nondirectory path))) - (or (string-prefix-p "." filename) + (or (not (equal (file-name-extension path) "el")) + (member filename (list "packages.el" "doctor.el")) + (string-prefix-p "." filename) (string-prefix-p "test-" filename) - (string-suffix-p ".example.el" filename) - (not (equal (file-name-extension path) "el")) - (member filename (list "packages.el" "doctor.el"))))) + (string-prefix-p "flycheck_" filename) + (string-suffix-p ".example.el" filename)))) -(cl-defun doom-cli-byte-compile (&optional modules recompile-p) +(cl-defun doom-cli-byte-compile (&optional targets recompile-p verbose-p) "Byte compiles your emacs configuration. init.el is always byte-compiled by this. +If TARGETS is specified, as a list of direcotries + If MODULES is specified (a list of module strings, e.g. \"lang/php\"), those are byte-compiled. Otherwise, all enabled modules are byte-compiled, including Doom core. It always ignores unit tests and files with `no-byte-compile' enabled. @@ -48,138 +68,109 @@ Use `doom-clean-byte-compiled-files' or `make clean' to reverse byte-compilation. If RECOMPILE-P is non-nil, only recompile out-of-date files." - (let ((default-directory doom-emacs-dir) - (doom-modules (doom-modules)) - (byte-compile-verbose doom-debug-mode) - (byte-compile-warnings '(not free-vars unresolved noruntime lexical make-local)) - - ;; In case it is changed during compile-time - (auto-mode-alist auto-mode-alist) - (noninteractive t) - - targets) - - (let (target-dirs) - (dolist (module (delete-dups modules)) - (pcase module - (":core" - (push (doom-glob doom-emacs-dir "init.el") targets) - (push doom-core-dir target-dirs)) - (":private" - (push doom-private-dir target-dirs)) - ((pred file-directory-p) - (push module target-dirs)) - ((pred (string-match "^\\([^/]+\\)/\\([^/]+\\)$")) - (push (doom-module-locate-path - (doom-keyword-intern (match-string 1 module)) - (intern (match-string 2 module))) - target-dirs)) - (_ (user-error "%S is not a valid target" module)))) - - (and (or (null modules) (member ":private" modules)) - (not recompile-p) - (not (or doom-auto-accept - (y-or-n-p - (concat "Warning: byte compiling is for advanced users. It will interfere with your\n" - "efforts to debug issues. It is not recommended you do it if you frequently\n" - "tinker with your Emacs config.\n\n" - "Alternatively, use `bin/doom compile :core` instead to byte-compile only the\n" - "Doom core files, as these don't change often.\n\n" - "If you have issues, please make sure byte-compilation isn't the cause by using\n" - "`bin/doom clean` to clear out your *.elc files.\n\n" - "Byte-compile anyway?")))) - (user-error "Aborting")) + (let* ((default-directory doom-emacs-dir) + (targets (nreverse (delete-dups targets))) + ;; In case it is changed during compile-time + (auto-mode-alist auto-mode-alist) + kill-emacs-hook kill-buffer-query-functions) + (let ((after-load-functions + (if (null targets) + after-load-functions + ;; Assemble el files we want to compile, and preserve in the order + ;; they are loaded in, so we don't run into any scary catch-22s + ;; while byte-compiling, like missing macros. + (cons (let ((target-dirs (cl-remove-if-not #'file-directory-p targets))) + (lambda (path) + (and (not (doom--byte-compile-ignore-file-p path)) + (cl-find-if (doom-partial #'file-in-directory-p path) + target-dirs) + (cl-pushnew path targets)))) + after-load-functions)))) + (doom-log "Reloading Doom in preparation for byte-compilation") ;; But first we must be sure that Doom and your private config have been ;; fully loaded. Which usually aren't so in an noninteractive session. - (let ((doom-interactive-mode 'byte-compile)) - (doom-initialize) - (doom-initialize-packages) - (doom-initialize-core)) + (let ((load-prefer-newer t) + (noninteractive t) + doom-interactive-mode) + (doom-initialize 'force) + (quiet! (doom-initialize-packages)))) - ;; - (unless target-dirs - (push (doom-glob doom-emacs-dir "init.el") targets) - ;; If no targets were supplied, then we use your module list. - (appendq! target-dirs - (list doom-core-dir) - (nreverse - (cl-remove-if-not - (lambda (path) (file-in-directory-p path doom-emacs-dir)) - ;; Omit `doom-private-dir', which is always first - (cdr (doom-module-load-path)))))) + (if (null targets) + (print! (info "No targets to %scompile" (if recompile-p "re" ""))) + (print! (start "%scompiling your config...") + (if recompile-p "Re" "Byte-")) - ;; Assemble el files we want to compile; taking into account that MODULES - ;; may be a list of MODULE/SUBMODULE strings from the command line. - (appendq! targets - (doom-files-in target-dirs - :match "\\.el$" - :filter #'doom--byte-compile-ignore-file-p))) + (dolist (dir + (cl-remove-if-not #'file-directory-p targets) + (setq targets (cl-remove-if #'file-directory-p targets))) + (prependq! targets + (doom-files-in + dir :match "\\.el" :filter #'doom--byte-compile-ignore-file-p))) - (unless targets - (print! - (if targets - (warn "Couldn't find any valid targets") - (info "No targets to %scompile" (if recompile-p "re" "")))) - (cl-return nil)) - - (print! - (start (if recompile-p - "Recompiling stale elc files..." - "Byte-compiling your config (may take a while)..."))) - (print-group! - (require 'use-package) - (condition-case e - (let ((total-ok 0) - (total-fail 0) - (total-noop 0) - (use-package-defaults use-package-defaults) - (use-package-expand-minimally t) - kill-emacs-hook kill-buffer-query-functions) - ;; Prevent packages from being loaded at compile time if they - ;; don't meet their own predicates. - (push (list :no-require t - (lambda (_name args) - (or (when-let (pred (or (plist-get args :if) - (plist-get args :when))) - (not (eval pred t))) - (when-let (pred (plist-get args :unless)) - (eval pred t))))) - use-package-defaults) - - (unless recompile-p - (doom-clean-byte-compiled-files)) - - (dolist (target (delete-dups (delq nil targets))) - (cl-incf - (if (not (or (not recompile-p) - (let ((elc-file (byte-compile-dest-file target))) - (and (file-exists-p elc-file) - (file-newer-than-file-p target elc-file))))) - total-noop - (pcase (if (doom-file-cookie-p target "if" t) - (byte-compile-file target) - 'no-byte-compile) - (`no-byte-compile - (print! (info "Ignored %s") (relpath target)) - total-noop) - (`nil - (print! (error "Failed to compile %s") (relpath target)) - total-fail) - (_ - (print! (success "Compiled %s") (relpath target)) - (load target t t) - total-ok))))) - (print! (class (if (= total-fail 0) 'success 'error) - "%s %d/%d file(s) (%d ignored)") - (if recompile-p "Recompiled" "Compiled") - total-ok (- (length targets) total-noop) - total-noop) - t) - ((debug error) - (print! (error "\nThere were breaking errors.\n\n%s") - "Reverting changes...") - (signal 'doom-error (list 'byte-compile e))))))) + (print-group! + (require 'use-package) + (condition-case-unless-debug e + (let* ((total-ok 0) + (total-fail 0) + (total-noop 0) + (byte-compile-verbose nil) + (byte-compile-warnings '(not free-vars unresolved noruntime lexical make-local)) + (byte-compile-dynamic-docstrings t) + (use-package-compute-statistics nil) + (use-package-defaults use-package-defaults) + (use-package-expand-minimally t) + (targets (delete-dups targets)) + (modules (seq-group-by (lambda (t) (doom-module-from-path t)) targets)) + (total-files (length targets)) + (total-modules (length modules)) + (i 0) + last-module) + ;; Prevent packages from being loaded at compile time if they + ;; don't meet their own predicates. + (push (list :no-require t + (lambda (_name args) + (or (when-let (pred (or (plist-get args :if) + (plist-get args :when))) + (not (eval pred t))) + (when-let (pred (plist-get args :unless)) + (eval pred t))))) + use-package-defaults) + (dolist (module-files modules) + (cl-incf i) + (dolist (target (cdr module-files)) + (let ((elc-file (byte-compile-dest-file target))) + (cl-incf + (if (and recompile-p (not (file-newer-than-file-p target elc-file))) + total-noop + (pcase (if (not (doom-file-cookie-p target "if" t)) + 'no-byte-compile + (unless (equal last-module (car module-files)) + (print! (success "(% 3d/%d) Compiling %s %s module...") + i total-modules (caar module-files) (cdar module-files)) + (setq last-module (car module-files))) + (if verbose-p + (byte-compile-file target) + (quiet! (byte-compile-file target)))) + (`no-byte-compile + (print! (debug "(% 3d/%d) Ignored %s") + i total-modules (relpath target)) + total-noop) + (`nil + (print! (error "(% 3d/%d) Failed to compile %s") + i total-modules (relpath target)) + total-fail) + (_ total-ok))))))) + (print! (class (if (= total-fail 0) 'success 'warn) + "%s %d/%d file(s) (%d ignored)") + (if recompile-p "Recompiled" "Byte-compiled") + total-ok total-files + total-noop) + (= total-fail 0)) + ((debug error) + (print! (error "There were breaking errors.\n\n%s") + "Reverting changes...") + (signal 'doom-error (list 'byte-compile e)))))))) (defun doom-clean-byte-compiled-files () "Delete all the compiled elc files in your Emacs configuration and private @@ -188,7 +179,8 @@ module. This does not include your byte-compiled, third party packages.'" (print! (start "Cleaning .elc files")) (print-group! (cl-loop with default-directory = doom-emacs-dir - with success = nil + with success = 0 + with esc = (if doom-debug-mode "" "\033[1A") for path in (append (doom-glob doom-emacs-dir "*.elc") (doom-files-in doom-private-dir :match "\\.elc$" :depth 1) @@ -196,10 +188,10 @@ module. This does not include your byte-compiled, third party packages.'" (doom-files-in doom-modules-dirs :match "\\.elc$" :depth 4)) if (file-exists-p path) do (delete-file path) - and do (print! (success "Deleted %s") (relpath path)) - and do (setq success t) + and do (print! (success "\033[KDeleted %s%s") (relpath path) esc) + and do (cl-incf success) finally do - (print! (if success - (success "All elc files deleted") - (info "No elc files to clean")))) + (print! (if (> success 0) + (success "\033[K%d elc files deleted" success) + (info "\033[KNo elc files to clean")))) t)) diff --git a/core/cli/debug.el b/core/cli/debug.el index d36f73dc6..1faa6956e 100644 --- a/core/cli/debug.el +++ b/core/cli/debug.el @@ -1,10 +1,12 @@ ;;; core/cli/debug.el -*- lexical-binding: t; -*- +(load! "autoload/debug" doom-core-dir) + ;; ;;; Commands (defcli! info - ((format ["--json" "--md" "--lisp"] "What format to dump info into")) + ((format ["--json" "--md" "--lisp"] "What format to dump info into")) "Output system info in markdown for bug reports." (pcase format ("--json" @@ -24,6 +26,5 @@ (defcli! (version v) () "Show version information for Doom & Emacs." - :bare t (doom/version) nil) diff --git a/core/cli/doctor.el b/core/cli/doctor.el index 22e690e2e..a394d2965 100644 --- a/core/cli/doctor.el +++ b/core/cli/doctor.el @@ -81,7 +81,6 @@ in." (print-group! (let ((doom-interactive-mode 'doctor)) (doom-initialize 'force) - (doom-initialize-core) (doom-initialize-modules)) (print! (success "Initialized Doom Emacs %s") doom-version) diff --git a/core/cli/env.el b/core/cli/env.el index d80414fed..5b2188385 100644 --- a/core/cli/env.el +++ b/core/cli/env.el @@ -1,8 +1,9 @@ ;;; core/cli/env.el -*- lexical-binding: t; -*- (defcli! env - ((clear-p ["-c" "--clear"] "Clear and delete your envvar file") - (outputfile ["-o" PATH] + ((allow ["-a" "--allow"] "An envvar whitelist regexp") + (clear-p ["-c" "--clear"] "Clear and delete your envvar file") + (outputfile ["-o" PATH] "Generate the envvar file at PATH. Envvar files that aren't in `doom-env-file' won't be loaded automatically at startup. You will need to load them manually from your private config with the `doom-load-envvars-file' @@ -58,35 +59,25 @@ Why this over exec-path-from-shell? (defvar doom-env-ignored-vars '("^DBUS_SESSION_BUS_ADDRESS$" - "^GPG_AGENT_INFO$" - "^\\(SSH\\|GPG\\)_TTY$" - "^HOME$" - "^PS1$" - "^PWD$" - "^R?PROMPT$" - "^SSH_AGENT_PID$" - "^SSH_AUTH_SOCK$" - "^TERM$" + "^GPG_AGENT_INFO$" "^\\(SSH\\|GPG\\)_TTY$" + "^SSH_\\(AUTH_SOCK\\|AGENT_PID\\)$" + "^HOME$" "^PWD$" "^PS1$" "^R?PROMPT$" "^TERM$" ;; Doom envvars - "^DEBUG$" - "^INSECURE$" - "^YES$" - "^__") + "^DEBUG$" "^INSECURE$" "^YES$" "^__") "Environment variables to not save in `doom-env-file'. Each string is a regexp, matched against variable names to omit from `doom-env-file'.") -(defun doom-cli-reload-env-file (&optional force-p env-file) +(defun doom-cli-reload-env-file (&optional force-p env-file whitelist) "Generates `doom-env-file', if it doesn't exist (or if FORCE-P). This scrapes the variables from your shell environment by running `doom-env-executable' through `shell-file-name' with `doom-env-switches'. By default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in `doom-env-ignored-vars' are removed." - (let ((env-file (if env-file - (expand-file-name env-file) - doom-env-file))) + (let ((env-file (if env-file (expand-file-name env-file) doom-env-file)) + (process-environment doom--initial-process-environment)) (when (or force-p (not (file-exists-p env-file))) (with-temp-file env-file (setq-local coding-system-for-write 'utf-8) @@ -95,38 +86,38 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in "Regenerating" "Generating") (path env-file)) - (let ((process-environment doom--initial-process-environment)) - (print! (info "Scraping shell environment")) - (print-group! - (when doom-interactive-mode - (user-error "'doom env' must be run on the command line, not an interactive session")) - (goto-char (point-min)) - (insert - (concat - "# -*- mode: sh -*-\n" - "# ---------------------------------------------------------------------------\n" - "# This file was auto-generated by `doom env'. It contains a list of environment\n" - "# variables scraped from your default shell (excluding variables blacklisted\n" - "# in doom-env-ignored-vars).\n" - "#\n" - (if (file-equal-p env-file doom-env-file) - (concat "# It is NOT safe to edit this file. Changes will be overwritten next time you\n" - "# run 'doom sync'. To create a safe-to-edit envvar file use:\n#\n" - "# doom env -o ~/.doom.d/myenv\n#\n" - "# And load it with (doom-load-envvars-file \"~/.doom.d/myenv\").\n") - (concat "# This file is safe to edit by hand, but remember to preserve the null bytes at\n" - "# the end of each line! needs to be loaded manually with:\n#\n" - "# (doom-load-envvars-file \"path/to/this/file\")\n#\n" - "# Use 'doom env -o path/to/this/file' to regenerate it.")) - "# ---------------------------------------------------------------------------\n\0\n")) - ;; We assume that this noninteractive session was spawned from the - ;; user's interactive shell, therefore we just dump - ;; `process-environment' to a file. - (dolist (env process-environment) - (if (cl-find-if (doom-rpartial #'string-match-p (car (split-string env "="))) - doom-env-ignored-vars) - (print! (info "Ignoring %s") env) - (insert env "\0\n"))) - (print! (success "Successfully generated %S") - (path env-file)) - t)))))) + (print-group! + (when doom-interactive-mode + (user-error "'doom env' must be run on the command line, not an interactive session")) + (goto-char (point-min)) + (insert + (concat + "# -*- mode: sh -*-\n" + "# ---------------------------------------------------------------------------\n" + "# This file was auto-generated by `doom env'. It contains a list of environment\n" + "# variables scraped from your default shell (excluding variables blacklisted\n" + "# in doom-env-ignored-vars).\n" + "#\n" + (if (file-equal-p env-file doom-env-file) + (concat "# It is NOT safe to edit this file. Changes will be overwritten next time you\n" + "# run 'doom sync'. To create a safe-to-edit envvar file use:\n#\n" + "# doom env -o ~/.doom.d/myenv\n#\n" + "# And load it with (doom-load-envvars-file \"~/.doom.d/myenv\").\n") + (concat "# This file is safe to edit by hand, but remember to preserve the null bytes at\n" + "# the end of each line! needs to be loaded manually with:\n#\n" + "# (doom-load-envvars-file \"path/to/this/file\")\n#\n" + "# Use 'doom env -o path/to/this/file' to regenerate it.")) + "# ---------------------------------------------------------------------------\n\0\n")) + ;; We assume that this noninteractive session was spawned from the + ;; user's interactive shell, therefore we just dump + ;; `process-environment' to a file. + (dolist (env process-environment) + (if (and (cl-find-if (doom-rpartial #'string-match-p (car (split-string env "="))) + doom-env-ignored-vars) + (not (cl-find-if (doom-rpartial #'string-match-p (car (split-string env "="))) + whitelist))) + (print! (info "Ignoring %s") env) + (insert env "\0\n"))) + (print! (success "Successfully generated %S") + (path env-file)) + t))))) diff --git a/core/cli/install.el b/core/cli/install.el index 719ca07b0..8b0d81f32 100644 --- a/core/cli/install.el +++ b/core/cli/install.el @@ -24,7 +24,6 @@ DOOMDIR environment variable. e.g. doom -p ~/.config/doom install DOOMDIR=~/.config/doom doom install" - :bare t (print! (green "Installing Doom Emacs!\n")) (let ((default-directory (doom-path "~"))) ;; Create `doom-private-dir' @@ -59,8 +58,7 @@ DOOMDIR environment variable. e.g. ;; In case no init.el was present the first time `doom-initialize-modules' was ;; called in core.el (e.g. on first install) - (doom-initialize 'force 'noerror) - (doom-initialize-modules) + (doom-initialize-modules 'force) ;; Ask if user would like an envvar file generated (if noenv-p @@ -79,28 +77,28 @@ DOOMDIR environment variable. e.g. (print! "Regenerating autoloads files") (doom-cli-reload-autoloads) - + (cond (nofonts-p) - (IS-WINDOWS - (print! (warn "Doom cannot install all-the-icons' fonts on Windows!\n")) - (print-group! - (print! - (concat "You'll have to do so manually:\n\n" - " 1. Launch Doom Emacs\n" - " 2. Execute 'M-x all-the-icons-install-fonts' to download the fonts\n" - " 3. Open the download location in windows explorer\n" - " 4. Open each font file to install them")))) - ((or doom-auto-accept - (y-or-n-p "Download and install all-the-icon's fonts?")) - (require 'all-the-icons) - (let ((window-system (cond (IS-MAC 'ns) - (IS-LINUX 'x)))) - (all-the-icons-install-fonts 'yes)))) + (IS-WINDOWS + (print! (warn "Doom cannot install all-the-icons' fonts on Windows!\n")) + (print-group! + (print! + (concat "You'll have to do so manually:\n\n" + " 1. Launch Doom Emacs\n" + " 2. Execute 'M-x all-the-icons-install-fonts' to download the fonts\n" + " 3. Open the download location in windows explorer\n" + " 4. Open each font file to install them")))) + ((or doom-auto-accept + (y-or-n-p "Download and install all-the-icon's fonts?")) + (require 'all-the-icons) + (let ((window-system (cond (IS-MAC 'ns) + (IS-LINUX 'x)))) + (all-the-icons-install-fonts 'yes)))) (when (file-exists-p "~/.emacs") (print! (warn "A ~/.emacs file was detected. This conflicts with Doom and should be deleted!"))) (print! (success "\nFinished! Doom is ready to go!\n")) (with-temp-buffer - (doom-template-insert "QUICKSTART_INTRO") - (print! (buffer-string))))) + (insert (doom-glob doom-core-dir "templates/QUICKSTART_INTRO")) + (print! "%s" (buffer-string))))) diff --git a/core/cli/packages.el b/core/cli/packages.el index 71b7b583e..77e1ca362 100644 --- a/core/cli/packages.el +++ b/core/cli/packages.el @@ -2,7 +2,7 @@ ;;; core/cli/packages.el (defcli! (update u) - ((discard-p ["--discard"] "All local changes to packages are discarded")) + ((discard-p ["--discard"] "All local changes to packages are discarded")) "Updates packages. This works by fetching all installed package repos and checking the distance @@ -74,23 +74,77 @@ list remains lean." "-n" "25" end-ref (concat "^" (regexp-quote start-ref))) (straight--process-get-output))) +(defun doom--barf-if-incomplete-packages () + (let ((straight-safe-mode t)) + (condition-case _ (straight-check-all) + (error (user-error "Package state is incomplete. Run 'doom sync' first"))))) + +(defmacro doom--with-package-recipes (recipes binds &rest body) + (declare (indent 2)) + (let ((recipe-var (make-symbol "recipe")) + (recipes-var (make-symbol "recipes"))) + `(let* ((,recipes-var ,recipes) + (built ()) + (straight-use-package-pre-build-functions + (cons (lambda (pkg &rest _) (cl-pushnew pkg built :test #'equal)) + straight-use-package-pre-build-functions))) + (dolist (,recipe-var ,recipes-var (nreverse built)) + (cl-block nil + (straight--with-plist (append (list :recipe ,recipe-var) ,recipe-var) + ,(doom-enlist binds) + ,@body)))))) + +(defvar doom--cli-updated-recipes nil) +(defun doom--cli-recipes-update () + "Updates straight and recipe repos." + (unless doom--cli-updated-recipes + (straight--make-build-cache-available) + (print! (start "Updating recipe repos...")) + (print-group! + (doom--with-package-recipes + (delq + nil (mapcar (doom-rpartial #'gethash straight--repo-cache) + (mapcar #'symbol-name straight-recipe-repositories))) + (recipe package type local-repo) + (let ((esc (unless doom-debug-mode "\033[1A")) + (ref (straight-vc-get-commit type local-repo)) + newref) + (print! (start "\033[KUpdating recipes for %s...%s") package esc) + (when (straight-vc-fetch-from-remote recipe) + (setq output (straight--process-get-output)) + (straight-merge-package package) + (or (equal ref (setq newref (straight-vc-get-commit type local-repo))) + (print! (success "\033[K%s updated (%s -> %s)") + package + (doom--abbrev-commit ref) + (doom--abbrev-commit newref))))))) + (setq straight--recipe-lookup-cache (make-hash-table :test #'eq) + doom--cli-updated-recipes t))) + + (defun doom-cli-packages-install () "Installs missing packages. This function will install any primary package (i.e. a package with a `package!' declaration) or dependency thereof that hasn't already been." - (straight--transaction-finalize) + (doom-initialize-packages) (print! (start "Installing packages...")) (let ((pinned (doom-package-pinned-list))) (print-group! (if-let (built - (doom-with-package-recipes (doom-package-recipe-list) + (doom--with-package-recipes (doom-package-recipe-list) (recipe package type local-repo) + (unless (file-directory-p (straight--repos-dir local-repo)) + (doom--cli-recipes-update)) (condition-case-unless-debug e - (straight-use-package (intern package)) + (let ((straight-use-package-pre-build-functions + (cons (lambda (pkg &rest _) + (when-let (commit (cdr (assoc pkg pinned))) + (print! (info "Checked out %s") commit))) + straight-use-package-pre-build-functions))) + (straight-use-package (intern package))) (error - (signal 'doom-package-error - (list package e (straight--process-get-output))))))) + (signal 'doom-package-error (list package e)))))) (print! (success "Installed %d packages") (length built)) (print! (info "No packages need to be installed")) @@ -99,7 +153,7 @@ declaration) or dependency thereof that hasn't already been." (defun doom-cli-packages-build (&optional force-p) "(Re)build all packages." - (straight--transaction-finalize) + (doom-initialize-packages) (print! (start "(Re)building %spackages...") (if force-p "all " "")) (print-group! (let ((straight-check-for-modifications @@ -118,7 +172,7 @@ declaration) or dependency thereof that hasn't already been." (unless force-p (straight--make-build-cache-available)) (if-let (built - (doom-with-package-recipes recipes (package local-repo) + (doom--with-package-recipes recipes (package local-repo) (unless force-p ;; Ensure packages with outdated files/bytecode are rebuilt (let ((build-dir (straight--build-dir package)) @@ -143,18 +197,21 @@ declaration) or dependency thereof that hasn't already been." (defun doom-cli-packages-update () "Updates packages." - (straight--transaction-finalize) - (print! (start "Updating packages (this may take a while)...")) + (doom-initialize-packages) + (doom--barf-if-incomplete-packages) (let* ((repo-dir (straight--repos-dir)) (pinned (doom-package-pinned-list)) + (recipes (doom-package-recipe-list)) (packages-to-rebuild (make-hash-table :test 'equal)) (repos-to-rebuild (make-hash-table :test 'equal)) - (recipes (doom-package-recipe-list)) (total (length recipes)) (esc (unless doom-debug-mode "\033[1A")) (i 0) errors) - (doom-with-package-recipes recipes (recipe package type local-repo) + (when recipes + (doom--cli-recipes-update)) + (print! (start "Updating packages (this may take a while)...")) + (doom--with-package-recipes recipes (recipe package type local-repo) (cl-incf i) (print-group! (unless (straight--repository-is-available-p recipe) @@ -173,7 +230,9 @@ declaration) or dependency thereof that hasn't already been." (error "%S is not a valid repository" package))) (condition-case-unless-debug e (let ((ref (straight-vc-get-commit type local-repo)) - (target-ref (cdr (assoc local-repo pinned))) + (target-ref + (cdr (or (assoc local-repo pinned) + (assoc package pinned)))) output) (or (cond ((not (stringp target-ref)) @@ -201,9 +260,9 @@ declaration) or dependency thereof that hasn't already been." (doom--same-commit-p target-ref (straight-vc-get-commit type local-repo))) ((print! (start "\033[K(%d/%d) Re-cloning %s...") i total local-repo esc) - (let ((repo (straight--repos-dir local-repo))) - (ignore-errors - (delete-directory repo 'recursive)) + (let ((repo (straight--repos-dir local-repo)) + (straight-vc-git-default-clone-depth 'full)) + (delete-directory repo 'recursive) (print-group! (straight-use-package (intern package) nil 'no-build)) (prog1 (file-directory-p repo) @@ -219,7 +278,7 @@ declaration) or dependency thereof that hasn't already been." (puthash package t packages-to-rebuild) (unless (string-empty-p output) (print! (start "\033[K(%d/%d) Updating %s...") i total local-repo) - (print-group! (print! (indent 2 output)))) + (print-group! (print! "%s" (indent 2 output)))) (print! (success "\033[K(%d/%d) %s updated (%s -> %s)") i total local-repo (doom--abbrev-commit ref) @@ -227,24 +286,19 @@ declaration) or dependency thereof that hasn't already been." (user-error (signal 'user-error (error-message-string e))) (error - (print! (warn "\033[K(%d/%d) Encountered error with %s" i total package)) - (print-group! - (print! (error "%s") e) - (print-group! (print! (info "%s" (straight--process-get-output))))) - (push package errors)))))) - (princ "\033[K") - (when errors - (print! (error "Encountered %d error(s), the offending packages: %s") - (length errors) (string-join errors ", "))) - (if (hash-table-empty-p packages-to-rebuild) - (ignore (print! (success "All %d packages are up-to-date") total)) - (let ((default-directory (straight--build-dir))) - (mapc (doom-rpartial #'delete-directory 'recursive) - (hash-table-keys packages-to-rebuild))) - (print! (success "Updated %d package(s)") - (hash-table-count packages-to-rebuild)) - (doom-cli-packages-build) - t))) + (signal 'doom-package-error (list package e))))))) + (print-group! + (princ "\033[K") + (if (hash-table-empty-p packages-to-rebuild) + (ignore (print! (success "All %d packages are up-to-date") total)) + (straight--transaction-finalize) + (let ((default-directory (straight--build-dir))) + (mapc (doom-rpartial #'delete-directory 'recursive) + (hash-table-keys packages-to-rebuild))) + (print! (success "Updated %d package(s)") + (hash-table-count packages-to-rebuild)) + (doom-cli-packages-build) + t)))) ;;; PURGE (for the emperor) @@ -258,8 +312,8 @@ declaration) or dependency thereof that hasn't already been." (defun doom--cli-packages-purge-builds (builds) (if (not builds) - (progn (print! (info "No builds to purge")) - 0) + (prog1 0 + (print! (info "No builds to purge"))) (print! (start "Purging straight builds..." (length builds))) (print-group! (length @@ -287,8 +341,8 @@ declaration) or dependency thereof that hasn't already been." (defun doom--cli-packages-regraft-repos (repos) (if (not repos) - (progn (print! (info "No repos to regraft")) - 0) + (prog1 0 + (print! (info "No repos to regraft"))) (print! (start "Regrafting %d repos..." (length repos))) (let ((before-size (doom-directory-size (straight--repos-dir)))) (print-group! @@ -302,8 +356,7 @@ declaration) or dependency thereof that hasn't already been." (defun doom--cli-packages-purge-repo (repo) (let ((repo-dir (straight--repos-dir repo))) (delete-directory repo-dir 'recursive) - (ignore-errors - (delete-file (straight--modified-file repo))) + (delete-file (straight--modified-file repo)) (if (file-directory-p repo-dir) (ignore (print! (error "Failed to purge repos/%s" repo))) (print! (success "Purged repos/%s" repo)) @@ -311,8 +364,8 @@ declaration) or dependency thereof that hasn't already been." (defun doom--cli-packages-purge-repos (repos) (if (not repos) - (progn (print! (info "No repos to purge")) - 0) + (prog1 0 + (print! (info "No repos to purge"))) (print! (start "Purging straight repositories...")) (print-group! (length @@ -322,8 +375,8 @@ declaration) or dependency thereof that hasn't already been." (require 'core-packages) (let ((dirs (doom-files-in package-user-dir :type t :depth 0))) (if (not dirs) - (progn (print! (info "No ELPA packages to purge")) - 0) + (prog1 0 + (print! (info "No ELPA packages to purge"))) (print! (start "Purging ELPA packages...")) (dolist (path dirs (length dirs)) (condition-case e @@ -346,16 +399,18 @@ a `package!' declaration) or isn't depended on by another primary package. If BUILDS-P, include straight package builds. If REPOS-P, include straight repos. If ELPA-P, include packages installed with package.el (M-x package-install)." + (doom-initialize-packages) + (doom--barf-if-incomplete-packages) (print! (start "Purging orphaned packages (for the emperor)...")) (cl-destructuring-bind (&optional builds-to-purge repos-to-purge repos-to-regraft) (let ((rdirs (straight--directory-files (straight--repos-dir) nil nil 'sort)) (bdirs (straight--directory-files (straight--build-dir) nil nil 'sort))) - (list (cl-remove-if (doom-rpartial #'gethash straight--profile-cache) - bdirs) - (cl-remove-if (doom-rpartial #'straight--checkhash straight--repo-cache) - rdirs) - (cl-remove-if-not (doom-rpartial #'straight--checkhash straight--repo-cache) - rdirs))) + (list (seq-remove (doom-rpartial #'gethash straight--profile-cache) + bdirs) + (seq-remove (doom-rpartial #'straight--checkhash straight--repo-cache) + rdirs) + (seq-filter (doom-rpartial #'straight--checkhash straight--repo-cache) + rdirs))) (let (success) (print-group! (if (not builds-p) diff --git a/core/cli/upgrade.el b/core/cli/upgrade.el index 5e327f525..14d3854ce 100644 --- a/core/cli/upgrade.el +++ b/core/cli/upgrade.el @@ -1,8 +1,8 @@ ;;; core/cli/upgrade.el -*- lexical-binding: t; -*- (defcli! (upgrade up) - ((force-p ["-f" "--force"] "Discard local changes to Doom and packages, and upgrade anyway") - (packages-only-p ["-p" "--packages"] "Only upgrade packages, not Doom")) + ((force-p ["-f" "--force"] "Discard local changes to Doom and packages, and upgrade anyway") + (packages-only-p ["-p" "--packages"] "Only upgrade packages, not Doom")) "Updates Doom and packages. This requires that ~/.emacs.d is a git repo, and is the equivalent of the @@ -19,7 +19,7 @@ following shell commands: nil (list (unless packages-only-p (doom-cli-upgrade doom-auto-accept doom-auto-discard)) - (doom-cli-execute "refresh") + (doom-cli-execute "sync") (when (doom-cli-packages-update) (doom-cli-reload-package-autoloads) t))) @@ -110,6 +110,23 @@ following shell commands: (equal (vc-git--rev-parse "HEAD") new-rev)) (print! (info "%s") (cdr result)) (error "Failed to check out %s" (substring new-rev 0 10))) + + ;; Reload Doom's CLI & libraries, in case there were any + ;; upstream changes. Major changes will still break, however + (condition-case e + (progn + (mapc (doom-rpartial #'unload-feature t) + '(core core-lib + core-cli + core-modules + core-packages)) + (require 'core) + (setq doom-init-p nil + doom-init-modules-p nil) + (doom-initialize)) + (error + (signal 'doom-error (list "Could not upgrade Doom without issues")))) + (print! (success "Finished upgrading Doom Emacs"))) t))))) (ignore-errors diff --git a/core/core-cli.el b/core/core-cli.el index 852f6fd43..2aa215247 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -1,5 +1,24 @@ ;;; -*- lexical-binding: t; no-byte-compile: t; -*- +(require 'seq) + +(load! "autoload/process") +(load! "autoload/plist") +(load! "autoload/files") +(load! "autoload/format") + +;; Create all our core directories to quell file errors +(mapc (doom-rpartial #'make-directory 'parents) + (list doom-local-dir + doom-etc-dir + doom-cache-dir)) + +;; Ensure straight and the bare minimum is ready to go +(require 'core-modules) +(require 'core-packages) +(doom-initialize-core-packages) + + ;; ;;; Variables @@ -11,7 +30,6 @@ commands like `doom-cli-packages-install', `doom-cli-packages-update' and (defvar doom-auto-discard (getenv "FORCE") "If non-nil, discard all local changes while updating.") -(defvar doom--cli-p nil) (defvar doom--cli-commands (make-hash-table :test 'equal)) (defvar doom--cli-groups (make-hash-table :test 'equal)) (defvar doom--cli-group nil) @@ -54,9 +72,10 @@ commands like `doom-cli-packages-install', `doom-cli-packages-update' and (defun doom--cli-process (cli args) (let* ((args (copy-sequence args)) (arglist (copy-sequence (doom-cli-arglist cli))) - (expected (or (cl-position-if (doom-rpartial #'memq cl--lambda-list-keywords) - arglist) - (length arglist))) + (expected + (or (cl-position-if (doom-rpartial #'memq cl--lambda-list-keywords) + arglist) + (length arglist))) (got 0) restvar rest @@ -137,7 +156,7 @@ Executes a cli defined with `defcli!' with the name or alias specified by COMMAND, and passes ARGS to it." (if-let (cli (doom-cli-get command)) (funcall (doom-cli-fn cli) - (doom--cli-process cli args)) + (doom--cli-process cli (remq nil args))) (user-error "Couldn't find any %S command" command))) (defmacro defcli! (name speclist &optional docstring &rest body) @@ -186,10 +205,6 @@ BODY will be run when this dispatcher is called." for optsym = (if (listp opt) (car opt) opt) unless (memq optsym cl--lambda-list-keywords) collect (list optsym `(cdr (assq ',optsym --alist--)))) - ,@(unless (plist-get plist :bare) - '((unless doom-init-p - (doom-initialize 'force 'noerror) - (doom-initialize-modules)))) ,@body))) doom--cli-commands) (when aliases @@ -208,10 +223,25 @@ BODY will be run when this dispatcher is called." ;;; Straight hacks (defvar doom--cli-straight-discard-options - '("^Delete remote \"[^\"]+\", re-create it with correct " - "^Reset branch " - "^Abort merge$" - "^Discard changes$")) + '((" has diverged from branch " + . "^Reset [^ ]+ to branch") + (" but recipe specifies a URL of " + . "^Delete remote \"[^\"]+\", re-create it with correct ") + (" has a merge conflict:" + . "^Abort merge$") + (" has a dirty worktree:" + . "^Discard changes$") + ("^In repository " + . "^Reset branch ")) + "A list of regexps, mapped to regexps. + +Their CAR is tested against the prompt, and CDR is tested against the presented +option, and is used by `straight-vc-git--popup-raw' to select which option to +recommend. + +It may not be obvious to users what they should do for some straight prompts, +so Doom will recommend the one that reverts a package back to its (or target) +original state.") ;; HACK Remove dired & magit options from prompt, since they're inaccessible in ;; noninteractive sessions. @@ -222,63 +252,69 @@ BODY will be run when this dispatcher is called." (defadvice! doom--straight-fallback-to-y-or-n-prompt-a (orig-fn &optional prompt) :around #'straight-are-you-sure (or doom-auto-accept - (if noninteractive - (y-or-n-p (format! "%s" (or prompt ""))) - (funcall orig-fn prompt)))) + (if doom-interactive-mode + (funcall orig-fn prompt) + (y-or-n-p (format! "%s" (or prompt "")))))) + +(defun doom--straight-recommended-option-p (prompt option) + (cl-loop for (prompt-re . opt-re) in doom--cli-straight-discard-options + if (string-match-p prompt-re prompt) + return (string-match-p opt-re option))) (defadvice! doom--straight-fallback-to-tty-prompt-a (orig-fn prompt actions) "Modifies straight to prompt on the terminal when in noninteractive sessions." :around #'straight--popup-raw - (if (not noninteractive) + (if doom-interactive-mode (funcall orig-fn prompt actions) - ;; We can't intercept C-g, so no point displaying any options for this key - ;; when C-c is the proper way to abort batch Emacs. - (delq! "C-g" actions 'assoc) - ;; HACK These are associated with opening dired or magit, which isn't - ;; possible in tty Emacs, so... - (delq! "e" actions 'assoc) - (delq! "g" actions 'assoc) - (if doom-auto-discard - (cl-loop with doom-auto-accept = t - for (_key desc func) in actions - when desc - when (cl-find-if (doom-rpartial #'string-match-p desc) - doom--cli-straight-discard-options) - return (funcall func)) - (print! (start "%s") (red prompt)) - (print-group! - (terpri) - (let (options) - (print-group! - (print! " 1) Abort") - (cl-loop for (_key desc func) in actions + (let ((doom--cli-straight-discard-options doom--cli-straight-discard-options)) + ;; We can't intercept C-g, so no point displaying any options for this key + ;; when C-c is the proper way to abort batch Emacs. + (delq! "C-g" actions 'assoc) + ;; HACK These are associated with opening dired or magit, which isn't + ;; possible in tty Emacs, so... + (delq! "e" actions 'assoc) + (delq! "g" actions 'assoc) + (if doom-auto-discard + (cl-loop with doom-auto-accept = t + for (_key desc func) in actions when desc - do (push func options) - and do - (print! "%2s) %s" (1+ (length options)) - (if (cl-find-if (doom-rpartial #'string-match-p desc) - doom--cli-straight-discard-options) - (green (concat desc " (Recommended)")) - desc)))) + when (doom--straight-recommended-option-p prompt desc) + return (funcall func)) + (print! (start "%s") (red prompt)) + (print-group! (terpri) - (let* ((options - (cons (lambda () - (let ((doom-format-indent 0)) - (terpri) - (print! (warn "Aborted"))) - (kill-emacs 1)) - (nreverse options))) - (prompt - (format! "How to proceed? (%s) " - (mapconcat #'number-to-string - (number-sequence 1 (length options)) - ", "))) - answer fn) - (while (null (nth (setq answer (1- (read-number prompt))) - options)) - (print! (warn "%s is not a valid answer, try again.") - answer)) - (funcall (nth answer options)))))))) + (let (options) + (print-group! + (print! " 1) Abort") + (cl-loop for (_key desc func) in actions + when desc + do (push func options) + and do + (print! "%2s) %s" (1+ (length options)) + (if (doom--straight-recommended-option-p prompt desc) + (progn + (setq doom--cli-straight-discard-options nil) + (green (concat desc " (Recommended)"))) + desc)))) + (terpri) + (let* ((options + (cons (lambda () + (let ((doom-format-indent 0)) + (terpri) + (print! (warn "Aborted"))) + (kill-emacs 1)) + (nreverse options))) + (prompt + (format! "How to proceed? (%s) " + (mapconcat #'number-to-string + (number-sequence 1 (length options)) + ", "))) + answer fn) + (while (null (nth (setq answer (1- (read-number prompt))) + options)) + (print! (warn "%s is not a valid answer, try again.") + answer)) + (funcall (nth answer options))))))))) (defadvice! doom--straight-respect-print-indent-a (args) "Indent straight progress messages to respect `doom-format-indent', so we @@ -297,34 +333,18 @@ everywhere we use it (and internally)." interactive))) -;; -;;; Dependencies - -(require 'seq) - -;; Eagerly load these libraries because we may be in a session that hasn't been -;; fully initialized (e.g. where autoloads files haven't been generated or -;; `load-path' populated). -(load! "autoload/cli") -(load! "autoload/debug") -(load! "autoload/files") -(load! "autoload/format") -(load! "autoload/plist") - - ;; ;;; CLI Commands (load! "cli/help") (load! "cli/install") -(defcligroup! "Maintenance" - "For managing your config and packages" - (defcli! (sync s refresh re) - ((if-necessary-p ["-n" "--if-necessary"] "Only regenerate autoloads files if necessary") - (inhibit-envvar-p ["-e"] "Don't regenerate the envvar file") +(defcli! (sync s refresh re) + ((inhibit-envvar-p ["-e"] "Don't regenerate the envvar file") + (inhibit-elc-p ["-c"] "Don't recompile config") + (update-p ["-u"] "...") (prune-p ["-p" "--prune"] "Purge orphaned packages & regraft repos")) - "Synchronize your config with Doom Emacs. + "Synchronize your config with Doom Emacs. This is the equivalent of running autoremove, install, autoloads, then recompile. Run this whenever you: @@ -337,48 +357,44 @@ recompile. Run this whenever you: It will ensure that unneeded packages are removed, all needed packages are installed, autoloads files are up-to-date and no byte-compiled files have gone stale." - :bare t - (let (success) - ;; Ensures that no pre-existing state pollutes the generation of the new - ;; autoloads files. - (dolist (file (list doom-autoload-file doom-package-autoload-file)) - (delete-file file) - (delete-file (byte-compile-dest-file file))) + (print! (start "Synchronizing your config with Doom Emacs...")) + (print-group! + (and (not inhibit-envvar-p) + (file-exists-p doom-env-file) + (doom-cli-reload-env-file 'force)) + (doom-cli-reload-core-autoloads) + (doom-cli-packages-install) + (doom-cli-packages-build) + (when update-p + (doom-cli-packages-update)) + (doom-cli-packages-purge prune-p 'builds-p prune-p prune-p) + (doom-cli-reload-package-autoloads) + t)) - (doom-initialize 'force 'noerror) - (doom-initialize-modules) - - (print! (start "Synchronizing your config with Doom Emacs...")) - (print-group! - (when (and (not inhibit-envvar-p) - (file-exists-p doom-env-file)) - (doom-cli-reload-env-file 'force)) - - (doom-cli-reload-core-autoloads) - (doom-cli-packages-install) - (doom-cli-packages-build) - (doom-cli-packages-purge prune-p 'builds-p prune-p prune-p) - (doom-cli-reload-package-autoloads) - t))) - - (load! "cli/env") - (load! "cli/upgrade") - (load! "cli/packages") - (load! "cli/autoloads")) +(load! "cli/env") +(load! "cli/upgrade") +(load! "cli/packages") +(load! "cli/autoloads") (defcligroup! "Diagnostics" "For troubleshooting and diagnostics" (load! "cli/doctor") (load! "cli/debug") - (load! "cli/test")) + + ;; Our tests are broken at the moment. Working on fixing them, but for now we + ;; disable them: + ;; (load! "cli/test") + ) + (defcligroup! "Compilation" "For compiling Doom and your config" (load! "cli/byte-compile")) + (defcligroup! "Utilities" "Conveniences for interacting with Doom externally" - (defcli! run () + (defcli! run (&rest args) "Run Doom Emacs from bin/doom's parent directory. All arguments are passed on to Emacs. @@ -388,11 +404,16 @@ All arguments are passed on to Emacs. WARNING: this command exists for convenience and testing. Doom will suffer additional overhead by being started this way. For the best performance, it is -best to run Doom out of ~/.emacs.d and ~/.doom.d.") +best to run Doom out of ~/.emacs.d and ~/.doom.d.")) - ;; (load! "cli/batch") - ;; (load! "cli/org") - ) + +;; +;;; Load user config + +(condition-case-unless-debug e + (load! "init" doom-private-dir t) + (error + (signal 'doom-private-error (list "init.el" e)))) (provide 'core-cli) ;;; core-cli.el ends here diff --git a/core/core-editor.el b/core/core-editor.el index 6b76ffa5b..e05ac3204 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -79,8 +79,8 @@ possible." t)))))) ;; Don't autosave files or create lock/history/backup files. We don't want -;; copies of potentially sensitive material floating around, and we'll rely on -;; git and our own good fortune instead. Fingers crossed! +;; copies of potentially sensitive material floating around or polluting our +;; filesystem. We rely on git and our own good fortune instead. Fingers crossed! (setq auto-save-default nil create-lockfiles nil make-backup-files nil @@ -216,7 +216,7 @@ possible." (use-package! recentf ;; Keep track of recently opened files :defer-incrementally easymenu tree-widget timer - :after-call after-find-file + :hook (doom-first-file . recentf-mode) :commands recentf-open-files :config (defun doom--recent-file-truename (file) @@ -246,22 +246,20 @@ possible." "Add dired directory to recentf file list." (recentf-add-file default-directory))) - (when doom-interactive-mode - (add-hook 'kill-emacs-hook #'recentf-cleanup) - (quiet! (recentf-mode +1)))) + (add-hook 'kill-emacs-hook #'recentf-cleanup) + (advice-add #'recentf-load-list :around #'doom-shut-up-a)) (use-package! savehist ;; persist variables across sessions :defer-incrementally custom - :after-call post-command-hook + :hook (doom-first-input . savehist-mode) + :init + (setq savehist-file (concat doom-cache-dir "savehist")) :config - (setq savehist-file (concat doom-cache-dir "savehist") - savehist-save-minibuffer-history t + (setq savehist-save-minibuffer-history t savehist-autosave-interval nil ; save on kill only savehist-additional-variables '(kill-ring search-ring regexp-search-ring)) - (savehist-mode +1) - (add-hook! 'kill-emacs-hook (defun doom-unpropertize-kill-ring-h () "Remove text properties from `kill-ring' for a smaller savehist file." @@ -273,11 +271,11 @@ possible." (use-package! saveplace ;; persistent point location in buffers - :after-call after-find-file dired-initial-position-hook - :config + :hook (doom-first-file . save-place-mode) + :init (setq save-place-file (concat doom-cache-dir "saveplace") save-place-limit 100) - + :config (defadvice! doom--recenter-on-load-saveplace-a (&rest _) "Recenter on cursor when loading a saved place." :after-while #'save-place-find-file-hook @@ -293,9 +291,7 @@ possible." `pp' can be expensive for longer lists, and there's no reason to prettify cache files, so we replace calls to `pp' with the much faster `prin1'." :around #'save-place-alist-to-file - (letf! ((#'pp #'prin1)) (funcall orig-fn))) - - (save-place-mode +1)) + (letf! ((#'pp #'prin1)) (funcall orig-fn)))) (use-package! server @@ -314,7 +310,8 @@ files, so we replace calls to `pp' with the much faster `prin1'." ;;; Packages (use-package! better-jumper - :after-call pre-command-hook + :hook (doom-first-input . better-jumper-mode) + :hook (better-jumper-post-jump . recenter) :preface ;; REVIEW Suppress byte-compiler warning spawning a *Compile-Log* buffer at ;; startup. This can be removed once gilbertw1/better-jumper#2 is merged. @@ -324,17 +321,16 @@ files, so we replace calls to `pp' with the much faster `prin1'." (global-set-key [remap evil-jump-backward] #'better-jumper-jump-backward) (global-set-key [remap xref-pop-marker-stack] #'better-jumper-jump-backward) :config - (better-jumper-mode +1) - (add-hook 'better-jumper-post-jump-hook #'recenter) + (advice-add #'dired-find-file :before #'doom-set-jump-maybe-a) - (defadvice! doom-set-jump-a (orig-fn &rest args) + (defun doom-set-jump-a (orig-fn &rest args) "Set a jump point and ensure ORIG-FN doesn't set any new jump points." (better-jumper-set-jump (if (markerp (car args)) (car args))) (let ((evil--jumps-jumping t) (better-jumper--jumping t)) (apply orig-fn args))) - (defadvice! doom-set-jump-maybe-a (orig-fn &rest args) + (defun doom-set-jump-maybe-a (orig-fn &rest args) "Set a jump point if ORIG-FN returns non-nil." (let ((origin (point-marker)) (result @@ -441,7 +437,7 @@ files, so we replace calls to `pp' with the much faster `prin1'." (use-package! smartparens ;; Auto-close delimiters and blocks as you type. It's more powerful than that, ;; but that is all Doom uses it for. - :after-call doom-switch-buffer-hook after-find-file + :hook (doom-first-buffer . smartparens-global-mode) :commands sp-pair sp-local-pair sp-with-modes sp-point-in-comment sp-point-in-string :config ;; smartparens recognizes `slime-mrepl-mode', but not `sly-mrepl-mode', so... @@ -501,16 +497,12 @@ files, so we replace calls to `pp' with the much faster `prin1'." (defun doom-disable-smartparens-mode-maybe-h () (when smartparens-mode (setq-local doom-buffer-smartparens-mode t) - (turn-off-smartparens-mode)))) - - (smartparens-global-mode +1)) + (turn-off-smartparens-mode))))) (use-package! so-long - :after-call after-find-file + :hook (doom-first-file . global-so-long-mode) :config - (when doom-interactive-mode - (global-so-long-mode +1)) (setq so-long-threshold 400) ; reduce false positives w/ larger threshold ;; Don't disable syntax highlighting and line numbers, or make the buffer ;; read-only, in `so-long-minor-mode', so we can have a basic editing @@ -530,6 +522,7 @@ files, so we replace calls to `pp' with the much faster `prin1'." (appendq! so-long-minor-modes '(flycheck-mode flyspell-mode + spell-fu-mode eldoc-mode smartparens-mode highlight-numbers-mode @@ -560,8 +553,7 @@ files, so we replace calls to `pp' with the much faster `prin1'." (use-package! ws-butler ;; a less intrusive `delete-trailing-whitespaces' on save - :after-call after-find-file - :config (ws-butler-global-mode +1)) + :hook (doom-first-buffer . ws-butler-global-mode)) (provide 'core-editor) ;;; core-editor.el ends here diff --git a/core/core-keybinds.el b/core/core-keybinds.el index be5a93ce5..abe650a8f 100644 --- a/core/core-keybinds.el +++ b/core/core-keybinds.el @@ -179,8 +179,7 @@ localleader prefix." ;;; Packages (use-package! which-key - :defer 1 - :after-call pre-command-hook + :hook (doom-first-input . which-key-mode) :init (setq which-key-sort-order #'which-key-prefix-then-key-order which-key-sort-uppercase-first nil @@ -195,9 +194,7 @@ localleader prefix." (setq-hook! 'which-key-init-buffer-hook line-spacing 3) (which-key-add-key-based-replacements doom-leader-key "") - (which-key-add-key-based-replacements doom-localleader-key "") - - (which-key-mode +1)) + (which-key-add-key-based-replacements doom-localleader-key "")) ;; diff --git a/core/core-lib.el b/core/core-lib.el index 5f5d311e2..1e3dc6244 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -467,11 +467,19 @@ advised)." (put ',fn 'permanent-local-hook t) (add-hook sym #',fn ,append)))))) +(defmacro add-hook-trigger! (hook-var &rest targets) + "TODO" + `(let ((fn (intern (format "%s-h" ,hook-var)))) + (fset fn (lambda (&rest _) (run-hooks ,hook-var) (set ,hook-var nil))) + (put ,hook-var 'permanent-local t) + (dolist (on (list ,@targets)) + (if (functionp on) + (advice-add on :before fn) + (add-hook on fn))))) + (defmacro add-hook! (hooks &rest rest) "A convenience macro for adding N functions to M hooks. -If N and M = 1, there's no benefit to using this macro over `add-hook'. - This macro accepts, in order: 1. The mode(s) or hook(s) to add to. This is either an unquoted mode, an diff --git a/core/core-modules.el b/core/core-modules.el index b50fdd33c..db7104c25 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -71,6 +71,13 @@ before the user's private module.") ;; ;;; Bootstrap API +(defun doom-initialize-core-modules () + "Load Doom's core files for an interactive session." + (require 'core-keybinds) + (require 'core-ui) + (require 'core-projects) + (require 'core-editor)) + (defun doom-initialize-modules (&optional force-p) "Loads the init.el in `doom-private-dir' and sets up hooks for a healthy session of Dooming. Will noop if used more than once, unless FORCE-P is @@ -78,16 +85,18 @@ non-nil." (when (or force-p (not doom-init-modules-p)) (setq doom-init-modules-p t doom-modules nil) - (load custom-file 'noerror 'nomessage) - (when (load! "init" doom-private-dir t) - (when doom-modules - (maphash (lambda (key plist) - (let ((doom--current-module key) - (doom--current-flags (plist-get plist :flags))) - (load! "init" (plist-get plist :path) t))) - doom-modules)) - (run-hook-wrapped 'doom-before-init-modules-hook #'doom-try-run-hook) - (when doom-interactive-mode + (with-temp-buffer + (doom-log "Initializing core modules") + (doom-initialize-core-modules) + (when-let (init-p (load! "init" doom-private-dir t)) + (doom-log "Initializing user config") + (when doom-modules + (maphash (lambda (key plist) + (let ((doom--current-module key) + (doom--current-flags (plist-get plist :flags))) + (load! "init" (plist-get plist :path) t))) + doom-modules)) + (run-hook-wrapped 'doom-before-init-modules-hook #'doom-try-run-hook) (when doom-modules (maphash (lambda (key plist) (let ((doom--current-module key) @@ -95,7 +104,8 @@ non-nil." (load! "config" (plist-get plist :path) t))) doom-modules)) (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) - (load! "config" doom-private-dir t))))) + (load! "config" doom-private-dir t) + (load custom-file 'noerror (not doom-debug-mode)))))) ;; @@ -122,15 +132,17 @@ non-nil." of PROPERTY and VALUEs. \(fn CATEGORY MODULE PROPERTY VALUE &rest [PROPERTY VALUE [...]])" - (if-let (old-plist (doom-module-get category module)) - (progn - (when plist - (when (cl-oddp (length plist)) - (signal 'wrong-number-of-arguments (list (length plist)))) - (while plist - (plist-put old-plist (pop plist) (pop plist)))) - (puthash (cons category module) old-plist doom-modules)) - (puthash (cons category module) plist doom-modules))) + (puthash (cons category module) + (if-let (old-plist (doom-module-get category module)) + (if (null plist) + old-plist + (when (cl-oddp (length plist)) + (signal 'wrong-number-of-arguments (list (length plist)))) + (while plist + (plist-put old-plist (pop plist) (pop plist))) + old-plist) + plist) + doom-modules)) (defun doom-module-set (category module &rest plist) "Enables a module by adding it to `doom-modules'. @@ -223,18 +235,21 @@ those directories. The first returned path is always `doom-private-dir'." collect (plist-get plist :path))) nil)) -(defun doom-modules (&optional refresh-p) +(defun doom-module-list (&optional all-p) "Minimally initialize `doom-modules' (a hash table) and return it. This value is cached. If REFRESH-P, then don't use the cached value." - (or (unless refresh-p doom-modules) - (let (doom-interactive-mode - doom-modules - doom-init-modules-p) - (load! "init" doom-private-dir t) - (or doom-modules - (make-hash-table :test 'equal - :size 20 - :rehash-threshold 1.0))))) + (if all-p + (cl-loop for path in (cdr (doom-module-load-path 'all)) + collect (doom-module-from-path path)) + (or doom-modules + (let (doom-interactive-mode + doom-modules + doom-init-modules-p) + (load! "init" doom-private-dir t) + (or doom-modules + (make-hash-table :test 'equal + :size 20 + :rehash-threshold 1.0)))))) ;; @@ -375,8 +390,8 @@ for a list of all recognized module trees. Order defines precedence (from most to least)." `(let ((modules ,@(if (keywordp (car modules)) - (list (list 'quote modules)) - modules))) + (list (list 'quote modules)) + modules))) (unless doom-modules (setq doom-modules (make-hash-table :test 'equal diff --git a/core/core-packages.el b/core/core-packages.el index 1ad951a37..bbcbfd1de 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -30,43 +30,20 @@ ;; `doom-core-dir'. These contain `package!' declarations that tell DOOM what ;; plugins to install and where from. ;; -;; All that said, you can still use package.el's commands, but 'bin/doom -;; refresh' will purge ELPA packages. - -(defvar doom-init-packages-p nil - "If non-nil, Doom's package management system has been initialized.") +;; All that said, you can still use package.el's commands, but 'bin/doom sync' +;; will purge ELPA packages. (defvar doom-packages () "A list of enabled packages. Each element is a sublist, whose CAR is the package's name as a symbol, and whose CDR is the plist supplied to its `package!' declaration. Set by `doom-initialize-packages'.") -(defvar doom-core-packages '(straight use-package) - "A list of packages that must be installed (and will be auto-installed if -missing) and shouldn't be deleted.") - -(defvar doom-core-package-sources - '((org-elpa :local-repo nil) - (melpa - :type git :host github - :repo "melpa/melpa" - :no-build t) - (gnu-elpa-mirror - :type git :host github - :repo "emacs-straight/gnu-elpa-mirror" - :no-build t) - (emacsmirror-mirror - :type git :host github - :repo "emacs-straight/emacsmirror-mirror" - :no-build t)) - "A list of recipes for straight's recipe repos.") - (defvar doom-disabled-packages () "A list of packages that should be ignored by `use-package!' and `after!'.") ;; -;;; Package managers +;;; package.el ;; Ensure that, if we do need package.el, it is configured correctly. You really ;; shouldn't be using it, but it may be convenient for quick package testing. @@ -94,7 +71,7 @@ missing) and shouldn't be deleted.") ;;; Straight (setq straight-base-dir doom-local-dir - straight-repository-branch "master" + straight-repository-branch "develop" straight-cache-autoloads nil ; we already do this, and better. ;; Doom doesn't encourage you to modify packages in place. Disabling this ;; makes 'doom sync' instant (once everything set up), which is much nicer @@ -123,81 +100,305 @@ missing) and shouldn't be deleted.") ;; -;;; Bootstrapper +;;; Bootstrappers + +(defun doom-initialize-core-packages (&optional force-p) + "Ensure `straight' is installed and was compiled with this version of Emacs." + (when (or force-p (null (bound-and-true-p straight-recipe-repositories))) + (doom-log "Initializing straight") + (cl-destructuring-bind (&key pin recipe &allow-other-keys) + (let ((doom-packages (doom-package-list nil 'core-only))) + (doom-package-get 'straight)) + (let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el")) + (repo-url (concat "http" (if gnutls-verify-error "s") + "://github.com/" + (or (plist-get recipe :repo) "raxod502/straight.el"))) + (branch (or (plist-get recipe :branch) straight-repository-branch)) + (call (if doom-debug-mode #'doom-exec-process #'doom-call-process))) + (if (not (file-directory-p repo-dir)) + (message "Installing straight...") + ;; TODO Rethink this clumsy workaround + (let ((default-directory repo-dir)) + (unless (equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) pin) + (delete-directory repo-dir 'recursive) + (message "Updating straight...")))) + (unless (file-directory-p repo-dir) + (cond + ((eq straight-vc-git-default-clone-depth 'full) + (funcall call "git" "clone" "--origin" "origin" repo-url repo-dir)) + ((null pin) + (funcall call "git" "clone" "--origin" "origin" repo-url repo-dir + "--depth" (number-to-string straight-vc-git-default-clone-depth) + "--branch" straight-repository-branch)) + ((integerp straight-vc-git-default-clone-depth) + (make-directory repo-dir t) + (let ((default-directory repo-dir)) + (funcall call "git" "init") + (funcall call "git" "checkout" "-b" straight-repository-branch) + (funcall call "git" "remote" "add" "origin" repo-url) + (funcall call "git" "fetch" "origin" pin + "--depth" (number-to-string straight-vc-git-default-clone-depth)) + (funcall call "git" "checkout" "--detach" pin))))) + (require 'straight (concat repo-dir "/straight.el")) + (doom-log "Initializing recipes") + (with-temp-buffer + (insert-file-contents (doom-path repo-dir "bootstrap.el")) + ;; Don't install straight for us -- we've already done that -- only set + ;; up its recipe repos for us. + (eval-region (search-forward "(require 'straight)") + (point-max))))))) (defun doom-initialize-packages (&optional force-p) - "Ensures that Doom's package system and straight.el are initialized. + "Process all packages, essential and otherwise, if they haven't already been. If FORCE-P is non-nil, do it anyway. -This ensure `doom-packages' is populated, if isn't aren't already. Use this -before any of straight's or Doom's package management's API to ensure all the -necessary package metadata is initialized and available for them." - (unless doom-init-packages-p - (setq force-p t)) +This ensures `doom-packages' is populated and `straight' recipes are properly +processed." + (doom-initialize-core-packages force-p) (when (or force-p (not (bound-and-true-p package--initialized))) (doom-log "Initializing package.el") (require 'package) - (package-initialize)) - (when (or force-p (not doom-packages)) - (doom-log "Initializing straight") - (setq doom-init-packages-p t) - (doom-ensure-straight) - (mapc #'straight-use-package doom-core-packages) - (doom-log "Initializing doom-packages") - (setq doom-disabled-packages nil - doom-pinned-packages nil - doom-packages (doom-package-list)) + (package-initialize) + (unless package--initialized + (error "Failed to initialize package.el"))) + (when (or force-p (null doom-packages)) + (doom-log "Initializing straight.el") + (or (setq doom-disabled-packages nil + doom-packages (doom-package-list)) + (error "Failed to read any packages")) (dolist (package doom-packages) - (let ((name (car package))) - (with-plist! (cdr package) (recipe modules disable ignore pin) - (if ignore - (doom-log "Ignoring package %S" name) - (if (not disable) - (with-demoted-errors "Package error: %s" - (when recipe - (straight-override-recipe (cons name recipe))) - (straight-register-package name)) - (doom-log "Disabling package %S" name) + (cl-destructuring-bind + (name &key recipe disable ignore &allow-other-keys) package + (unless ignore + (if disable (cl-pushnew name doom-disabled-packages) - ;; Warn about disabled core packages - (when (cl-find :core modules :key #'car) - (print! (warn "%s\n%s") - (format "You've disabled %S" name) - (indent 2 (concat "This is a core package. Disabling it will cause errors, as Doom assumes\n" - "core packages are always available. Disable their minor-modes or hooks instead."))))))))))) + (when recipe + (straight-override-recipe (cons name recipe))) + (straight-register-package name))))))) -(defun doom-ensure-straight () - "Ensure `straight' is installed and was compiled with this version of Emacs." - (unless (fboundp 'straight--reset-caches) - (defvar bootstrap-version) - (let* (;; Force straight to install into ~/.emacs.d/.local/straight instead of - ;; ~/.emacs.d/straight by pretending `doom-local-dir' is our .emacs.d. - (user-emacs-directory straight-base-dir) - (bootstrap-file (doom-path straight-base-dir "straight/repos/straight.el/straight.el")) - (bootstrap-version 5)) - (make-directory (doom-path straight-base-dir "straight/build") 'parents) - (or (require 'straight nil t) - (file-readable-p bootstrap-file) - (with-current-buffer - (url-retrieve-synchronously - (format "https://raw.githubusercontent.com/raxod502/straight.el/%s/install.el" - straight-repository-branch) - 'silent 'inhibit-cookies) - (goto-char (point-max)) - (eval-print-last-sexp))) - (load bootstrap-file nil t)) - (require 'straight)) - (straight--reset-caches) - (setq straight-recipe-repositories nil - straight-recipe-overrides nil) - (mapc #'straight-use-recipes doom-core-package-sources) - (straight-register-package - `(straight :type git :host github - :repo ,(format "%s/straight.el" straight-repository-user) - :files ("straight*.el") - :branch ,straight-repository-branch - :no-byte-compile t))) + +;; +;;; Package management API + +(defun doom-package-get (package &optional prop nil-value) + "Returns PACKAGE's `package!' recipe from `doom-packages'." + (let ((plist (cdr (assq package doom-packages)))) + (if prop + (if (plist-member plist prop) + (plist-get plist prop) + nil-value) + plist))) + +(defun doom-package-set (package prop value) + "Set PROPERTY in PACKAGE's recipe to VALUE." + (setf (alist-get package doom-packages) + (plist-put (alist-get package doom-packages) + prop value))) + +(defun doom-package-recipe (package &optional prop nil-value) + "Returns the `straight' recipe PACKAGE was registered with." + (let ((plist (gethash (symbol-name package) straight--recipe-cache))) + (if prop + (if (plist-member plist prop) + (plist-get plist prop) + nil-value) + plist))) + +(defun doom-package-recipe-repo (package) + "Resolve and return PACKAGE's (symbol) local-repo property." + (if-let* ((recipe (cdr (straight-recipes-retrieve package))) + (repo (straight-vc-local-repo-name recipe))) + repo + (symbol-name package))) + +(defun doom-package-build-recipe (package &optional prop nil-value) + "Returns the `straight' recipe PACKAGE was installed with." + (let ((plist (nth 2 (gethash (symbol-name package) straight--build-cache)))) + (if prop + (if (plist-member plist prop) + (plist-get plist prop) + nil-value) + plist))) + +(defun doom-package-build-time (package) + "TODO" + (car (gethash (symbol-name package) straight--build-cache))) + +(defun doom-package-dependencies (package &optional recursive _noerror) + "Return a list of dependencies for a package." + (let ((deps (nth 1 (gethash (symbol-name package) straight--build-cache)))) + (if recursive + (append deps (mapcan (lambda (dep) (doom-package-dependencies dep t t)) + (copy-sequence deps))) + (copy-sequence deps)))) + +(defun doom-package-depending-on (package &optional noerror) + "Return a list of packages that depend on the package named NAME." + (cl-check-type name symbol) + ;; can't get dependencies for built-in packages + (unless (or (doom-package-build-recipe name) + noerror) + (error "Couldn't find %s, is it installed?" name)) + (cl-loop for pkg in (hash-table-keys straight--build-cache) + for deps = (doom-package-dependencies pkg) + if (memq package deps) + collect pkg + and append (doom-package-depending-on pkg t))) + + +;;; Predicate functions +(defun doom-package-built-in-p (package) + "Return non-nil if PACKAGE (a symbol) is built-in." + (eq (doom-package-build-recipe package :type) + 'built-in)) + +(defun doom-package-installed-p (package) + "Return non-nil if PACKAGE (a symbol) is installed." + (file-directory-p (straight--build-dir (symbol-name package)))) + +(defun doom-package-is-type-p (package type) + "TODO" + (memq type (doom-enlist (doom-package-get package :type)))) + +(defun doom-package-in-module-p (package category &optional module) + "Return non-nil if PACKAGE was installed by the user's private config." + (when-let (modules (doom-package-get package :modules)) + (or (and (not module) (assq :private modules)) + (member (cons category module) modules)))) + +(defun doom-package-backend (package) + "Return 'straight, 'builtin, 'elpa or 'other, depending on how PACKAGE is +installed." + (cond ((gethash (symbol-name package) straight--build-cache) + 'straight) + ((or (doom-package-built-in-p package) + (assq package package--builtins)) + 'builtin) + ((assq package package-alist) + 'elpa) + ((locate-library (symbol-name package)) + 'other))) + +(defun doom-package-changed-recipe-p (name) + "Return t if a package named NAME (a symbol) has a different recipe than it +was installed with." + (cl-check-type name symbol) + ;; TODO + ;; (when (doom-package-installed-p name) + ;; (when-let* ((doom-recipe (assq name doom-packages)) + ;; (install-recipe (doom-package-recipe))) + ;; (not (equal (cdr quelpa-recipe) + ;; (cdr (plist-get (cdr doom-recipe) :recipe)))))) + ) + + +;;; Package getters +(defun doom--read-packages (file &optional noeval noerror) + (condition-case-unless-debug e + (with-temp-buffer ; prevent buffer-local state from propagating + (if (not noeval) + (load file noerror 'nomessage 'nosuffix) + (when (file-exists-p file) + (insert-file-contents file) + (let (emacs-lisp-mode) (emacs-lisp-mode)) + ;; Scrape `package!' blocks from FILE for a comprehensive listing of + ;; packages used by this module. + (while (search-forward "(package! " nil t) + (goto-char (match-beginning 0)) + (let ((ppss (save-excursion (syntax-ppss)))) + ;; Don't collect packages in comments or strings + (or (nth 3 ppss) + (nth 4 ppss) + (cl-destructuring-bind (_ name . plist) + (read (current-buffer)) + (push (cons + name (plist-put + plist :modules + (list (doom-module-from-path file)))) + doom-packages)))))))) + (error + (signal 'doom-package-error + (list (doom-module-from-path file) + file e))))) + +(defun doom-package-list (&optional all-p core-only-p) + "Retrieve a list of explicitly declared packages from enabled modules. + +If ALL-P, gather packages unconditionally across all modules, including disabled +ones." + (let ((doom-interactive-mode t) + doom-packages) + (doom--read-packages + (doom-path doom-core-dir "packages.el") all-p 'noerror) + (unless core-only-p + (let ((private-packages (doom-path doom-private-dir "packages.el")) + (doom-modules (doom-module-list))) + (if all-p + (mapc #'doom--read-packages + (doom-files-in doom-modules-dir + :depth 2 + :match "/packages\\.el$")) + ;; We load the private packages file twice to ensure disabled packages + ;; are seen ASAP, and a second time to ensure privately overridden + ;; packages are properly overwritten. + (doom--read-packages private-packages nil 'noerror) + (cl-loop for key being the hash-keys of doom-modules + for path = (doom-module-path (car key) (cdr key) "packages.el") + for doom--current-module = key + do (doom--read-packages path nil 'noerror))) + (doom--read-packages private-packages all-p 'noerror))) + (reverse doom-packages))) + +(defun doom-package-pinned-list () + "Return an alist mapping package names (strings) to pinned commits (strings)." + (let (alist) + (dolist (package doom-packages alist) + (cl-destructuring-bind (name &key disable ignore pin unpin &allow-other-keys) + package + (when (and (not ignore) + (not disable) + (or pin unpin)) + (setf (alist-get (doom-package-recipe-repo name) alist + nil 'remove #'equal) + (unless unpin pin))))))) + +(defun doom-package-unpinned-list () + "Return an alist mapping package names (strings) to pinned commits (strings)." + (let (alist) + (dolist (package doom-packages alist) + (cl-destructuring-bind + (_ &key recipe disable ignore pin unpin &allow-other-keys) + package + (when (and (not ignore) + (not disable) + (or unpin + (and (plist-member recipe :pin) + (null pin)))) + (cl-pushnew (doom-package-recipe-repo (car package)) alist + :test #'equal)))))) + +(defun doom-package-recipe-list () + "Return straight recipes for non-builtin packages with a local-repo." + (let (recipes) + (dolist (recipe (hash-table-values straight--recipe-cache)) + (cl-destructuring-bind (&key local-repo type no-build &allow-other-keys) + recipe + (unless (or (null local-repo) + (eq type 'built-in) + no-build) + (push recipe recipes)))) + (nreverse recipes))) + +(defun doom-package-state-list () + "TODO" + (let (alist) + (dolist (recipe (hash-table-values straight--repo-cache) alist) + (cl-destructuring-bind (&key local-repo type &allow-other-keys) + recipe + (when (and local-repo (not (eq type 'built-in))) + (setf (alist-get local-repo alist nil nil #'equal) + (straight-vc-get-commit type local-repo))))))) ;; @@ -254,6 +455,8 @@ elsewhere." (plist-put! plist :modules (append module-list (list module) + (when (file-in-directory-p ,(dir!) doom-private-dir) + '((:private . modules))) nil)))) ;; Merge given plist with pre-existing one (doplist! ((prop val) (list ,@plist) plist) @@ -282,8 +485,9 @@ elsewhere." (error-message-string e))))) ;; This is the only side-effect of this macro! (setf (alist-get name doom-packages) plist) - (with-no-warnings - (not (plist-get plist :disable))))) + (unless (plist-get plist :disable) + (with-no-warnings + (cons name plist))))) (defmacro disable-packages! (&rest packages) "A convenience macro for disabling packages in bulk. @@ -311,24 +515,26 @@ should use it!" (if (memq t targets) `(mapc (doom-rpartial #'doom-package-set :unpin t) (mapcar #'car doom-packages)) - (let (forms) - (dolist (target targets) - (cl-check-type target (or symbol keyword list)) - (cond - ((symbolp target) - (push `(doom-package-set ',target :unpin t) forms)) - ((or (keywordp target) - (listp target)) - (cl-destructuring-bind (category . modules) (doom-enlist target) - (dolist (pkg doom-packages) - (let ((pkg-modules (plist-get (cdr pkg) :modules))) - (and (assq category pkg-modules) - (or (null modules) - (cl-loop for module in modules - if (member (cons category module) pkg-modules) - return t)) - (push `(doom-package-set ',(car pkg) :unpin t) forms)))))))) - (macroexp-progn forms)))) + (macroexp-progn + (mapcar + (lambda (target) + (when target + `(doom-package-set ',target :unpin t))) + (cl-loop for target in targets + if (or (keywordp target) (listp target)) + append + (cl-loop with (category . modules) = (doom-enlist target) + for (name . plist) in doom-packages + for pkg-modules = (plist-get plist :modules) + if (and (assq category pkg-modules) + (or (null modules) + (cl-loop for module in modules + if (member (cons category module) pkg-modules) + return t)) + name) + collect it) + else if (symbolp target) + collect target))))) (provide 'core-packages) ;;; core-packages.el ends here diff --git a/core/core-projects.el b/core/core-projects.el index 14ba77ac4..dff3aec43 100644 --- a/core/core-projects.el +++ b/core/core-projects.el @@ -20,7 +20,6 @@ Emacs.") ;;; Packages (use-package! projectile - :after-call after-find-file dired-before-readin-hook minibuffer-setup-hook :commands (projectile-project-root projectile-project-name projectile-project-p diff --git a/core/core-ui.el b/core/core-ui.el index 9b590b668..ea788cd97 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -443,9 +443,10 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (use-package! winner ;; undo/redo changes to Emacs' window layout - :after-call after-find-file doom-switch-window-hook + :hook (window-configuration-change . winner-mode) :preface (defvar winner-dont-bind-my-keys t) ; I'll bind keys myself - :config (winner-mode +1) + :config + (remove-hook 'window-configuration-change #'winner-mode) (appendq! winner-boring-buffers '("*Compile-Log*" "*inferior-lisp*" "*Fuzzy Completions*" "*Apropos*" "*Help*" "*cvs*" "*Buffer List*" "*Ibuffer*" @@ -454,13 +455,12 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (use-package! paren ;; highlight matching delimiters - :after-call after-find-file doom-switch-buffer-hook + :hook (doom-first-buffer . show-paren-mode) :config (setq show-paren-delay 0.1 show-paren-highlight-openparen t show-paren-when-point-inside-paren t - show-paren-when-point-in-periphery t) - (show-paren-mode +1)) + show-paren-when-point-in-periphery t)) ;;;###package whitespace diff --git a/core/core.el b/core/core.el index f4d5aa9c6..aea4ac635 100644 --- a/core/core.el +++ b/core/core.el @@ -1,8 +1,9 @@ ;;; core.el --- the heart of the beast -*- lexical-binding: t; -*- -(when (version< emacs-version "26.1") - (error "Detected Emacs %s. Doom only supports Emacs 26.1 and higher" - emacs-version)) +(eval-when-compile + (when (< emacs-major-version 26) + (error "Detected Emacs v%s. Doom only supports Emacs 26 and newer" + emacs-version))) (defconst doom-version "2.0.9" "Current version of Doom Emacs.") @@ -195,7 +196,7 @@ users).") ;; Emacs "updates" its ui more often than it needs to, so we slow it down ;; slightly from 0.5s: -(setq idle-update-delay 1) +(setq idle-update-delay 1.0) ;; Emacs is essentially one huge security vulnerability, what with all the ;; dependencies it pulls in from all corners of the globe. Let's try to be at @@ -306,15 +307,13 @@ users).") ;; Adopt a sneaky garbage collection strategy of waiting until idle time to ;; collect; staving off the collector while the user is working. -(when doom-interactive-mode - (setq gcmh-idle-delay 5 - gcmh-high-cons-threshold 16777216 ; 16mb - gcmh-verbose doom-debug-mode - gc-cons-percentage 0.6) - (add-transient-hook! 'pre-command-hook (gcmh-mode +1)) - (with-eval-after-load 'gcmh - (setq gc-cons-percentage 0.1) - (add-hook 'focus-out-hook #'gcmh-idle-garbage-collect))) +(setq gcmh-idle-delay 5 + gcmh-high-cons-threshold 16777216 ; 16mb + gcmh-verbose doom-debug-mode + gc-cons-percentage 0.6) +(with-eval-after-load 'gcmh + ;; But restore this later, otherwise we risk freezing and stuttering! + (setq gc-cons-percentage 0.1)) ;; HACK `tty-run-terminal-initialization' is *tremendously* slow for some ;; reason. Disabling it completely could have many side-effects, so we @@ -337,18 +336,14 @@ users).") "Run MODE-local-vars-hook after local variables are initialized." (run-hook-wrapped (intern-soft (format "%s-local-vars-hook" major-mode)) #'doom-try-run-hook)) -(add-hook 'hack-local-variables-hook #'doom-run-local-var-hooks-h) ;; If the user has disabled `enable-local-variables', then ;; `hack-local-variables-hook' is never triggered, so we trigger it at the end ;; of `after-change-major-mode-hook': -(defun doom-run-local-var-hooks-if-necessary-h () +(defun doom-run-local-var-hooks-maybe-h () "Run `doom-run-local-var-hooks-h' if `enable-local-variables' is disabled." (unless enable-local-variables (doom-run-local-var-hooks-h))) -(add-hook 'after-change-major-mode-hook - #'doom-run-local-var-hooks-if-necessary-h - 'append) ;; @@ -427,7 +422,18 @@ If this is a daemon session, load them all immediately instead." nil #'doom-load-packages-incrementally (cdr doom-incremental-packages) t)))) -(add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h) + +;; +;;; Custom hooks + +(defvar doom-first-input-hook nil + "Transient hooks run before the first user input.") + +(defvar doom-first-file-hook nil + "Transient hooks run before the first interactively opened file.") + +(defvar doom-first-buffer-hook nil + "Transient hooks run before the first interactively opened buffer.") ;; @@ -445,7 +451,7 @@ If RETURN-P, return the message as a string instead of displaying it." (setq doom-init-time (float-time (time-subtract (current-time) before-init-time)))))) -(defun doom-initialize (&optional force-p noerror) +(defun doom-initialize (&optional force-p) "Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil). The bootstrap process ensures that the essential directories exist, all core @@ -473,6 +479,7 @@ for a list of all recognized module trees. Order defines precedence (from most to least)." (when (or force-p (not doom-init-p)) (setq doom-init-p t) + (doom-log "Initializing Doom") ;; Reset as much state as possible, so `doom-initialize' can be treated like ;; a reset function. e.g. when reloading the config. @@ -480,70 +487,51 @@ to least)." load-path doom--initial-load-path process-environment doom--initial-process-environment) - ;; Load shell environment, optionally generated from 'doom env'. No need to - ;; do so if we're in terminal Emacs, because Emacs will correctly inherit + (or (and + ;; `doom-autoload-file' tells Emacs where to load all its functions + ;; from. This includes everything in core/autoload/*.el and + ;; autoload files in enabled modules. + (or (doom-load-autoloads-file doom-autoload-file) + (ignore (warn "Doom's core autoloads file is missing"))) + ;; Loads `doom-package-autoload-file', which loads a concatenated + ;; package autoloads file which caches `load-path', + ;; `auto-mode-alist', `Info-directory-list', and + ;; `doom-disabled-packages'. A big reduction in startup time. + (or (doom-load-autoloads-file doom-package-autoload-file) + (ignore (warn "Doom's package autoloads file is missing")))) + (signal 'doom-error + (list "Doom is in an incomplete state" + "run 'bin/doom sync' on the command line to repair it"))) + + ;; Load shell environment, optionally generated from 'doom env'. No need + ;; to do so if we're in terminal Emacs, where Emacs correctly inherits ;; your shell environment there. - (when (and (or (display-graphic-p) - (daemonp)) - (file-exists-p doom-env-file)) - (doom-load-envvars-file doom-env-file)) + (and (or (display-graphic-p) + (daemonp)) + (doom-load-envvars-file doom-env-file 'noerror)) (require 'core-modules) - (let (;; `doom-autoload-file' tells Emacs where to load all its functions - ;; from. This includes everything in core/autoload/*.el and autoload - ;; files in enabled modules. - (core-autoloads-p (doom-load-autoloads-file doom-autoload-file noerror)) - ;; Loads `doom-package-autoload-file', which loads a concatenated - ;; package autoloads file which caches `load-path', `auto-mode-alist', - ;; `Info-directory-list', and `doom-disabled-packages'. A big - ;; reduction in startup time. - (pkg-autoloads-p (doom-load-autoloads-file doom-package-autoload-file noerror))) + (autoload 'doom-initialize-packages "core-packages") + (autoload 'doom-initialize-core-packages "core-packages") - (if (and core-autoloads-p pkg-autoloads-p (not force-p)) - ;; In case we want to use package.el or straight via M-x - (progn - (with-eval-after-load 'package - (require 'core-packages)) - (with-eval-after-load 'straight - (require 'core-packages) - (doom-initialize-packages))) + ;; In case we want to use package.el or straight via M-x + (with-eval-after-load 'package (require 'core-packages)) + (with-eval-after-load 'straight (doom-initialize-packages)) - ;; Eagerly load these libraries because we may be in a session that hasn't been - ;; fully initialized (e.g. where autoloads files haven't been generated or - ;; `load-path' populated). - (mapc (doom-rpartial #'load nil (not doom-debug-mode) 'nosuffix) - (file-expand-wildcards (concat doom-core-dir "autoload/*.el"))) + ;; Bootstrap interactive session + (add-hook! 'window-setup-hook + (add-hook 'hack-local-variables-hook #'doom-run-local-var-hooks-h) + (add-hook 'after-change-major-mode-hook #'doom-run-local-var-hooks-maybe-h 'append) + (add-hook 'doom-first-input-hook #'gcmh-mode) + (add-hook-trigger! 'doom-first-input-hook 'pre-command-hook) + (add-hook-trigger! 'doom-first-file-hook 'after-find-hook 'dired-initial-position-hook) + (add-hook-trigger! 'doom-first-buffer-hook 'after-find-hook 'doom-switch-buffer-hook)) + (add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h) + (add-hook 'window-setup-hook #'doom-display-benchmark-h 'append) - ;; Create all our core directories to quell file errors - (mapc (doom-rpartial #'make-directory 'parents) - (list doom-local-dir - doom-etc-dir - doom-cache-dir)) + (doom-initialize-modules force-p)) - ;; Ensure the package management system (and straight) are ready for - ;; action (and all core packages/repos are installed) - (require 'core-packages) - (doom-initialize-packages force-p)) - - (unless (or (and core-autoloads-p pkg-autoloads-p) - noerror) - (unless core-autoloads-p - (warn "Your Doom core autoloads file is missing")) - (unless pkg-autoloads-p - (warn "Your package autoloads file is missing")) - (signal 'doom-autoload-error (list "Run `bin/doom refresh' to generate them"))) - - (when doom-interactive-mode - (add-hook 'window-setup-hook #'doom-display-benchmark-h 'append) - (add-to-list 'command-switch-alist (cons "--restore" #'doom-restore-session-handler)))) - t)) - -(defun doom-initialize-core () - "Load Doom's core files for an interactive session." - (require 'core-keybinds) - (require 'core-ui) - (require 'core-projects) - (require 'core-editor)) + doom-init-p) (provide 'core) ;;; core.el ends here diff --git a/core/packages.el b/core/packages.el index 986d1459a..fba82b326 100644 --- a/core/packages.el +++ b/core/packages.el @@ -5,6 +5,22 @@ (package! auto-minor-mode :pin "17cfa1b54800fdef2975c0c0531dad34846a5065") (package! gcmh :pin "b1bde5089169a74f62033d027e06e98cbeedd43f") +;; core-packages.el +(package! straight + ;; :type 'core + :recipe `(:host github + :repo "raxod502/straight.el" + :branch ,straight-repository-branch + :local-repo "straight.el" + :files ("straight*.el") + :no-build t) + :pin "f606bfaf9330cfb1ef6971bb1f6ac4e2c39a39c2") + +;; core-modules.el +(package! use-package + ;; :type 'core + :pin "c873d5529c9c80cb58222f22873a4f081c307cb2") + ;; core-ui.el (package! all-the-icons :pin "d6cb6d4a779eaa3570d8e451fd4d38b2b4554860") (package! hide-mode-line :pin "88888825b5b27b300683e662fa3be88d954b1cea") diff --git a/init.el b/init.el index 13ed45647..78a37fc54 100644 --- a/init.el +++ b/init.el @@ -47,7 +47,3 @@ ;; And let 'er rip! (doom-initialize) -(if noninteractive - (doom-initialize-packages) - (doom-initialize-core) - (doom-initialize-modules)) diff --git a/modules/checkers/syntax/config.el b/modules/checkers/syntax/config.el index f6c52c0a1..9d9ab1049 100644 --- a/modules/checkers/syntax/config.el +++ b/modules/checkers/syntax/config.el @@ -5,7 +5,7 @@ (use-package! flycheck :commands flycheck-list-errors flycheck-buffer - :after-call doom-switch-buffer-hook after-find-file + :hook (doom-first-buffer . global-flycheck-mode) :config (setq flycheck-emacs-lisp-load-path 'inherit) @@ -39,9 +39,7 @@ :n "j" #'flycheck-error-list-next-error :n "k" #'flycheck-error-list-previous-error :n "RET" #'flycheck-error-list-goto-error - :n [return] #'flycheck-error-list-goto-error) - - (global-flycheck-mode +1)) + :n [return] #'flycheck-error-list-goto-error)) (use-package! flycheck-popup-tip diff --git a/modules/completion/helm/config.el b/modules/completion/helm/config.el index 66e8d7b9a..24d3175c9 100644 --- a/modules/completion/helm/config.el +++ b/modules/completion/helm/config.el @@ -23,8 +23,7 @@ be negative.") ;;; Packages (use-package! helm-mode - :defer t - :after-call pre-command-hook + :hook (doom-first-input . helm-mode) :init (map! [remap apropos] #'helm-apropos [remap find-library] #'helm-locate-library @@ -43,7 +42,6 @@ be negative.") [remap recentf-open-files] #'helm-recentf [remap yank-pop] #'helm-show-kill-ring) :config - (helm-mode +1) ;; helm is too heavy for `find-file-at-point' (add-to-list 'helm-completing-read-handlers-alist (cons #'find-file-at-point nil))) diff --git a/modules/completion/ido/config.el b/modules/completion/ido/config.el index 22de041ae..5f0cb880b 100644 --- a/modules/completion/ido/config.el +++ b/modules/completion/ido/config.el @@ -8,12 +8,12 @@ ;;; Packages (use-package! ido - :after-call pre-command-hook + :hook (doom-first-input . ido-mode) :hook (ido-mode . ido-everywhere) :hook (ido-mode . ido-ubiquitous-mode) :preface ;; HACK `ido' is a really old package. It defines `ido-mode' manually and - ;; doesn't define a hook, so we define one for it.") + ;; doesn't define a hook, so we define one for it, so we can use it! (defadvice! +ido-run-hooks-a (&rest _) :after #'ido-mode (run-hooks 'ido-mode-hook)) @@ -42,9 +42,7 @@ ;; Go to $HOME with ~ "~" (λ! (if (looking-back "/" (point-min)) (insert "~/") - (call-interactively #'self-insert-command)))) - - (ido-mode +1)) + (call-interactively #'self-insert-command))))) (use-package! ido-vertical-mode diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index f9dcab6c6..874181aa3 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -19,7 +19,7 @@ results buffer.") ;;; Packages (use-package! ivy - :after-call pre-command-hook + :hook (doom-first-input . ivy-mode) :init (let ((standard-search-fn (if (featurep! +prescient) @@ -98,12 +98,10 @@ evil-ex-specific constructs, so we disable it solely in evil-ex." (apply orig-fn args))) (define-key! ivy-minibuffer-map - "C-c C-e" #'+ivy/woccur [remap doom/delete-backward-word] #'ivy-backward-kill-word + "C-c C-e" #'+ivy/woccur "C-o" #'ivy-dispatching-done - "M-o" #'hydra-ivy/body) - - (ivy-mode +1)) + "M-o" #'hydra-ivy/body)) (use-package! ivy-rich diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 7d34f4001..ef7b512bc 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -432,7 +432,19 @@ relative to `org-directory', unless it is an absolute path." (setq org-pandoc-options '((standalone . t) (mathjax . t) - (variable . "revealjs-url=https://revealjs.com"))))) + (variable . "revealjs-url=https://revealjs.com")))) + + (defadvice! +org--fix-async-export-a (orig-fn &rest args) + :around #'org-export-to-file + (if (not org-export-in-background) + (apply orig-fn args) + (setq org-export-async-init-file (make-temp-file "doom-org-async-export")) + (with-temp-file org-export-async-init-file + (prin1 `(progn (setq org-export-async-debug ,debug-on-error + load-path ',load-path) + (load ,user-init-file nil t)) + (current-buffer))) + (apply orig-fn args)))) (defun +org-init-habit-h () From c6820797836f5a47cecce131150f58762c0c31bf Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 16:31:08 -0400 Subject: [PATCH 069/103] doom/doctor: warn about 28+, not 27+ 27 is now the recommended version for Doom. --- core/cli/doctor.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cli/doctor.el b/core/cli/doctor.el index a394d2965..bcc02fa43 100644 --- a/core/cli/doctor.el +++ b/core/cli/doctor.el @@ -48,8 +48,8 @@ in." ;; REVIEW Refactor me (print! (start "Checking your Emacs version...")) - (when EMACS27+ - (warn! "Emacs %s detected. Emacs HEAD is unstable and may cause errors." + (when EMACS28+ + (warn! "Emacs %s detected. Doom doesn't support Emacs 28/HEAD. It is unstable and may cause errors." emacs-version)) (print! (start "Checking for Emacs config conflicts...")) From 68b5f687bd2b09774fd0ed877efc319a21760631 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 16:33:03 -0400 Subject: [PATCH 070/103] doom/doctor: fix 'org not installed' error Also indents missing package warnings correctly and makes them harder to mistake for system packages. Fixes #2284 --- core/cli/doctor.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/cli/doctor.el b/core/cli/doctor.el index bcc02fa43..224562263 100644 --- a/core/cli/doctor.el +++ b/core/cli/doctor.el @@ -157,15 +157,17 @@ in." (condition-case-unless-debug ex (let ((doctor-file (doom-module-path (car key) (cdr key) "doctor.el")) (packages-file (doom-module-path (car key) (cdr key) "packages.el"))) - (cl-loop for name in (let (doom-packages + (cl-loop with doom-format-indent = 6 + for name in (let (doom-packages doom-disabled-packages) (load packages-file 'noerror 'nomessage) (mapcar #'car doom-packages)) unless (or (doom-package-get name :disable) (eval (doom-package-get name :ignore)) + (plist-get (doom-package-get name :recipe) :local-repo) (doom-package-built-in-p name) (doom-package-installed-p name)) - do (print! (error "%s is not installed") name)) + do (print! (error "Missing emacs package: %S") name)) (let ((inhibit-message t)) (load doctor-file 'noerror 'nomessage))) (file-missing (error! "%s" (error-message-string ex))) From e7f04a3d87c688ad53d7c27a24e56a7f541729c4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 16:36:58 -0400 Subject: [PATCH 071/103] doom/doctor: fix over-eager omnisharp checks Fixes #2206 --- modules/lang/csharp/doctor.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/lang/csharp/doctor.el b/modules/lang/csharp/doctor.el index 82c1c191d..b9a56317f 100644 --- a/modules/lang/csharp/doctor.el +++ b/modules/lang/csharp/doctor.el @@ -1,7 +1,7 @@ ;; -*- lexical-binding: t; no-byte-compile: t; -*- ;;; lang/csharp/doctor.el -(require 'omnisharp) -(let ((omnisharp-bin (or omnisharp-server-executable-path (omnisharp--server-installation-path t)))) - (unless (file-exists-p omnisharp-bin) - (warn! "Omnisharp server isn't installed, completion won't work"))) +(when (and (require 'omnisharp nil t) (not (featurep! +lsp))) + (let ((omnisharp-bin (or omnisharp-server-executable-path (omnisharp--server-installation-path t)))) + (unless (file-exists-p omnisharp-bin) + (warn! "Omnisharp server isn't installed, completion won't work")))) From 68709fe93a2b023d03b107473438e791036b31ef Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 22:32:03 -0400 Subject: [PATCH 072/103] Fix letf! sometimes losing letf binds When expanding: (quiet! ...) You'd expect (simplified for explanation): (letf! ((standard-output ...) ((symbol-function #'message) ...) ((symbol-function #'load-file) ...) ((symbol-function #'write-region) ...)) ...) But instead get: (letf! ((standard-output ...)) ;; where'd the other binds go? ...) This was due to data-loss caused by nreverse's destructive mutation of the given bindings. Also: silences byte-compiler complaining about unused bindings. --- core/core-lib.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 1e3dc6244..adabe49c6 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -210,20 +210,21 @@ the same name, for use with `funcall' or `apply'. ARGLIST and BODY are as in (setq body (macroexp-progn body)) (when (memq (car bindings) '(defun defmacro)) (setq bindings (list bindings))) - (dolist (binding (nreverse bindings) body) + (dolist (binding (reverse bindings) (macroexpand body)) (let ((type (car binding)) (rest (cdr binding))) (setq body (pcase type (`defmacro `(cl-macrolet ((,(car rest) ,(cadr rest) ,@(cddr rest))) ,body)) (`defun `(cl-letf* ((,(car rest) (symbol-function #',(car rest))) - ((symbol-function #',(car rest)) - (lambda ,(cadr rest) ,@(cddr rest)))) - ,body)) + ((symbol-function #',(car rest)) + (lambda ,(cadr rest) ,@(cddr rest)))) + (ignore ,(car rest)) + ,body)) (_ (when (eq (car-safe type) 'function) - (setq type `(symbol-function ,type))) - `(cl-letf ((,type ,@rest)) ,body))))))) + (setq type (list 'symbol-function type))) + (list 'cl-letf (list (cons type rest)) body))))))) (defmacro quiet! (&rest forms) "Run FORMS without generating any output. From fc90e0fb71771c48ff51e2af263d3e94152e151d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 22:36:43 -0400 Subject: [PATCH 073/103] Simplify quiet!'s expanded form We don't need to test doom-interactive-mode at runtime. --- core/core-lib.el | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index adabe49c6..92e9331af 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -231,18 +231,19 @@ the same name, for use with `funcall' or `apply'. ARGLIST and BODY are as in This silences calls to `message', `load-file', `write-region' and anything that writes to `standard-output'." - `(cond (doom-debug-mode ,@forms) - ((not doom-interactive-mode) - (letf! ((standard-output (lambda (&rest _))) - (defun load-file (file) (load-file nil t)) - (defun message (&rest _)) - (defun write-region (start end filename &optional append visit lockname mustbenew) - (unless visit (setq visit 'no-message)) - (funcall write-region start end filename append visit lockname mustbenew))) - ,@forms)) - ((let ((inhibit-message t) - (save-silently t)) - (prog1 ,@forms (message "")))))) + `(if doom-debug-mode + (progn ,@forms) + ,(if doom-interactive-mode + `(let ((inhibit-message t) + (save-silently t)) + (prog1 ,@forms (message ""))) + `(letf! ((standard-output (lambda (&rest _))) + (defun load-file (file) (load-file nil t)) + (defun message (&rest _)) + (defun write-region (start end filename &optional append visit lockname mustbenew) + (unless visit (setq visit 'no-message)) + (funcall write-region start end filename append visit lockname mustbenew))) + ,@forms)))) (defmacro if! (cond then &rest body) "Expands to THEN if COND is non-nil, to BODY otherwise. From f521823d3b5617235a8837bc41ccb2b63cd5c4a9 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 14 May 2020 22:37:39 -0400 Subject: [PATCH 074/103] Fix quiet! macro not silencing file loading --- core/core-lib.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 92e9331af..a4680456e 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -229,7 +229,7 @@ the same name, for use with `funcall' or `apply'. ARGLIST and BODY are as in (defmacro quiet! (&rest forms) "Run FORMS without generating any output. -This silences calls to `message', `load-file', `write-region' and anything that +This silences calls to `message', `load', `write-region' and anything that writes to `standard-output'." `(if doom-debug-mode (progn ,@forms) @@ -238,8 +238,9 @@ writes to `standard-output'." (save-silently t)) (prog1 ,@forms (message ""))) `(letf! ((standard-output (lambda (&rest _))) - (defun load-file (file) (load-file nil t)) (defun message (&rest _)) + (defun load (file &optional noerror nomessage nosuffix must-suffix) + (funcall load file noerror t nosuffix must-suffix)) (defun write-region (start end filename &optional append visit lockname mustbenew) (unless visit (setq visit 'no-message)) (funcall write-region start end filename append visit lockname mustbenew))) From 4e28b48a3ac232200e2c939900544743667653ce Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 01:34:07 -0400 Subject: [PATCH 075/103] Fix C-j/C-k for evil-collection-minibuffer users --- modules/config/default/+evil-bindings.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 5b7834829..b7d2f20c3 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -4,12 +4,12 @@ ;; NOTE SPC u replaces C-u as the universal argument. ;; Minibuffer - (define-key! :keymaps '(evil-ex-completion-map evil-ex-search-keymap) - "C-a" #'evil-beginning-of-line - "C-b" #'evil-backward-char - "C-f" #'evil-forward-char - "C-j" #'next-complete-history-element - "C-k" #'previous-complete-history-element) + (map! :map (evil-ex-completion-map evil-ex-search-keymap) + "C-a" #'evil-beginning-of-line + "C-b" #'evil-backward-char + "C-f" #'evil-forward-char + :gi "C-j" #'next-complete-history-element + :gi "C-k" #'previous-complete-history-element) (define-key! :keymaps +default-minibuffer-maps [escape] #'abort-recursive-edit @@ -26,6 +26,7 @@ "C-k" #'previous-line "C-S-j" #'scroll-up-command "C-S-k" #'scroll-down-command) + ;; For folks with `evil-collection-setup-minibuffer' enabled (define-key! :states 'insert :keymaps +default-minibuffer-maps "C-j" #'next-line "C-k" #'previous-line) From ea18c83c0aa587ef4a84d7c2f269af0443823293 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 01:44:53 -0400 Subject: [PATCH 076/103] General refactors & reformatting across the board --- core/autoload/help.el | 5 ++- modules/completion/company/config.el | 3 +- modules/completion/ivy/autoload/ivy.el | 2 +- modules/completion/ivy/config.el | 20 +++++----- modules/config/default/config.el | 2 +- modules/editor/evil/config.el | 25 +++++-------- modules/editor/evil/init.el | 2 + modules/emacs/dired/config.el | 2 +- modules/emacs/ibuffer/config.el | 8 ++-- modules/lang/org/autoload/org-link.el | 14 ++++--- modules/lang/org/autoload/org.el | 16 ++++---- modules/lang/org/config.el | 12 +++--- modules/lang/org/contrib/present.el | 30 +++++++-------- modules/lang/python/doctor.el | 2 +- modules/term/eshell/config.el | 7 ++-- modules/tools/lookup/packages.el | 5 +-- modules/tools/magit/autoload.el | 20 ++++++++-- modules/tools/pdf/config.el | 51 +++++++++++++------------- modules/ui/ophints/config.el | 7 ++-- 19 files changed, 123 insertions(+), 110 deletions(-) diff --git a/core/autoload/help.el b/core/autoload/help.el index 92f83f5d0..4bff9a079 100644 --- a/core/autoload/help.el +++ b/core/autoload/help.el @@ -115,7 +115,8 @@ selection of all minor-modes, active or not." (require 'org) (let* ((default-directory doom-docs-dir) (org-agenda-files (mapcar #'expand-file-name (doom-enlist files))) - (depth (if (integerp depth) depth))) + (depth (if (integerp depth) depth)) + (org-inhibit-startup t)) (message "Loading search results...") (unwind-protect (delq @@ -218,7 +219,7 @@ selection of all minor-modes, active or not." :prompt "Search documentation for: ")) ;;;###autoload -(defun doom/help-news-search (&optional initial-input) +(defun doom/help-search-news (&optional initial-input) "Search headlines in Doom's newsletters." (interactive) (doom-completing-read-org-headings diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index e53822f82..0a5486de9 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -137,8 +137,7 @@ "This disables the company-box scrollbar, because: https://github.com/sebastiencs/company-box/issues/44" :around #'company-box--update-scrollbar - (cl-letf (((symbol-function #'display-buffer-in-side-window) - (symbol-function #'ignore))) + (letf! ((#'display-buffer-in-side-window #'ignore)) (apply orig-fn args)))) diff --git a/modules/completion/ivy/autoload/ivy.el b/modules/completion/ivy/autoload/ivy.el index f646469af..8147c26d5 100644 --- a/modules/completion/ivy/autoload/ivy.el +++ b/modules/completion/ivy/autoload/ivy.el @@ -178,7 +178,7 @@ If ARG (universal argument), open selection in other-window." (user-error "%S doesn't support wgrep" caller))))) ;;;###autoload -(defun +ivy-yas-prompt (prompt choices &optional display-fn) +(defun +ivy-yas-prompt-fn (prompt choices &optional display-fn) (yas-completing-prompt prompt choices display-fn #'ivy-completing-read)) ;;;###autoload diff --git a/modules/completion/ivy/config.el b/modules/completion/ivy/config.el index 874181aa3..23f95a7af 100644 --- a/modules/completion/ivy/config.el +++ b/modules/completion/ivy/config.el @@ -88,7 +88,7 @@ results buffer.") (setq +ivy--origin nil))) (after! yasnippet - (add-hook 'yas-prompt-functions #'+ivy-yas-prompt)) + (add-hook 'yas-prompt-functions #'+ivy-yas-prompt-fn)) (defadvice! +ivy--inhibit-completion-in-region-a (orig-fn &rest args) "`ivy-completion-in-region' struggles with completing certain @@ -114,12 +114,12 @@ evil-ex-specific constructs, so we disable it solely in evil-ex." (cadr (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer)))) - ;; Include variable value in `counsel-describe-variable' + ;; Enahnce the appearance of a couple counsel commands (plist-put! ivy-rich-display-transformers-list 'counsel-describe-variable '(:columns ((counsel-describe-variable-transformer (:width 40)) ; the original transformer - (+ivy-rich-describe-variable-transformer (:width 50)) + (+ivy-rich-describe-variable-transformer (:width 50)) ; display variable value (ivy-rich-counsel-variable-docstring (:face font-lock-doc-face)))) 'counsel-M-x '(:columns @@ -139,10 +139,9 @@ evil-ex-specific constructs, so we disable it solely in evil-ex." ;; Highlight buffers differently based on whether they're in the same project ;; as the current project or not. - (let* ((plist (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer)) - (switch-buffer-alist (assq 'ivy-rich-candidate (plist-get plist :columns)))) - (when switch-buffer-alist - (setcar switch-buffer-alist '+ivy-rich-buffer-name))) + (when-let* ((plist (plist-get ivy-rich-display-transformers-list 'ivy-switch-buffer)) + (switch-buffer-alist (assq 'ivy-rich-candidate (plist-get plist :columns)))) + (setcar switch-buffer-alist '+ivy-rich-buffer-name)) (ivy-rich-mode +1)) @@ -264,7 +263,8 @@ evil-ex-specific constructs, so we disable it solely in evil-ex." (cl-destructuring-bind (find-program . args) (cond ((executable-find doom-projectile-fd-binary) (append (list doom-projectile-fd-binary - "--color=never" "-E" ".git" "--type" "file" "--type" "symlink" "--follow") + "--color=never" "-E" ".git" + "--type" "file" "--type" "symlink" "--follow") (if IS-WINDOWS '("--path-separator=/")))) ((executable-find "rg") (append (list "rg" "--files" "--follow" "--color=never" "--hidden" "--no-messages") @@ -282,8 +282,8 @@ evil-ex-specific constructs, so we disable it solely in evil-ex." (let ((offset (if (member find-program (list "rg" doom-projectile-fd-binary)) 0 2)) files) (while (< (point) (point-max)) - (push (buffer-substring - (+ offset (line-beginning-position)) (line-end-position)) files) + (push (buffer-substring (+ offset (line-beginning-position)) (line-end-position)) + files) (forward-line 1)) (nreverse files))))))) diff --git a/modules/config/default/config.el b/modules/config/default/config.el index bb6c3a70d..ac9e53ba4 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -353,7 +353,7 @@ Continues comments if executed from a commented line. Consults "dL" #'doom/help-search-loaded-files "dm" #'doom/help-modules "dn" #'doom/help-news - "dN" #'doom/help-news-search + "dN" #'doom/help-search-news "dpc" #'doom/help-package-config "dpd" #'doom/goto-private-packages-file "dph" #'doom/help-package-homepage diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index 3d214619b..8ea569173 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -1,13 +1,10 @@ ;;; editor/evil/config.el -*- lexical-binding: t; -*- -;; I'm a vimmer at heart. Its modal philosophy suits me better, and this module -;; strives to make Emacs a much better vim than vim was. - (defvar +evil-repeat-keys (cons ";" ",") "The keys to use for universal repeating motions. This is a cons cell whose CAR is the key for repeating a motion forward, and -whose CDR is for repeating backward. They should both be kbd-able strings.") +whose CDR is for repeating backward. They should both be `kbd'-able strings.") (defvar +evil-want-o/O-to-continue-comments t "If non-nil, the o/O keys will continue comment lines if the point is on a @@ -137,8 +134,8 @@ directives. By default, this only recognizes C directives.") (and (>= char ?2) (<= char ?9))) ;; REVIEW Fix #2493: dir-locals cannot target fundamental-mode when evil-mode - ;; is active. See https://github.com/hlissner/doom-emacs/issues/2493. - ;; Revert this if this is ever fixed upstream. + ;; is active. See hlissner/doom-emacs#2493. Revert this if + ;; emacs-evil/evil#1268 is resolved upstream. (defadvice! +evil--fix-local-vars-a (&rest _) :before #'turn-on-evil-mode (when (eq major-mode 'fundamental-mode) @@ -227,12 +224,12 @@ directives. By default, this only recognizes C directives.") (use-package! evil-embrace :commands embrace-add-pair embrace-add-pair-regexp :hook (LaTeX-mode . embrace-LaTeX-mode-hook) + :hook (LaTeX-mode . +evil-embrace-latex-mode-hook-h) :hook (org-mode . embrace-org-mode-hook) :hook (ruby-mode . embrace-ruby-mode-hook) :hook (emacs-lisp-mode . embrace-emacs-lisp-mode-hook) :hook ((lisp-mode emacs-lisp-mode clojure-mode racket-mode hy-mode) . +evil-embrace-lisp-mode-hook-h) - :hook ((org-mode LaTeX-mode) . +evil-embrace-latex-mode-hook-h) :hook ((c++-mode rustic-mode csharp-mode java-mode swift-mode typescript-mode) . +evil-embrace-angle-bracket-modes-hook-h) :init @@ -369,14 +366,12 @@ directives. By default, this only recognizes C directives.") (defmacro set-repeater! (command next-func prev-func) "Makes ; and , the universal repeat-keys in evil-mode. To change these keys see `+evil-repeat-keys'." - (let ((fn-sym (intern (format "+evil/repeat-%s" (doom-unquote command))))) - `(progn - (defun ,fn-sym (&rest _) - (when +evil-repeat-keys - (evil-define-key* 'motion 'local - (kbd (car +evil-repeat-keys)) #',next-func - (kbd (cdr +evil-repeat-keys)) #',prev-func))) - (advice-add #',command :after-while #',fn-sym)))) + `(defadvice! ,(intern (format "+evil--repeat-%s-a" (doom-unquote command))) (&rest _) + :after-while #',command + (when +evil-repeat-keys + (evil-define-key* 'motion 'local + (kbd (car +evil-repeat-keys)) #',next-func + (kbd (cdr +evil-repeat-keys)) #',prev-func)))) ;; n/N (set-repeater! evil-ex-search-next evil-ex-search-next evil-ex-search-previous) diff --git a/modules/editor/evil/init.el b/modules/editor/evil/init.el index 462e35b39..3c629003b 100644 --- a/modules/editor/evil/init.el +++ b/modules/editor/evil/init.el @@ -1,5 +1,7 @@ ;;; editor/evil/init.el -*- lexical-binding: t; -*- +(defvar evil-collection-key-blacklist) + ;; We load evil-collection ourselves for these reasons: ;; ;; 1. To truly lazy load it. Some of its modules, like diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index 6b619607b..bf971bedc 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -40,7 +40,7 @@ This is because there's no guarantee the remote system has GNU ls, which is the only variant that supports --group-directories-first." (when (file-remote-p default-directory) - (setq-local dired-actual-switches "-ahl"))))) + (setq-local dired-actual-switches (car args)))))) ;; Don't complain about this command being disabled when we use it (put 'dired-find-alternate-file 'disabled nil) diff --git a/modules/emacs/ibuffer/config.el b/modules/emacs/ibuffer/config.el index 9ad9e56d2..6cb2f9a87 100644 --- a/modules/emacs/ibuffer/config.el +++ b/modules/emacs/ibuffer/config.el @@ -42,16 +42,16 @@ (when (featurep! :ui workspaces) (define-ibuffer-filter workspace-buffers "Filter for workspace buffers" - (:reader - (+workspace-get (read-string "workspace name: ")) :description "workspace") + (:reader (+workspace-get (read-string "workspace name: ")) + :description "workspace") (memq buf (+workspace-buffer-list qualifier))) - (defun +ibuffer/workspace (workspace-name) + (defun +ibuffer-workspace (workspace-name) "Open an ibuffer window for a workspace" (ibuffer nil (format "%s buffers" workspace-name) (list (cons 'workspace-buffers (+workspace-get workspace-name))))) - (defun +ibuffer-current-workspace () + (defun +ibuffer/open-for-current-workspace () "Open an ibuffer window for the current workspace" (interactive) (+ibuffer/workspace (+workspace-current-name)))) diff --git a/modules/lang/org/autoload/org-link.el b/modules/lang/org/autoload/org-link.el index 59d6c477b..28e7bde1e 100644 --- a/modules/lang/org/autoload/org-link.el +++ b/modules/lang/org/autoload/org-link.el @@ -46,11 +46,15 @@ exist, and `org-link' otherwise." "Intepret LINK as an image file path and return its data." (setq link (expand-file-name - link - (pcase protocol - ("download" (or org-download-image-dir org-attach-id-dir default-directory)) - ("attachment" org-attach-id-dir) - (_ default-directory)))) + link (pcase protocol + ("download" + (or (if (require 'org-download nil t) org-download-image-dir) + (if (require 'org-attach) org-attach-id-dir) + default-directory)) + ("attachment" + (require 'org-attach) + org-attach-id-dir) + (_ default-directory)))) (when (and (file-exists-p link) (image-type-from-file-name link)) (with-temp-buffer diff --git a/modules/lang/org/autoload/org.el b/modules/lang/org/autoload/org.el index c984372cf..b392851b5 100644 --- a/modules/lang/org/autoload/org.el +++ b/modules/lang/org/autoload/org.el @@ -141,7 +141,7 @@ current file). Only scans first 2048 bytes of the document." ;;; Commands ;;;###autoload -(defun +org/dwim-at-point () +(defun +org/dwim-at-point (&optional arg) "Do-what-I-mean at point. If on a: @@ -158,7 +158,7 @@ If on a: - latex fragment: toggle it. - link: follow it - otherwise, refresh all inline images in current tree." - (interactive) + (interactive "P") (let* ((context (org-element-context)) (type (org-element-type context))) ;; skip over unimportant contexts @@ -206,7 +206,7 @@ If on a: (`table-cell (org-table-blank-field) - (org-table-recalculate) + (org-table-recalculate arg) (when (and (string-empty-p (string-trim (org-table-get-field))) (bound-and-true-p evil-local-mode)) (evil-change-state 'insert))) @@ -215,13 +215,13 @@ If on a: (org-babel-lob-execute-maybe)) (`statistics-cookie - (save-excursion (org-update-statistics-cookies nil))) + (save-excursion (org-update-statistics-cookies arg))) ((or `src-block `inline-src-block) - (org-babel-execute-src-block)) + (org-babel-execute-src-block arg)) ((or `latex-fragment `latex-environment) - (org-latex-preview)) + (org-latex-preview arg)) (`link (let* ((lineage (org-element-lineage context '(link) t)) @@ -229,7 +229,7 @@ If on a: (if (or (equal (org-element-property :type lineage) "img") (and path (image-type-from-file-name path))) (+org--refresh-inline-images-in-subtree) - (org-open-at-point)))) + (org-open-at-point arg)))) ((guard (org-element-property :checkbox (org-element-lineage context '(item) t))) (let ((match (and (org-at-item-checkbox-p) (match-string 1)))) @@ -238,7 +238,7 @@ If on a: (_ (if (or (org-in-regexp org-ts-regexp-both nil t) (org-in-regexp org-tsr-regexp-both nil t) - (org-in-regexp org-any-link-re nil t)) + (org-in-regexp org-link-any-re nil t)) (call-interactively #'org-open-at-point) (+org--refresh-inline-images-in-subtree)))))) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index ef7b512bc..43bf20874 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -160,7 +160,7 @@ This forces it to read the background before rendering." ("HOLD" . +org-todo-onhold) ("PROJ" . +org-todo-project))) - (defadvice! +org-display-link-in-eldoc-a (&rest args) + (defadvice! +org-display-link-in-eldoc-a (&rest _) "Display full link in minibuffer when cursor/mouse is over it." :before-until #'org-eldoc-documentation-function (when-let (link (org-element-property :raw-link (org-element-context))) @@ -196,10 +196,10 @@ This forces it to read the background before rendering." ;; I prefer C-c C-c over C-c ' (more consistent) (define-key org-src-mode-map (kbd "C-c C-c") #'org-edit-src-exit) - (defadvice! +org-fix-newline-and-indent-in-src-blocks-a () + (defadvice! +org-fix-newline-and-indent-in-src-blocks-a (&optional indent _arg _interactive) "Mimic `newline-and-indent' in src blocks w/ lang-appropriate indentation." - :after #'org-return-indent - (when (org-in-src-block-p t) + :after #'org-return + (when (and indent (org-in-src-block-p t)) (org-babel-do-in-edit-buffer (call-interactively #'indent-for-tab-command)))) @@ -916,8 +916,8 @@ compelling reason, so..." :ni "C-S-k" #'org-shiftup :ni "C-S-j" #'org-shiftdown ;; more intuitive RET keybinds - :i [return] #'org-return-indent - :i "RET" #'org-return-indent + :i [return] (λ! (org-return t)) + :i "RET" (λ! (org-return t)) :n [return] #'+org/dwim-at-point :n "RET" #'+org/dwim-at-point ;; more vim-esque org motion keys (not covered by evil-org-mode) diff --git a/modules/lang/org/contrib/present.el b/modules/lang/org/contrib/present.el index d05cf8985..48a6b395d 100644 --- a/modules/lang/org/contrib/present.el +++ b/modules/lang/org/contrib/present.el @@ -41,19 +41,19 @@ (defadvice! +org-present--narrow-to-subtree-a (orig-fn &rest args) "Narrow to the target subtree when you start the presentation." :around #'org-tree-slide--display-tree-with-narrow - (letf! ((defun org-narrow-to-subtree () - (save-excursion - (save-match-data - (org-with-limited-levels - (narrow-to-region - (progn - (when (org-before-first-heading-p) - (org-next-visible-heading 1)) - (ignore-errors (org-up-heading-all 99)) - (forward-line 1) - (point)) - (progn (org-end-of-subtree t t) - (when (and (org-at-heading-p) (not (eobp))) - (backward-char 1)) - (point)))))))) + (letf! (defun org-narrow-to-subtree () + (save-excursion + (save-match-data + (org-with-limited-levels + (narrow-to-region + (progn + (when (org-before-first-heading-p) + (org-next-visible-heading 1)) + (ignore-errors (org-up-heading-all 99)) + (forward-line 1) + (point)) + (progn (org-end-of-subtree t t) + (when (and (org-at-heading-p) (not (eobp))) + (backward-char 1)) + (point))))))) (apply orig-fn args)))) diff --git a/modules/lang/python/doctor.el b/modules/lang/python/doctor.el index 588d3fb7a..546df9a8d 100644 --- a/modules/lang/python/doctor.el +++ b/modules/lang/python/doctor.el @@ -5,7 +5,7 @@ "This module requires (:tools lsp)") (if (not (executable-find "python")) - (error! "Python isn't installed.") + (error! "Couldn't find python in your PATH") (unless (featurep! +lsp) (unless (zerop (shell-command "python -c 'import setuptools'")) (warn! "setuptools wasn't detected, which anaconda-mode requires")))) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index fd32f7d9e..5445489aa 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -183,9 +183,10 @@ You should use `set-eshell-alias!' to change this.") :hook (eshell-mode . fish-completion-mode) :init (setq fish-completion-fallback-on-bash-p t) :config - ;; HACK Even with `fish-completion-fallback-on-bash-p' non-nil, fish must be - ;; installed for bash completion to work. How frustrating. This way we - ;; can at least get bash completion whether or not fish is present. + ;; HACK Even with `fish-completion-fallback-on-bash-p' non-nil, + ;; `fish-completion--list-completions-with-desc' will throw an error if + ;; fish isn't installed (and so, will fail to fall back to bash), so we + ;; advise it to fail silently. (defadvice! +eshell--fallback-to-bash-a (&rest _) :before-until #'fish-completion--list-completions-with-desc (unless (executable-find "fish") ""))) diff --git a/modules/tools/lookup/packages.el b/modules/tools/lookup/packages.el index e42c7449d..e8efd6c7b 100644 --- a/modules/tools/lookup/packages.el +++ b/modules/tools/lookup/packages.el @@ -28,9 +28,8 @@ (if IS-MAC (package! osx-dictionary :pin "1b79ff64c72485cb078db9ab7ee3256b11a99f4b") (package! define-word :pin "08c71b1ff4fd07bf0c78d1fcf77efeaafc8f7443") - ;; HACK Fix #2945: the main package is broken (see - ;; SavchenkoValeriy/emacs-powerthesaurus). We use this fork until it is - ;; merged. + ;; HACK Fix #2945: the main package is broken due to + ;; SavchenkoValeriy/emacs-powerthesaurus#11 (package! powerthesaurus :recipe (:host github :repo "maxchaos/emacs-powerthesaurus" :branch "pt-api-change") :pin "4a834782a394f2dc70fc02d68b6962b44d87f0cf") diff --git a/modules/tools/magit/autoload.el b/modules/tools/magit/autoload.el index f96b0ff9f..2b4c99359 100644 --- a/modules/tools/magit/autoload.el +++ b/modules/tools/magit/autoload.el @@ -1,10 +1,22 @@ ;;; tools/magit/autoload.el -*- lexical-binding: t; -*- -;; HACK Magit complains loudly when it can't determine its own version, which is -;; the case when magit is built through straight. The warning is harmless, -;; however, so we just need it to shut up. +;; HACK Magit complains loudly (but harmlessly) when it can't determine its own +;; version (in the case of a sparse clone). ;;;###autoload -(advice-add #'magit-version :override #'ignore) +(defadvice! +magit--ignore-version-a (&optional print-dest) + :override #'magit-version + (when print-dest + (defvar magit-git-debug) + (princ (format "Magit (unknown), Git %s, Emacs %s, %s" + (or (let ((magit-git-debug + (lambda (err) + (display-warning '(magit git) err :error)))) + (magit-git-version t)) + "(unknown)") + emacs-version + system-type) + print-dest)) + nil) ;;;###autoload (defun +magit-display-buffer-fn (buffer) diff --git a/modules/tools/pdf/config.el b/modules/tools/pdf/config.el index b1a739685..9e9025dee 100644 --- a/modules/tools/pdf/config.el +++ b/modules/tools/pdf/config.el @@ -65,29 +65,30 @@ (setq-hook! 'pdf-view-mode-hook evil-normal-state-cursor (list nil)) ;; Install epdfinfo binary if needed, blocking until it is finished - (require 'pdf-tools) - (unless (file-executable-p pdf-info-epdfinfo-program) - (let ((wconf (current-window-configuration))) - (pdf-tools-install) - (message "Building epdfinfo, this will take a moment...") - ;; HACK We reset all `pdf-view-mode' buffers to fundamental mode so that - ;; `pdf-tools-install' has a chance to reinitialize them as - ;; `pdf-view-mode' buffers. This is necessary because - ;; `pdf-tools-install' won't do this to buffers that are already in - ;; pdf-view-mode. - (dolist (buffer (doom-buffers-in-mode 'pdf-view-mode)) - (with-current-buffer buffer (fundamental-mode))) - (while compilation-in-progress - ;; Block until `pdf-tools-install' is done - (redisplay) - (sleep-for 1)) - ;; HACK If pdf-tools was loaded by you opening a pdf file, once - ;; `pdf-tools-install' completes, `pdf-view-mode' will throw an error - ;; because the compilation buffer is focused, not the pdf buffer. - ;; Therefore, it is imperative that the window config is restored. - (when (file-executable-p pdf-info-epdfinfo-program) - (set-window-configuration wconf)))) + (when doom-interactive-mode + (require 'pdf-tools) + (unless (file-executable-p pdf-info-epdfinfo-program) + (let ((wconf (current-window-configuration))) + (pdf-tools-install) + (message "Building epdfinfo, this will take a moment...") + ;; HACK We reset all `pdf-view-mode' buffers to fundamental mode so that + ;; `pdf-tools-install' has a chance to reinitialize them as + ;; `pdf-view-mode' buffers. This is necessary because + ;; `pdf-tools-install' won't do this to buffers that are already in + ;; pdf-view-mode. + (dolist (buffer (doom-buffers-in-mode 'pdf-view-mode)) + (with-current-buffer buffer (fundamental-mode))) + (while compilation-in-progress + ;; Block until `pdf-tools-install' is done + (redisplay) + (sleep-for 1)) + ;; HACK If pdf-tools was loaded by you opening a pdf file, once + ;; `pdf-tools-install' completes, `pdf-view-mode' will throw an error + ;; because the compilation buffer is focused, not the pdf buffer. + ;; Therefore, it is imperative that the window config is restored. + (when (file-executable-p pdf-info-epdfinfo-program) + (set-window-configuration wconf)))) - ;; Sets up `pdf-tools-enable-minor-modes', `pdf-occur-global-minor-mode' and - ;; `pdf-virtual-global-minor-mode'. - (pdf-tools-install-noverify)) + ;; Sets up `pdf-tools-enable-minor-modes', `pdf-occur-global-minor-mode' and + ;; `pdf-virtual-global-minor-mode'. + (pdf-tools-install-noverify))) diff --git a/modules/ui/ophints/config.el b/modules/ui/ophints/config.el index 2db9a2850..f1349a549 100644 --- a/modules/ui/ophints/config.el +++ b/modules/ui/ophints/config.el @@ -2,7 +2,7 @@ (use-package! evil-goggles :when (featurep! :editor evil) - :after-call pre-command-hook + :hook (doom-first-input . evil-goggles-mode) :init (setq evil-goggles-duration 0.1 evil-goggles-pulse nil ; too slow @@ -23,13 +23,12 @@ '(+eval:region :face evil-goggles-yank-face :switch evil-goggles-enable-yank - :advice evil-goggles--generic-async-advice)) - (evil-goggles-mode +1)) + :advice evil-goggles--generic-async-advice))) (use-package! volatile-highlights :unless (featurep! :editor evil) - :after-call pre-command-hook + :hook (doom-first-input . volatile-highlights-mode) :config (after! undo-fu (vhl/define-extension 'undo-fu 'undo-fu-only-undo 'undo-fu-only-redo) From 2884dd9ea70b0bfedf1740baa3f70561a7277afe Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 02:28:38 -0400 Subject: [PATCH 077/103] Fix 'recreate repo' option not being recommended When updating a package with a changed recipe (e.g. it's branch). --- core/core-cli.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core-cli.el b/core/core-cli.el index 2aa215247..1bd95c361 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -232,7 +232,7 @@ BODY will be run when this dispatcher is called." (" has a dirty worktree:" . "^Discard changes$") ("^In repository " - . "^Reset branch ")) + . "^Reset branch \\|^Delete remote [^,]+, re-create it with correct URL")) "A list of regexps, mapped to regexps. Their CAR is tested against the prompt, and CDR is tested against the presented From 8f8d796ecda4d19a51492db22a73045b0d9e2891 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 04:19:25 -0400 Subject: [PATCH 078/103] doom/doctor: fix 'missing emacs package: org' #2284 --- core/cli/doctor.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cli/doctor.el b/core/cli/doctor.el index 224562263..eb3ae5423 100644 --- a/core/cli/doctor.el +++ b/core/cli/doctor.el @@ -164,7 +164,7 @@ in." (mapcar #'car doom-packages)) unless (or (doom-package-get name :disable) (eval (doom-package-get name :ignore)) - (plist-get (doom-package-get name :recipe) :local-repo) + (plist-member (doom-package-get name :recipe) :local-repo) (doom-package-built-in-p name) (doom-package-installed-p name)) do (print! (error "Missing emacs package: %S") name)) From 805976b8bd3ca4e02cb4f832396e1d77d5828631 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 04:53:59 -0400 Subject: [PATCH 079/103] Handle the case where EMACSDIR has no trailing slash --- bin/doom | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/doom b/bin/doom index 9da3f4c96..d2dfce4f1 100755 --- a/bin/doom +++ b/bin/doom @@ -12,7 +12,10 @@ (let* ((loaddir (file-name-directory (file-truename load-file-name))) (emacsdir (getenv "EMACSDIR")) (user-emacs-directory - (abbreviate-file-name (or emacsdir (expand-file-name "../" loaddir))))) + (abbreviate-file-name + (if emacsdir + (file-name-as-directory emacsdir) + (expand-file-name "../" loaddir))))) ;; (load (expand-file-name "core/core.el" user-emacs-directory) nil t) From 87e279ce61b4a2ae161e67b6c277b3be80637e41 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 04:59:10 -0400 Subject: [PATCH 080/103] doom/doctor: improve error handler for font detection Fixes #3008 --- core/cli/doctor.el | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/core/cli/doctor.el b/core/cli/doctor.el index eb3ae5423..5c4dc2f40 100644 --- a/core/cli/doctor.el +++ b/core/cli/doctor.el @@ -132,14 +132,21 @@ in." (`darwin "~/Library/Fonts/")) (require 'all-the-icons nil t)) (with-temp-buffer - (insert (cdr (doom-call-process "fc-list" "" "file"))) - (dolist (font all-the-icons-font-names) - (if (save-excursion (re-search-backward font nil t)) - (success! "Found font %s" font) - (print! (warn "Warning: couldn't find %S font") font) - (explain! "You can install it by running `M-x all-the-icons-install-fonts' within Emacs.\n\n" - "This could also mean you've installed them in non-standard locations, in which " - "case feel free to ignore this warning."))))))) + (let ((errors 0)) + (cl-destructuring-bind (status . output) + (doom-call-process "fc-list" "" "file") + (if (not (zerop status)) + (print! (error "There was an error running `fc-list'. Is fontconfig installed correctly?")) + (insert (cdr (doom-call-process "fc-list" "" "file"))) + (dolist (font all-the-icons-font-names) + (if (save-excursion (re-search-backward font nil t)) + (success! "Found font %s" font) + (print! (warn "Warning: couldn't find %S font") font))) + (when (> errors 0) + (explain! "Some all-the-icons fonts were missing.\n\n" + "You can install them by running `M-x all-the-icons-install-fonts' within Emacs.\n" + "This could also mean you've installed them in non-standard locations, in which " + "case feel free to ignore this warning."))))))))) (print! (start "Checking for stale elc files in your DOOMDIR...")) (when (file-directory-p doom-private-dir) From 76b133fd9802ef3bb601d3ac155eb01512023baa Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 05:32:11 -0400 Subject: [PATCH 081/103] Install core packages early --- core/core-packages.el | 110 +++++++++++++++++++++++++----------------- core/packages.el | 4 +- 2 files changed, 69 insertions(+), 45 deletions(-) diff --git a/core/core-packages.el b/core/core-packages.el index bbcbfd1de..ddf7e19a9 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -102,51 +102,62 @@ package's name as a symbol, and whose CDR is the plist supplied to its ;; ;;; Bootstrappers +(defun doom--ensure-straight () + (cl-destructuring-bind (&key pin recipe &allow-other-keys) + (doom-package-get 'straight) + (let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el")) + (repo-url (concat "http" (if gnutls-verify-error "s") + "://github.com/" + (or (plist-get recipe :repo) "raxod502/straight.el"))) + (branch (or (plist-get recipe :branch) straight-repository-branch)) + (call (if doom-debug-mode #'doom-exec-process #'doom-call-process))) + (if (not (file-directory-p repo-dir)) + (message "Installing straight...") + ;; TODO Rethink this clumsy workaround + (let ((default-directory repo-dir)) + (unless (equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) pin) + (delete-directory repo-dir 'recursive) + (message "Updating straight...")))) + (unless (file-directory-p repo-dir) + (cond + ((eq straight-vc-git-default-clone-depth 'full) + (funcall call "git" "clone" "--origin" "origin" repo-url repo-dir)) + ((null pin) + (funcall call "git" "clone" "--origin" "origin" repo-url repo-dir + "--depth" (number-to-string straight-vc-git-default-clone-depth) + "--branch" straight-repository-branch)) + ((integerp straight-vc-git-default-clone-depth) + (make-directory repo-dir t) + (let ((default-directory repo-dir)) + (funcall call "git" "init") + (funcall call "git" "checkout" "-b" straight-repository-branch) + (funcall call "git" "remote" "add" "origin" repo-url) + (funcall call "git" "fetch" "origin" pin + "--depth" (number-to-string straight-vc-git-default-clone-depth)) + (funcall call "git" "checkout" "--detach" pin))))) + (require 'straight (concat repo-dir "/straight.el")) + (doom-log "Initializing recipes") + (with-temp-buffer + (insert-file-contents (doom-path repo-dir "bootstrap.el")) + ;; Don't install straight for us -- we've already done that -- only set + ;; up its recipe repos for us. + (eval-region (search-forward "(require 'straight)") + (point-max)))))) + (defun doom-initialize-core-packages (&optional force-p) "Ensure `straight' is installed and was compiled with this version of Emacs." (when (or force-p (null (bound-and-true-p straight-recipe-repositories))) (doom-log "Initializing straight") - (cl-destructuring-bind (&key pin recipe &allow-other-keys) - (let ((doom-packages (doom-package-list nil 'core-only))) - (doom-package-get 'straight)) - (let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el")) - (repo-url (concat "http" (if gnutls-verify-error "s") - "://github.com/" - (or (plist-get recipe :repo) "raxod502/straight.el"))) - (branch (or (plist-get recipe :branch) straight-repository-branch)) - (call (if doom-debug-mode #'doom-exec-process #'doom-call-process))) - (if (not (file-directory-p repo-dir)) - (message "Installing straight...") - ;; TODO Rethink this clumsy workaround - (let ((default-directory repo-dir)) - (unless (equal (cdr (doom-call-process "git" "rev-parse" "HEAD")) pin) - (delete-directory repo-dir 'recursive) - (message "Updating straight...")))) - (unless (file-directory-p repo-dir) - (cond - ((eq straight-vc-git-default-clone-depth 'full) - (funcall call "git" "clone" "--origin" "origin" repo-url repo-dir)) - ((null pin) - (funcall call "git" "clone" "--origin" "origin" repo-url repo-dir - "--depth" (number-to-string straight-vc-git-default-clone-depth) - "--branch" straight-repository-branch)) - ((integerp straight-vc-git-default-clone-depth) - (make-directory repo-dir t) - (let ((default-directory repo-dir)) - (funcall call "git" "init") - (funcall call "git" "checkout" "-b" straight-repository-branch) - (funcall call "git" "remote" "add" "origin" repo-url) - (funcall call "git" "fetch" "origin" pin - "--depth" (number-to-string straight-vc-git-default-clone-depth)) - (funcall call "git" "checkout" "--detach" pin))))) - (require 'straight (concat repo-dir "/straight.el")) - (doom-log "Initializing recipes") - (with-temp-buffer - (insert-file-contents (doom-path repo-dir "bootstrap.el")) - ;; Don't install straight for us -- we've already done that -- only set - ;; up its recipe repos for us. - (eval-region (search-forward "(require 'straight)") - (point-max))))))) + (let ((doom-disabled-packages nil) + (doom-packages (doom-package-list nil 'core-only))) + (doom--ensure-straight) + (doom-log "Installing core packages") + (dolist (package doom-packages) + (cl-destructuring-bind (name &key recipe &allow-other-keys) + package + (when recipe + (straight-override-recipe (cons name recipe))) + (straight-use-package name)))))) (defun doom-initialize-packages (&optional force-p) "Process all packages, essential and otherwise, if they haven't already been. @@ -348,7 +359,11 @@ ones." for doom--current-module = key do (doom--read-packages path nil 'noerror))) (doom--read-packages private-packages all-p 'noerror))) - (reverse doom-packages))) + (cl-remove-if-not + (if core-only-p + (lambda (pkg) (eq (plist-get (cdr pkg) :type) 'core)) + #'identity) + (nreverse doom-packages)))) (defun doom-package-pinned-list () "Return an alist mapping package names (strings) to pinned commits (strings)." @@ -405,7 +420,7 @@ ones." ;;; Module package macros (cl-defmacro package! - (name &rest plist &key built-in recipe ignore _pin _disable) + (name &rest plist &key built-in recipe ignore _type _pin _disable) "Declares a package and how to install it (if applicable). This macro is declarative and does not load nor install packages. It is used to @@ -416,6 +431,15 @@ Only use this macro in a module's packages.el file. Accepts the following properties: + :type core|local|built-in|virtual + Specifies what kind of package this is. Can be a symbol or a list thereof. + `core' = this is a protected package and cannot be disabled! + `local' = this package is being modified in-place. This package's repo is + unshallowed and will be skipped when you update packages. + `built-in' = this package is already built-in (otherwise, will be + installed) + `virtual' = this package is not tracked by Doom's package manager. It won't + be installed or uninstalled. Use this to pin 2nd order dependencies. :recipe RECIPE Specifies a straight.el recipe to allow you to acquire packages from external sources. See https://github.com/raxod502/straight.el#the-recipe-format for diff --git a/core/packages.el b/core/packages.el index fba82b326..cd6ebc6e0 100644 --- a/core/packages.el +++ b/core/packages.el @@ -7,7 +7,7 @@ ;; core-packages.el (package! straight - ;; :type 'core + :type 'core :recipe `(:host github :repo "raxod502/straight.el" :branch ,straight-repository-branch @@ -18,7 +18,7 @@ ;; core-modules.el (package! use-package - ;; :type 'core + :type 'core :pin "c873d5529c9c80cb58222f22873a4f081c307cb2") ;; core-ui.el From 2b8388079b1cdf1f1c3018d549da9c55eb1026da Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 05:32:48 -0400 Subject: [PATCH 082/103] Fix doom/bump-module command Also allows you to bump :core now. --- core/autoload/packages.el | 55 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/core/autoload/packages.el b/core/autoload/packages.el index 7b677e129..2c0825a9b 100644 --- a/core/autoload/packages.el +++ b/core/autoload/packages.el @@ -144,30 +144,37 @@ Grabs the latest commit id of the package using 'git'." If SELECT (prefix arg) is non-nil, prompt you to choose a specific commit for each package." (interactive - (append - (mapcar #'intern - (split-string - (completing-read - "Bump module: " - (let ((modules (doom-module-list 'all))) - (mapcar (lambda (m) - (if (listp m) - (format "%s %s" (car m) (cdr m)) - (format "%s" m))) - (append (list ":private") - (delete-dups (mapcar #'car modules)) - modules))) - nil t nil nil) - " " t)) - (list current-prefix-arg))) - (if-let (packages-file (if (eq category :private) - (doom-glob doom-private-dir "packages.el") - (doom-module-locate-path category module "packages.el"))) - (with-current-buffer - (or (get-file-buffer packages-file) - (find-file-noselect packages-file)) - (doom/bump-packages-in-buffer select)) - (user-error "Module %s %s has no packages.el file"))) + (let* ((module (completing-read + "Bump module: " + (let ((modules (cons (list :core) (doom-module-list 'all)))) + (mapcar (lambda (m) + (if (listp m) + (format "%s %s" (car m) (cdr m)) + (format "%s" m))) + (append (list ":private") + (delete-dups (mapcar #'car modules)) + modules))) + nil t nil nil)) + (module (split-string module " " t))) + (list (intern (car module)) + (ignore-errors (intern (cadr module))) + current-prefix-arg))) + (mapc (lambda (module) + (if-let (packages-file + (pcase category + (:private (doom-glob doom-private-dir "packages.el")) + (:core (doom-glob doom-core-dir "packages.el")) + (_ (doom-module-locate-path category module "packages.el")))) + (with-current-buffer + (or (get-file-buffer packages-file) + (find-file-noselect packages-file)) + (doom/bump-packages-in-buffer select) + (save-buffer)) + (message "Module %s has no packages.el file" (cons category module)))) + (if module + (list (cons category module)) + (cl-remove-if-not (lambda (m) (eq (car m) category)) + (cons (list :core) (doom-module-list 'all)))))) ;;;###autoload (defun doom/bump-package (package) From e16c410b2a92c761342ca6dc8ced226297db30dc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 05:36:43 -0400 Subject: [PATCH 083/103] Fix use-package load errors on 'doom install' --- core/cli/install.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/cli/install.el b/core/cli/install.el index 8b0d81f32..f7b517d3c 100644 --- a/core/cli/install.el +++ b/core/cli/install.el @@ -58,7 +58,13 @@ DOOMDIR environment variable. e.g. ;; In case no init.el was present the first time `doom-initialize-modules' was ;; called in core.el (e.g. on first install) - (doom-initialize-modules 'force) + (ignore-errors (load! "init" doom-private-dir t)) + (when doom-modules + (maphash (lambda (key plist) + (let ((doom--current-module key) + (doom--current-flags (plist-get plist :flags))) + (load! "init" (plist-get plist :path) t))) + doom-modules)) ;; Ask if user would like an envvar file generated (if noenv-p From 8a83e9adddad4013725c04d3f2ace8a5f507a094 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 14:20:03 -0400 Subject: [PATCH 084/103] Fix wrong-number-of-args error on dired-find-file --- core/core-editor.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/core-editor.el b/core/core-editor.el index e05ac3204..165dd5d48 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -321,8 +321,6 @@ files, so we replace calls to `pp' with the much faster `prin1'." (global-set-key [remap evil-jump-backward] #'better-jumper-jump-backward) (global-set-key [remap xref-pop-marker-stack] #'better-jumper-jump-backward) :config - (advice-add #'dired-find-file :before #'doom-set-jump-maybe-a) - (defun doom-set-jump-a (orig-fn &rest args) "Set a jump point and ensure ORIG-FN doesn't set any new jump points." (better-jumper-set-jump (if (markerp (car args)) (car args))) From c1bee692cf2c178e8d9695da7955143f10386943 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 14:22:13 -0400 Subject: [PATCH 085/103] doom/install? ignore errors in module init.el's Fix #3132 --- core/cli/install.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/cli/install.el b/core/cli/install.el index f7b517d3c..b776d9402 100644 --- a/core/cli/install.el +++ b/core/cli/install.el @@ -58,12 +58,13 @@ DOOMDIR environment variable. e.g. ;; In case no init.el was present the first time `doom-initialize-modules' was ;; called in core.el (e.g. on first install) - (ignore-errors (load! "init" doom-private-dir t)) + (ignore-errors + (load! "init" doom-private-dir t)) (when doom-modules (maphash (lambda (key plist) (let ((doom--current-module key) (doom--current-flags (plist-get plist :flags))) - (load! "init" (plist-get plist :path) t))) + (ignore-errors (load! "init" (plist-get plist :path) t)))) doom-modules)) ;; Ask if user would like an envvar file generated From ea2de668b7ee93c005c235178cc0b195265813bd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 17:19:39 -0400 Subject: [PATCH 086/103] Fix #3135: no template after doom install --- core/cli/install.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cli/install.el b/core/cli/install.el index b776d9402..f5082d698 100644 --- a/core/cli/install.el +++ b/core/cli/install.el @@ -107,5 +107,5 @@ DOOMDIR environment variable. e.g. (print! (success "\nFinished! Doom is ready to go!\n")) (with-temp-buffer - (insert (doom-glob doom-core-dir "templates/QUICKSTART_INTRO")) + (insert-file-contents (doom-glob doom-core-dir "templates/QUICKSTART_INTRO")) (print! "%s" (buffer-string))))) From 0972858808e3bb29ef92db0ff75ba25feb97c7c3 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 17:55:23 -0400 Subject: [PATCH 087/103] Update 'doom install' post-amble --- core/templates/QUICKSTART_INTRO | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/core/templates/QUICKSTART_INTRO b/core/templates/QUICKSTART_INTRO index f7d101ac7..2f7bd1e60 100644 --- a/core/templates/QUICKSTART_INTRO +++ b/core/templates/QUICKSTART_INTRO @@ -1,25 +1,19 @@ -Before you doom yourself, there are a few things you should know: +But before you doom yourself, here are some things you should know: -1. Whenever you edit your doom! block in ~/.doom.d/init.el or modify your - modules, run: +1. Don't forget to run 'doom sync', then restart Emacs, after modifying + ~/.doom.d/init.el or ~/.doom.d/packages.el. - bin/doom refresh + This command ensures needed packages are installed, orphaned packages are + removed, and your autoloads/cache files are up to date. When in doubt, run + 'doom sync'! - This will ensure all needed packages are installed, all orphaned packages are - removed, and your autoloads files are up to date. This is important! If you - forget to do this you will get errors! +2. If something goes wrong, run `doom doctor`. It diagnoses common issues with + your environment and setup, and may offer clues about what is wrong. -2. If something inexplicably goes wrong, try `bin/doom doctor` +3. Use 'doom upgrade' to update Doom. Doing it any other way will require + additional steps. Run 'doom help upgrade' to understand those extra steps. - This will diagnose common issues with your environment and setup, and may - give you clues about what is wrong. - -3. Use `bin/doom upgrade` to update Doom. Doing it any other way may require - additional work. When in doubt, run `bin/doom sync`. - -4. Check out `bin/doom help` to see what else `bin/doom` can do (and it is - recommended you add ~/.emacs.d/bin to your PATH). - -5. You can find Doom's documentation via `M-x doom/help` or `SPC h D`. +4. Access Doom's documentation from within Emacs via 'SPC h D' or 'C-h D' (or + 'M-x doom/help') Have fun! From 3d10e984ec35a995a42daae66dcc4f6c149a3048 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 17:56:29 -0400 Subject: [PATCH 088/103] Fix #3134: invalid lambda variable t on 'doom compile' --- core/cli/byte-compile.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cli/byte-compile.el b/core/cli/byte-compile.el index b8831cd7c..2f55f2b48 100644 --- a/core/cli/byte-compile.el +++ b/core/cli/byte-compile.el @@ -121,7 +121,7 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files." (use-package-defaults use-package-defaults) (use-package-expand-minimally t) (targets (delete-dups targets)) - (modules (seq-group-by (lambda (t) (doom-module-from-path t)) targets)) + (modules (seq-group-by #'doom-module-from-path targets)) (total-files (length targets)) (total-modules (length modules)) (i 0) From 2e1c706c73afb3bf1e506df4b3f447de961a86a2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 21:56:04 -0400 Subject: [PATCH 089/103] doom/env: fix -a switch, add -r switch #2434 Can now white and blacklist envvars --- core/cli/env.el | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/core/cli/env.el b/core/cli/env.el index 5b2188385..b9090617b 100644 --- a/core/cli/env.el +++ b/core/cli/env.el @@ -1,7 +1,8 @@ ;;; core/cli/env.el -*- lexical-binding: t; -*- (defcli! env - ((allow ["-a" "--allow"] "An envvar whitelist regexp") + ((allow ["-a" "--allow" regexp] "An envvar whitelist regexp") + (reject ["-r" "--reject" regexp] "An envvar blacklist regexp") (clear-p ["-c" "--clear"] "Clear and delete your envvar file") (outputfile ["-o" PATH] "Generate the envvar file at PATH. Envvar files that aren't in @@ -47,17 +48,18 @@ Why this over exec-path-from-shell? (print! (success "Successfully deleted %S") (path env-file))) - (args + ((and args (not (or allow reject))) (user-error "I don't understand 'doom env %s'" (string-join args " "))) - ((doom-cli-reload-env-file 'force env-file))))) + ((doom-cli-reload-env-file + 'force env-file (list allow) (list reject)))))) ;; ;; Helpers -(defvar doom-env-ignored-vars +(defvar doom-env-blacklist '("^DBUS_SESSION_BUS_ADDRESS$" "^GPG_AGENT_INFO$" "^\\(SSH\\|GPG\\)_TTY$" "^SSH_\\(AUTH_SOCK\\|AGENT_PID\\)$" @@ -69,7 +71,13 @@ Why this over exec-path-from-shell? Each string is a regexp, matched against variable names to omit from `doom-env-file'.") -(defun doom-cli-reload-env-file (&optional force-p env-file whitelist) +(defvar doom-env-whitelist '() + "A whitelist for envvars to save in `doom-env-file'. + +This overrules `doom-env-ignored-vars'. Each string is a regexp, matched against +variable names to omit from `doom-env-file'.") + +(defun doom-cli-reload-env-file (&optional force-p env-file whitelist blacklist) "Generates `doom-env-file', if it doesn't exist (or if FORCE-P). This scrapes the variables from your shell environment by running @@ -112,11 +120,13 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in ;; user's interactive shell, therefore we just dump ;; `process-environment' to a file. (dolist (env process-environment) - (if (and (cl-find-if (doom-rpartial #'string-match-p (car (split-string env "="))) - doom-env-ignored-vars) - (not (cl-find-if (doom-rpartial #'string-match-p (car (split-string env "="))) - whitelist))) - (print! (info "Ignoring %s") env) + (if (cl-find-if (doom-rpartial #'string-match-p (car (split-string env "="))) + (remq nil (append blacklist doom-env-blacklist))) + (if (not (cl-find-if (doom-rpartial #'string-match-p (car (split-string env "="))) + (remq nil (append whitelist doom-env-whitelist)))) + (print! (info "Ignoring %s") env) + (print! (info "Whitelisted %s") env) + (insert env "\0\n")) (insert env "\0\n"))) (print! (success "Successfully generated %S") (path env-file)) From 1b43cf99f715aa16999e0458d0de016a15bab9da Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 21:56:43 -0400 Subject: [PATCH 090/103] Add comments to & reformat doom-initialize --- core/core.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/core.el b/core/core.el index aea4ac635..0fe78e949 100644 --- a/core/core.el +++ b/core/core.el @@ -499,6 +499,8 @@ to least)." ;; `doom-disabled-packages'. A big reduction in startup time. (or (doom-load-autoloads-file doom-package-autoload-file) (ignore (warn "Doom's package autoloads file is missing")))) + ;; If neither autoloads file loads, then the user forgot to sync, or + ;; aborted a doom command midway! (signal 'doom-error (list "Doom is in an incomplete state" "run 'bin/doom sync' on the command line to repair it"))) @@ -510,15 +512,16 @@ to least)." (daemonp)) (doom-load-envvars-file doom-env-file 'noerror)) + ;; Loads `use-package' and our module helper library (require 'core-modules) + + ;; In case we want to use package.el or straight via M-x later (autoload 'doom-initialize-packages "core-packages") (autoload 'doom-initialize-core-packages "core-packages") - - ;; In case we want to use package.el or straight via M-x (with-eval-after-load 'package (require 'core-packages)) (with-eval-after-load 'straight (doom-initialize-packages)) - ;; Bootstrap interactive session + ;; Bootstrap the interactive session (add-hook! 'window-setup-hook (add-hook 'hack-local-variables-hook #'doom-run-local-var-hooks-h) (add-hook 'after-change-major-mode-hook #'doom-run-local-var-hooks-maybe-h 'append) @@ -529,6 +532,7 @@ to least)." (add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h) (add-hook 'window-setup-hook #'doom-display-benchmark-h 'append) + ;; Load core/core-*.el, the user's private init.el and their config.el (doom-initialize-modules force-p)) doom-init-p) From ceb1d4e91f5718e1610d3536ed394ac25e5251f4 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 22:53:17 -0400 Subject: [PATCH 091/103] Disable {bash,fish}-completion on Windows Because neither is available on windows, you'll get errors when trying to complete in eshell. Better to disable it so eshell can fall back to pcomplete. --- modules/term/eshell/config.el | 1 + modules/term/eshell/packages.el | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 5445489aa..421a891df 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -180,6 +180,7 @@ You should use `set-eshell-alias!' to change this.") (use-package! fish-completion + :unless IS-WINDOWS :hook (eshell-mode . fish-completion-mode) :init (setq fish-completion-fallback-on-bash-p t) :config diff --git a/modules/term/eshell/packages.el b/modules/term/eshell/packages.el index 61da48f63..82bfc2281 100644 --- a/modules/term/eshell/packages.el +++ b/modules/term/eshell/packages.el @@ -7,6 +7,7 @@ (package! esh-help :pin "417673ed18a983930a66a6692dbfb288a995cb80") (package! eshell-did-you-mean :pin "7cb6ef8e2274d0a50a9e114d412307a6543533d5") -(when (featurep! :completion company) - (package! fish-completion :pin "10384881817b5ae38cf6197a077a663420090d2c") - (package! bash-completion :pin "96ce14af9674f3e605bacca87abc0c23b8f13cd5")) +(unless IS-WINDOWS + (when (featurep! :completion company) + (package! fish-completion :pin "10384881817b5ae38cf6197a077a663420090d2c") + (package! bash-completion :pin "96ce14af9674f3e605bacca87abc0c23b8f13cd5"))) From eafad7bbad41b8cdfef6b2532cb7ae24115e6fb0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 22:54:50 -0400 Subject: [PATCH 092/103] Reformat term/eshell module - Two newlines between use-package! blocks - Remove comment that was redundant with the code below it --- modules/term/eshell/config.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/term/eshell/config.el b/modules/term/eshell/config.el index 421a891df..0b16b51f1 100644 --- a/modules/term/eshell/config.el +++ b/modules/term/eshell/config.el @@ -179,6 +179,17 @@ You should use `set-eshell-alias!' to change this.") :config (setup-esh-help-eldoc)) +(use-package! eshell-did-you-mean + :after esh-mode ; Specifically esh-mode, not eshell + :config + (eshell-did-you-mean-setup) + ;; HACK There is a known issue with `eshell-did-you-mean' where it does not + ;; work on first invocation, so we invoke it once manually by setting the + ;; last command and then calling the output filter. + (setq eshell-last-command-name "catt") + (eshell-did-you-mean-output-filter "catt: command not found")) + + (use-package! fish-completion :unless IS-WINDOWS :hook (eshell-mode . fish-completion-mode) @@ -191,14 +202,3 @@ You should use `set-eshell-alias!' to change this.") (defadvice! +eshell--fallback-to-bash-a (&rest _) :before-until #'fish-completion--list-completions-with-desc (unless (executable-find "fish") ""))) - -;; Activate eshell-did-you-mean using its setup function (lazily) -(use-package! eshell-did-you-mean - :after esh-mode ; Specifically esh-mode, not eshell - :config - (eshell-did-you-mean-setup) - ;; HACK There is a known issue with `eshell-did-you-mean' where it does not - ;; work on first invocation, so we invoke it once manually by setting - ;; the last command and then calling the output filter. - (setq eshell-last-command-name "catt") - (eshell-did-you-mean-output-filter "catt: command not found")) \ No newline at end of file From 10d9ca87e9c51a475ebede48eea19ef0a9600950 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 15 May 2020 22:58:00 -0400 Subject: [PATCH 093/103] Correct regexps for recommended straight options When you're being prompted, these regexps control what option is highlighted as the recommended option, and two of them were definitely wrong, and another two *might've* been wrong. --- core/core-cli.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/core-cli.el b/core/core-cli.el index 1bd95c361..c53207d2a 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -223,13 +223,13 @@ BODY will be run when this dispatcher is called." ;;; Straight hacks (defvar doom--cli-straight-discard-options - '((" has diverged from branch " + '(("has diverged from" . "^Reset [^ ]+ to branch") - (" but recipe specifies a URL of " - . "^Delete remote \"[^\"]+\", re-create it with correct ") - (" has a merge conflict:" + ("but recipe specifies a URL of" + . "re-create it with correct URL") + ("has a merge conflict:" . "^Abort merge$") - (" has a dirty worktree:" + ("has a dirty worktree:" . "^Discard changes$") ("^In repository " . "^Reset branch \\|^Delete remote [^,]+, re-create it with correct URL")) From e3ca1d52adbf0faa417c0a1ab514a11895fbb078 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 16 May 2020 05:13:46 -0400 Subject: [PATCH 094/103] Bump :lang org bastibe/org-journal@8bf06b2 -> bastibe/org-journal@2c43b10 emacs-straight/org-mode@20c1322 -> emacs-straight/org-mode@93c50e3 oer/org-re-reveal@61549f4 -> oer/org-re-reveal@a9e9d4e org-roam/company-org-roam@3da3821 -> org-roam/company-org-roam@674c2bd org-roam/org-roam@ad5fca5 -> org-roam/org-roam@1267a43 Fixes #3123 --- modules/lang/org/config.el | 14 +------------- modules/lang/org/packages.el | 10 +++++----- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 43bf20874..3dc4acc22 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -831,19 +831,7 @@ compelling reason, so..." (after! org (add-to-list 'org-tags-exclude-from-inheritance "crypt") (add-hook! 'org-mode-hook - (add-hook 'before-save-hook 'org-encrypt-entries nil t))) - :config - (after! epa - ;; HACK Fix #3123: `org-encrypt-string' expects `epa-file-encrypt-to' to be - ;; a string, but its docs say it can be a string or list of strings, - ;; and Doom sets it to a list of strings by default. Remove this when - ;; this is addressed upstream. - ;; TODO Report this upstream. - (unless org-crypt-key - (setq org-crypt-key - (if (listp epa-file-encrypt-to) - (car epa-file-encrypt-to) - epa-file-encrypt-to))))) + (add-hook 'before-save-hook 'org-encrypt-entries nil t)))) (use-package! org-clock ; built-in diff --git a/modules/lang/org/packages.el b/modules/lang/org/packages.el index 55db471a0..0e5007246 100644 --- a/modules/lang/org/packages.el +++ b/modules/lang/org/packages.el @@ -27,7 +27,7 @@ :recipe (:host github :repo "emacs-straight/org-mode" :files ("*.el" "lisp/*.el" "contrib/lisp/*.el")) - :pin "20c13221942183290dc440ca6ba91597f243b9e7") + :pin "93c50e3a7867a1a85fc78b337172585f7a10dcc6") ;; ...And prevent other packages from pulling org; org-plus-contrib satisfies ;; the dependency already: https://github.com/raxod502/straight.el/issues/352 (package! org :recipe (:local-repo nil)) @@ -62,7 +62,7 @@ (when (featurep! +jupyter) (package! jupyter :pin "785edbbff65abb0c929dc2fbd8b8305c77fd529e")) (when (featurep! +journal) - (package! org-journal :pin "8bf06b28d6f14f52d4968123e2b4b91930c8f947")) + (package! org-journal :pin "2c43b10eed0659f8e47797e5e53d2973f939284d")) (when (featurep! +noter) (package! org-noter :pin "9ead81d42dd4dd5074782d239b2efddf9b8b7b3d")) (when (featurep! +pomodoro) @@ -72,11 +72,11 @@ :recipe (:host github :repo "anler/centered-window-mode") :pin "f50859941ab5c7cbeaee410f2d38716252b552ac") (package! org-tree-slide :pin "7bf09a02bd2d8f1ccfcb5209bfb18fbe02d1f44e") - (package! org-re-reveal :pin "61549f4c00284a30e34caa3d76001b233ea5d2ad")) + (package! org-re-reveal :pin "a9e9d4ef88417b3af7741a8d8f444ece820e7a3b")) (when (featurep! +roam) - (package! org-roam :pin "ad5fca5440e5c8a6b8078013684df43b3e43d773") + (package! org-roam :pin "1267a430431f11035798cc4007c5dd3efe543ced") (when (featurep! :completion company) - (package! company-org-roam :pin "3da3821d1736e0d05a042bd944b74ea1da4a021b"))) + (package! company-org-roam :pin "674c2bd493f571c5323d69279557a6c18ccbd14e"))) ;;; Babel (package! ob-async :pin "80a30b96a007d419ece12c976a81804ede340311") From 4f885ca17676db7c85423fb75e2e08bec729f4bf Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 16 May 2020 05:15:53 -0400 Subject: [PATCH 095/103] Bump :completion ivy abo-abo/swiper@84efa3a -> abo-abo/swiper@04ca164 ericdanan/counsel-projectile@b556ed8 -> ericdanan/counsel-projectile@126e825 mhayashi1120/Emacs-wgrep@5977b8e -> mhayashi1120/Emacs-wgrep@f0ef9bf raxod502/prescient.el@0f4a89b -> raxod502/prescient.el@3ab7605 --- modules/completion/ivy/packages.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/completion/ivy/packages.el b/modules/completion/ivy/packages.el index 05a724417..78f1a9b25 100644 --- a/modules/completion/ivy/packages.el +++ b/modules/completion/ivy/packages.el @@ -1,18 +1,18 @@ ;; -*- no-byte-compile: t; -*- ;;; completion/ivy/packages.el -(package! swiper :pin "84efa3a2cbb9c5b0bbcc8d2e90671434eed74f94") +(package! swiper :pin "04ca16420053a3a6d34a96f0d680dd449c2e5851") (package! ivy) (package! ivy-hydra) (package! counsel) (package! amx :pin "7fb7b874291e0cdeb1f0acb18564a686ec86788d") -(package! counsel-projectile :pin "b556ed8995f375e57496f3482aef4b0def565de8") +(package! counsel-projectile :pin "126e825bbab872b3befd9ef88660571391ebfdc3") (package! ivy-rich :pin "3f818b201769bc13cc75aa73645217e374136aca") -(package! wgrep :pin "5977b8e00051c9003ca96e9d35133e0dea68db2c") +(package! wgrep :pin "f0ef9bfa44db503cdb2f83fcfbd2fa4e2382ef1f") (if (featurep! +prescient) - (package! ivy-prescient :pin "0f4a89bdec61395138d968a38d375e63ccfbed63") + (package! ivy-prescient :pin "3ab7605d997fb8337bf5ded2ad960b98ac0e1fd7") (when (featurep! +fuzzy) (package! flx :pin "17f5c9cb2af18aa6f52910ff4a5a63591261ced5"))) From 49790fb53f5bb468aecbd3474c2bfb2b31dd4606 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 16 May 2020 05:31:33 -0400 Subject: [PATCH 096/103] Include the error when 'doom upgrade' fails --- core/cli/upgrade.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/cli/upgrade.el b/core/cli/upgrade.el index 14d3854ce..cf2a15bfb 100644 --- a/core/cli/upgrade.el +++ b/core/cli/upgrade.el @@ -125,7 +125,8 @@ following shell commands: doom-init-modules-p nil) (doom-initialize)) (error - (signal 'doom-error (list "Could not upgrade Doom without issues")))) + (signal 'doom-error (list "Could not upgrade Doom without issues" + e)))) (print! (success "Finished upgrading Doom Emacs"))) t))))) From 375faedb1b27a8051207662418ef9610f0f1a782 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 16 May 2020 05:38:20 -0400 Subject: [PATCH 097/103] Emit backtrace if doom upgrade fails --- core/cli/upgrade.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cli/upgrade.el b/core/cli/upgrade.el index cf2a15bfb..d346baceb 100644 --- a/core/cli/upgrade.el +++ b/core/cli/upgrade.el @@ -113,7 +113,7 @@ following shell commands: ;; Reload Doom's CLI & libraries, in case there were any ;; upstream changes. Major changes will still break, however - (condition-case e + (condition-case-unless-debug e (progn (mapc (doom-rpartial #'unload-feature t) '(core core-lib From 6241ba2faa817ee15df8522c0e0296a4894626b0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 16 May 2020 17:31:29 -0400 Subject: [PATCH 098/103] Emit fetch output when updating recipe repos --- core/cli/packages.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/cli/packages.el b/core/cli/packages.el index 77e1ca362..a6c7ec4e5 100644 --- a/core/cli/packages.el +++ b/core/cli/packages.el @@ -108,16 +108,18 @@ list remains lean." (recipe package type local-repo) (let ((esc (unless doom-debug-mode "\033[1A")) (ref (straight-vc-get-commit type local-repo)) - newref) + newref output) (print! (start "\033[KUpdating recipes for %s...%s") package esc) (when (straight-vc-fetch-from-remote recipe) (setq output (straight--process-get-output)) (straight-merge-package package) - (or (equal ref (setq newref (straight-vc-get-commit type local-repo))) - (print! (success "\033[K%s updated (%s -> %s)") - package - (doom--abbrev-commit ref) - (doom--abbrev-commit newref))))))) + (unless (equal ref (setq newref (straight-vc-get-commit type local-repo))) + (print! (success "\033[K%s updated (%s -> %s)") + package + (doom--abbrev-commit ref) + (doom--abbrev-commit newref)) + (unless (string-empty-p output) + (print-group! (print! (info "%s" output))))))))) (setq straight--recipe-lookup-cache (make-hash-table :test #'eq) doom--cli-updated-recipes t))) From de78d0cc62ad142784c02b584313050a06bc0780 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 16 May 2020 20:30:00 -0400 Subject: [PATCH 099/103] Fix #3138: infinite loop when reading package! files --- core/core-packages.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/core-packages.el b/core/core-packages.el index ddf7e19a9..83020e72c 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -315,19 +315,19 @@ was installed with." (let (emacs-lisp-mode) (emacs-lisp-mode)) ;; Scrape `package!' blocks from FILE for a comprehensive listing of ;; packages used by this module. - (while (search-forward "(package! " nil t) - (goto-char (match-beginning 0)) + (while (search-forward "(package!" nil t) (let ((ppss (save-excursion (syntax-ppss)))) ;; Don't collect packages in comments or strings - (or (nth 3 ppss) - (nth 4 ppss) - (cl-destructuring-bind (_ name . plist) - (read (current-buffer)) - (push (cons - name (plist-put - plist :modules - (list (doom-module-from-path file)))) - doom-packages)))))))) + (unless (or (nth 3 ppss) + (nth 4 ppss)) + (goto-char (match-beginning 0)) + (cl-destructuring-bind (_ name . plist) + (read (current-buffer)) + (push (cons + name (plist-put + plist :modules + (list (doom-module-from-path file)))) + doom-packages)))))))) (error (signal 'doom-package-error (list (doom-module-from-path file) From 98d7b97d33a0d482d96a5cbd19313d8a36f0487b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 17 May 2020 06:10:34 -0400 Subject: [PATCH 100/103] Fix 'doom run' not (re)executing startup hooks Makes leader keys (among other things) unable to function. --- bin/doom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/doom b/bin/doom index d2dfce4f1..6ce7dc813 100755 --- a/bin/doom +++ b/bin/doom @@ -5,7 +5,7 @@ :; case "$VERSION" in *\ 2[0-5].[0-9]) echo "Detected Emacs $VERSION"; echo "Doom only supports Emacs 26.1 and newer"; echo; exit 2 ;; esac :; DOOMBASE="$(dirname "$0")/.." :; [ "$1" = -d ] || [ "$1" = --debug ] && { shift; export DEBUG=1; } -:; [ "$1" = run ] && { cd "$DOOMBASE"; shift; exec $EMACS -q --no-splash -l init.el "$@"; exit 0; } +:; [ "$1" = run ] && { cd "$DOOMBASE"; shift; exec $EMACS -q --no-splash -l init.el -f doom-run-all-startup-hooks-h "$@"; exit 0; } :; exec $EMACS --no-site-file --script "$0" -- "$@" :; exit 0 From bdd4657e23d9525e98dbe4fbf7e52f508800b1da Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 17 May 2020 20:31:51 -0400 Subject: [PATCH 101/103] Prevent company-abort side-effects suppressing echo-area e.g. some sly commands (like sly-compile-defun) log to the echo area, but company-abort was being called every time normal mode is invoked (which happens more often than you'd think). It would be fine if company-abort noop'ed if company wasn't active, but it doesn't; side effects ensue. --- modules/completion/company/config.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 0a5486de9..31db4b849 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -37,7 +37,14 @@ (unless (featurep! +childframe) ;; Don't persist company popups when switching back to normal mode. ;; `company-box' aborts on mode switch so it doesn't need this. - (add-hook 'evil-normal-state-entry-hook #'company-abort)) + (add-hook! 'evil-normal-state-entry-hook + (defun +company-abort-h () + ;; HACK `company-abort' doesn't no-op if company isn't active; causing + ;; unwanted side-effects, like the suppression of messages in the + ;; echo-area. + ;; REVIEW Revisit this to refactor; shouldn't be necessary! + (when company-candidates + (company-abort))))) ;; Allow users to switch between backends on the fly. E.g. C-x C-s followed ;; by C-x C-n, will switch from `company-yasnippet' to ;; `company-dabbrev-code'. From bbe3cbdaf6dd4c978e95ca6f3215b48cddf2d1af Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 17 May 2020 20:37:07 -0400 Subject: [PATCH 102/103] Activate global-company-mode on doom-first-input-hook --- modules/completion/company/config.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/completion/company/config.el b/modules/completion/company/config.el index 31db4b849..a83a13412 100644 --- a/modules/completion/company/config.el +++ b/modules/completion/company/config.el @@ -2,7 +2,7 @@ (use-package! company :commands company-complete-common company-manual-begin company-grab-line - :after-call pre-command-hook after-find-file + :hook (doom-first-input . global-company-mode) :init (setq company-idle-delay 0.25 company-minimum-prefix-length 2 @@ -52,8 +52,7 @@ :before #'company-begin-backend (company-abort))) - (add-hook 'after-change-major-mode-hook #'+company-init-backends-h 'append) - (global-company-mode +1)) + (add-hook 'after-change-major-mode-hook #'+company-init-backends-h 'append)) (use-package! company-tng From d697ff481e98e4eef509d1c8374eb4a85e6995ae Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 18 May 2020 01:38:22 -0400 Subject: [PATCH 103/103] Update direnv unconditionally in some cases --- modules/tools/direnv/config.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tools/direnv/config.el b/modules/tools/direnv/config.el index 04abdab15..8c50c9064 100644 --- a/modules/tools/direnv/config.el +++ b/modules/tools/direnv/config.el @@ -12,8 +12,8 @@ ;;; Packages (use-package! direnv - :hook (before-hack-local-variables . direnv--maybe-update-environment) - :hook (flycheck-before-syntax-check . direnv--maybe-update-environment) + :hook (before-hack-local-variables . direnv-update-environment) + :hook (flycheck-before-syntax-check . direnv-update-environment) :hook (direnv-envrc-mode . +direnv-envrc-fontify-keywords-h) :config (add-to-list 'direnv-non-file-modes 'vterm-mode)