diff --git a/bin/doom b/bin/doom index 8104260a8..32504f224 100755 --- a/bin/doom +++ b/bin/doom @@ -89,9 +89,9 @@ (user-error (message "Error: %s" (cadr e)) (kill-emacs 2))) -;; UX: Abort if the user is using 'doom' as root, unless ~/.config/emacs is -;; owned by root, in which case we assume the user genuinely wants root to be -;; their primary user account for Emacs. +;; UX: Abort if the user is using 'doom' as root, unless $EMACSDIR is owned by +;; root, in which case we can safely assume the user genuinely wants root to +;; be their primary user account for this session. (when (equal 0 (user-real-uid)) (unless (equal 0 (file-attribute-user-id (file-attributes doom-emacs-dir))) (message diff --git a/lisp/cli/install.el b/lisp/cli/install.el index 27dad9bc9..3e1e4ef21 100644 --- a/lisp/cli/install.el +++ b/lisp/cli/install.el @@ -55,20 +55,19 @@ Change `$DOOMDIR' with the `--doomdir' option, e.g. (setq doom-user-dir (expand-file-name "doom/" xdg-config-dir))))) (if (file-directory-p doom-user-dir) - (print! (item "Skipping %s (already exists)") (relpath doom-user-dir)) + (print! (item "Skipping %s (already exists)") (path doom-user-dir)) (make-directory doom-user-dir 'parents) - (print! (success "Created %s") (relpath doom-user-dir))) + (print! (success "Created %s") (path doom-user-dir))) ;; Create init.el, config.el & packages.el (print-group! (mapc (lambda (file) (cl-destructuring-bind (filename . template) file - (if (file-exists-p! filename doom-user-dir) - (print! (item "Skipping %s (already exists)") - (path filename)) - (print! (item "Creating %s%s") (relpath doom-user-dir) filename) - (with-temp-file (doom-path doom-user-dir filename) - (insert-file-contents template)) + (setq filename (doom-path doom-user-dir filename)) + (if (file-exists-p filename) + (print! (item "Skipping %s (already exists)...") (path filename)) + (print! (item "Creating %s...") (path filename)) + (with-temp-file filename (insert-file-contents template)) (print! (success "Done!"))))) (let ((template-dir (doom-path doom-emacs-dir "templates"))) `((,doom-module-init-file diff --git a/lisp/cli/packages.el b/lisp/cli/packages.el index 26018ae91..527bfb31b 100644 --- a/lisp/cli/packages.el +++ b/lisp/cli/packages.el @@ -799,5 +799,31 @@ However, in batch mode, print to stdout instead of stderr." "/dev/null"))) (apply fn args))) +;; If the repo failed to clone correctly (usually due to a connection failure), +;; straight proceeds as normal until a later call produces a garbage result +;; (typically, when it fails to fetch the remote branch of the empty directory). +;; This causes Straight to throw an otherwise cryptic type error when it tries +;; to sanitize the result for its log buffer. +;; +;; This error is a common source of user confusion and false positive bug +;; reports, so this advice catches them to regurgitates a more cogent +;; explanation. +(defadvice! doom-cli--straight-throw-error-on-no-branch-a (fn &rest args) + :around #'straight--process-log + (letf! ((defun shell-quote-argument (&rest args) + (unless (car args) + (error "Package was not properly cloned due to a connection failure, please try again later")) + (apply shell-quote-argument args))) + (apply fn args))) + +(defadvice! doom-cli--straight-regurgitate-empty-string-error-a (fn &rest args) + :around #'straight-vc-git-local-repo-name + (condition-case-unless-debug e + (apply fn args) + (wrong-type-argument + (if (eq (cadr e) 'stringp) + (error "Package was not properly cloned due to a connection failure, please try again later") + (signal (car e) (cdr e)))))) + (provide 'doom-cli-packages) ;;; packages.el ends here diff --git a/lisp/cli/sync.el b/lisp/cli/sync.el index f74a97923..6b7274e0e 100644 --- a/lisp/cli/sync.el +++ b/lisp/cli/sync.el @@ -26,8 +26,8 @@ (noupdate? ("-U") "Don't update any packages") (purge? ("--gc") "Purge orphaned package repos & regraft them") (jobs ("-j" "--jobs" num) "How many threads to use for native compilation") - (rebuild? ("-b" "--rebuild") "Rebuild, compile, & symlink installed packages") - (auto? ("-B") "Rebuild packages, but only if necessary") + (rebuild? ("-b" "--rebuild") "Rebuild all installed packages, unconditionally") + (nobuild? ("-B") "Don't rebuild packages when hostname or Emacs version has changed") &context context) "Synchronize your config with Doom Emacs. @@ -52,8 +52,6 @@ OPTIONS: :benchmark t (when (doom-profiles-bootloadable-p) (call! '(profiles sync "--reload"))) - (when (doom-cli-context-suppress-prompts-p context) - (setq auto? t)) (when jobs (setq native-comp-async-jobs-number (truncate jobs))) (run-hooks 'doom-before-sync-hook) @@ -75,11 +73,15 @@ OPTIONS: (when (and old-host (not (equal old-host (system-name)))) (print! (warn "Your system has changed since last sync")) (setq to-rebuild t)) - (when (and to-rebuild (not auto?)) - (or (y-or-n-p - (format! " %s" "Your installed packages will need to be recompiled. Do so now?")) - (exit! 0)) - (setq rebuild? t))) + (when (and to-rebuild (not (doom-cli-context-suppress-prompts-p context))) + (cond (nobuild? + (print! (warn "Packages must be rebuilt, but -B has prevented it. Skipping..."))) + ((doom-cli-context-get context 'upgrading) + (print! (warn "Packages will be rebuilt")) + (setq rebuild? t)) + ((y-or-n-p (format! " %s" "Installed packages must be rebuilt. Do so now?")) + (setq rebuild? t)) + ((exit! 0))))) (when (and (not noenvvar?) (file-exists-p doom-env-file)) (call! '(env))) @@ -89,7 +91,9 @@ OPTIONS: (when (doom-profile-generate) (print! (item "Restart Emacs or use 'M-x doom/reload' for changes to take effect")) (run-hooks 'doom-after-sync-hook)) - (with-temp-file doom-cli-sync-info-file (prin1 (cons emacs-version (system-name)) (current-buffer))) + (when (and (not rebuild?) (not nobuild?)) + (with-temp-file doom-cli-sync-info-file + (prin1 (cons emacs-version (system-name)) (current-buffer)))) t) (remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h))) diff --git a/lisp/cli/upgrade.el b/lisp/cli/upgrade.el index 9f44d6e93..13614c62a 100644 --- a/lisp/cli/upgrade.el +++ b/lisp/cli/upgrade.el @@ -21,6 +21,7 @@ (defcli! ((upgrade up)) ((packages? ("-p" "--packages") "Only upgrade packages, not Doom") (jobs ("-j" "--jobs" num) "How many CPUs to use for native compilation") + (nobuild? ("-B") "Don't rebuild packages when hostname or Emacs version has changed") &context context) "Updates Doom and packages. @@ -29,10 +30,11 @@ following shell commands: cd ~/.emacs.d git pull --rebase - doom clean doom sync -u" (let* ((force? (doom-cli-context-suppress-prompts-p context)) - (sync-cmd (append '("sync" "-u" "-B") (if jobs `("-j" ,num))))) + (sync-cmd (append '("sync" "-u") + (if nobuild? '("-B")) + (if jobs `("-j" ,num))))) (cond (packages? ;; HACK It's messy to use straight to upgrade straight, due to the @@ -53,7 +55,9 @@ following shell commands: ;; Reload Doom's CLI & libraries, in case there were any upstream changes. ;; Major changes will still break, however (print! (item "Reloading Doom Emacs")) + (doom-cli-context-put context 'upgrading t) (exit! "doom" "upgrade" "-p" + (if nobuild? "-B") (if force? "--force") (if jobs (format "--jobs=%d" jobs)))) @@ -95,6 +99,8 @@ following shell commands: (sh! "git" "reset" "--hard" (format "origin/%s" branch)) (sh! "git" "clean" "-ffd"))) + ;; In case of leftover state from a partial/incomplete 'doom upgrade' + (sh! "git" "branch" "-D" target-remote) (sh! "git" "remote" "remove" doom-upgrade-remote) (unwind-protect (let (result) @@ -135,7 +141,6 @@ following shell commands: (ignore (print! (error "Aborted"))) (print! (start "Upgrading Doom Emacs...")) (print-group! - (doom-compile-clean) (doom-cli-context-put context 'straight-recipe (doom-upgrade--get-straight-recipe)) (or (and (zerop (car (sh! "git" "reset" "--hard" target-remote))) (equal (cdr (sh! "git" "rev-parse" "HEAD")) new-rev)) diff --git a/lisp/doom-keybinds.el b/lisp/doom-keybinds.el index 856ea72bb..802993642 100644 --- a/lisp/doom-keybinds.el +++ b/lisp/doom-keybinds.el @@ -265,9 +265,12 @@ localleader prefix." (set-keymap-parent doom-leader-map mode-specific-map)) ((equal doom-leader-alt-key "C-x") (set-keymap-parent doom-leader-map ctl-x-map))) - (define-key map (kbd doom-leader-alt-key) 'doom/leader)) - (evil-define-key* doom-leader-key-states map (kbd doom-leader-key) 'doom/leader) - (evil-define-key* doom-leader-alt-key-states map (kbd doom-leader-alt-key) 'doom/leader)) + (define-key map (kbd doom-leader-alt-key) #'doom-leader-map) + (define-key map (kbd doom-localleader-alt-key) #'doom-localleader-map)) + (evil-define-key* '(normal visual motion) map (kbd doom-leader-key) #'doom-leader-map) + (evil-define-key* '(emacs insert) map (kbd doom-leader-alt-key) #'doom-leader-map) + (evil-define-key* '(normal visual motion) map (kbd doom-localleader-key) #'doom-localleader-map) + (evil-define-key* '(emacs insert) map (kbd doom-localleader-alt-key) #'doom-localleader-map)) (general-override-mode +1)))) diff --git a/lisp/doom-profiles.el b/lisp/doom-profiles.el index 94dd3dd09..26ae373d1 100644 --- a/lisp/doom-profiles.el +++ b/lisp/doom-profiles.el @@ -368,7 +368,8 @@ Defaults to the profile at `doom-profile-default'." ;; FIX: Make sure this only runs at startup to protect us Emacs' interpreter ;; re-evaluating this file when lazy-loading dynamic docstrings from the ;; byte-compiled init file. - `((when (doom-context-p 'init) + `((when (or (doom-context-p 'init) + (doom-context-p 'reload)) ,@(cl-loop for var in doom-autoloads-cached-vars if (boundp var) collect `(set-default ',var ',(symbol-value var))) diff --git a/modules/app/everywhere/config.el b/modules/app/everywhere/config.el index 9f5052784..4e235b7af 100644 --- a/modules/app/everywhere/config.el +++ b/modules/app/everywhere/config.el @@ -8,7 +8,7 @@ :config (set-yas-minor-mode! 'emacs-everywhere-mode) - ;; HACK Inhibit MAJOR-MODE-local-vars-hook in emacs-everywhere buffers, + ;; HACK: Inhibit MAJOR-MODE-local-vars-hook in emacs-everywhere buffers, ;; because Doom commonly starts servers and other extraneous services on ;; this hook, which will rarely work well in emacs-everywhere's temporary ;; buffers anyway. diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index d3f6263c9..0ac23185f 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -53,7 +53,7 @@ TAB/S-TAB.") (corfu-mode +1)))) :config (setq corfu-auto t - corfu-auto-delay 0.1 + corfu-auto-delay 0.18 corfu-auto-prefix 2 global-corfu-modes '((not erc-mode diff --git a/modules/lang/emacs-lisp/autoload.el b/modules/lang/emacs-lisp/autoload.el index d2092fa9c..2fcd75a23 100644 --- a/modules/lang/emacs-lisp/autoload.el +++ b/modules/lang/emacs-lisp/autoload.el @@ -413,20 +413,6 @@ This generally applies to your private config (`doom-user-dir') or Doom's source ;; ;;; Fontification -;;;###autoload -(defun +emacs-lisp-truncate-pin () - "Truncates long SHA1 hashes in `package!' :pin's." - (save-excursion - (goto-char (match-beginning 0)) - (and (stringp (plist-get (sexp-at-point) :pin)) - (search-forward ":pin" nil t) - (let ((start (re-search-forward "\"[^\"\n]\\{12\\}" nil t)) - (finish (and (re-search-forward "\"" (line-end-position) t) - (match-beginning 0)))) - (when (and start finish) - (put-text-property start finish 'display "..."))))) - nil) - (defvar +emacs-lisp--face nil) ;;;###autoload (defun +emacs-lisp-highlight-vars-and-faces (end) diff --git a/modules/lang/emacs-lisp/config.el b/modules/lang/emacs-lisp/config.el index 389589689..4a7b532f8 100644 --- a/modules/lang/emacs-lisp/config.el +++ b/modules/lang/emacs-lisp/config.el @@ -115,8 +115,6 @@ See `+emacs-lisp-non-package-mode' for details.") 'emacs-lisp-mode (append `(;; custom Doom cookies ("^;;;###\\(autodef\\|if\\|package\\)[ \n]" (1 font-lock-warning-face t))) - ;; Shorten the :pin of `package!' statements to 10 characters - `(("(package!\\_>" (0 (+emacs-lisp-truncate-pin)))) ;; highlight defined, special variables & functions (when +emacs-lisp-enable-extra-fontification `((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face))))) diff --git a/modules/lang/nix/config.el b/modules/lang/nix/config.el index 5e6677220..10bfb1731 100644 --- a/modules/lang/nix/config.el +++ b/modules/lang/nix/config.el @@ -11,8 +11,6 @@ :interpreter ("\\(?:cached-\\)?nix-shell" . +nix-shell-init-mode) :mode "\\.nix\\'" :init - ;; Treat flake.lock files as json. Fall back to js-mode because it's faster - ;; than js2-mode, and its extra features aren't needed there. (add-to-list 'auto-mode-alist (cons "/flake\\.lock\\'" (if (modulep! :lang json) diff --git a/modules/tools/magit/packages.el b/modules/tools/magit/packages.el index 7bebc3a57..c48e55650 100644 --- a/modules/tools/magit/packages.el +++ b/modules/tools/magit/packages.el @@ -1,12 +1,12 @@ ;; -*- no-byte-compile: t; -*- ;;; tools/magit/packages.el -(when (package! magit :pin "0963697f24cfbe80f92312044bd9ab28b914b053") +(when (package! magit :pin "0e8f25a8d8011328f2bf082232c720b24c2a12c2") (when (modulep! +forge) - (package! forge :pin "68771ca4d53c3aea5c860eeb888cee8e9cb5ca37") + (package! forge :pin "2a3b41eb6235b3f39c017c1f86b3928a45c5a64d") (package! code-review :recipe (:host github :repo "doomelpa/code-review" :files ("graphql" "code-review*.el")) :pin "e4c34fa284da25d8e0bafbae4300f1db5bdcda44")) - (package! magit-todos :pin "1e9acc0ba63fbc297001bf334d63cb4326be80df")) + (package! magit-todos :pin "332ce763f7336ea356964b92723678aa1ed4640f")) diff --git a/modules/ui/ligatures/config.el b/modules/ui/ligatures/config.el index 6312493ba..ad8baab5e 100644 --- a/modules/ui/ligatures/config.el +++ b/modules/ui/ligatures/config.el @@ -161,12 +161,13 @@ and cannot run in." (fboundp 'mac-auto-operator-composition-mode)) (add-hook 'doom-init-ui-hook #'mac-auto-operator-composition-mode 'append)) - ;; NOTE: the module does not support Emacs 27 and less, but if we still try to enable ligatures, - ;; it will end up in catastrophic work-loss errors, so we leave the check here for safety. + ;; This module does not support Emacs 27 and less, but if we still try to + ;; enable ligatures, it will end up in catastrophic work-loss errors, so we + ;; leave the check here for safety. ((and (> emacs-major-version 27) (or (featurep 'ns) - (string-match-p "HARFBUZZ" system-configuration-features)) - (featurep 'composite)) ; Emacs loads `composite' at startup + (featurep 'harfbuzz)) + (featurep 'composite)) ; Emacs loads `composite' at startup (use-package! ligature :config diff --git a/modules/ui/treemacs/config.el b/modules/ui/treemacs/config.el index d232ec1b0..62e3e6ddb 100644 --- a/modules/ui/treemacs/config.el +++ b/modules/ui/treemacs/config.el @@ -26,7 +26,7 @@ This must be set before `treemacs' has loaded.") treemacs-persist-file (concat doom-cache-dir "treemacs-persist") treemacs-last-error-persist-file (concat doom-cache-dir "treemacs-last-error-persist")) :config - ;; Don't follow the cursor + ;; Don't follow the cursor (it's more disruptive/jarring than helpful as a default) (treemacs-follow-mode -1) (set-popup-rule! "^ ?\\*Treemacs" :ignore t) diff --git a/modules/ui/workspaces/autoload/ivy.el b/modules/ui/workspaces/autoload/ivy.el deleted file mode 100644 index 97b84baf4..000000000 --- a/modules/ui/workspaces/autoload/ivy.el +++ /dev/null @@ -1,17 +0,0 @@ -;;; ui/workspaces/autoload/ivy.el -*- lexical-binding: t; -*- -;;;###if (modulep! :completion ivy) - -;;;###autoload -(defun +workspace--ivy-rich-preview (workspace) - (if-let (buffers (when-let (workspace (gethash workspace *persp-hash*)) - (cl-loop for (type . rest) in (persp-window-conf workspace) - if (eq type 'buffer) - collect (car leaf) - else if (eq type 'leaf) - append (cl-loop for (type . leaf) in rest - if (eq type 'buffer) - collect (car leaf))))) - (string-join buffers " ") - "*No buffers*")) - -;;; ivy.el ends here diff --git a/modules/ui/workspaces/autoload/workspaces.el b/modules/ui/workspaces/autoload/workspaces.el index 840ca1d5c..4cca0c7a8 100644 --- a/modules/ui/workspaces/autoload/workspaces.el +++ b/modules/ui/workspaces/autoload/workspaces.el @@ -318,12 +318,7 @@ workspace, otherwise the new workspace is blank." end of the workspace list." (interactive (list (or current-prefix-arg - (if (modulep! :completion ivy) - (ivy-read "Switch to workspace: " - (+workspace-list-names) - :caller #'+workspace/switch-to - :preselect (+workspace-current-name)) - (completing-read "Switch to workspace: " (+workspace-list-names)))))) + (completing-read "Switch to workspace: " (+workspace-list-names))))) (when (and (stringp index) (string-match-p "^[0-9]+$" index)) (setq index (string-to-number index))) diff --git a/modules/ui/workspaces/config.el b/modules/ui/workspaces/config.el index 68c5d9221..0fb223bf2 100644 --- a/modules/ui/workspaces/config.el +++ b/modules/ui/workspaces/config.el @@ -206,13 +206,6 @@ stored in `persp-save-dir'.") ("xt" counsel-projectile-switch-project-action-run-term "invoke term from project root") ("X" counsel-projectile-switch-project-action-org-capture "org-capture into project"))) - (when (modulep! :completion ivy) - (after! ivy-rich - (cl-callf plist-put ivy-rich-display-transformers-list - '+workspace/switch-to - '(:columns ((ivy-rich-candidate (:width 50)) - (+workspace--ivy-rich-preview)))))) - (when (modulep! :completion helm) (after! helm-projectile (setcar helm-source-projectile-projects-actions