dev: merging from main and pr7339

This commit is contained in:
Matt Nish-Lapidus 2024-03-29 10:46:41 -04:00
commit 3daf85b919
18 changed files with 78 additions and 86 deletions

View file

@ -89,9 +89,9 @@
(user-error (message "Error: %s" (cadr e)) (user-error (message "Error: %s" (cadr e))
(kill-emacs 2))) (kill-emacs 2)))
;; UX: Abort if the user is using 'doom' as root, unless ~/.config/emacs is ;; UX: Abort if the user is using 'doom' as root, unless $EMACSDIR is owned by
;; owned by root, in which case we assume the user genuinely wants root to be ;; root, in which case we can safely assume the user genuinely wants root to
;; their primary user account for Emacs. ;; be their primary user account for this session.
(when (equal 0 (user-real-uid)) (when (equal 0 (user-real-uid))
(unless (equal 0 (file-attribute-user-id (file-attributes doom-emacs-dir))) (unless (equal 0 (file-attribute-user-id (file-attributes doom-emacs-dir)))
(message (message

View file

@ -55,20 +55,19 @@ Change `$DOOMDIR' with the `--doomdir' option, e.g.
(setq doom-user-dir (expand-file-name "doom/" xdg-config-dir))))) (setq doom-user-dir (expand-file-name "doom/" xdg-config-dir)))))
(if (file-directory-p doom-user-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) (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 ;; Create init.el, config.el & packages.el
(print-group! (print-group!
(mapc (lambda (file) (mapc (lambda (file)
(cl-destructuring-bind (filename . template) file (cl-destructuring-bind (filename . template) file
(if (file-exists-p! filename doom-user-dir) (setq filename (doom-path doom-user-dir filename))
(print! (item "Skipping %s (already exists)") (if (file-exists-p filename)
(path filename)) (print! (item "Skipping %s (already exists)...") (path filename))
(print! (item "Creating %s%s") (relpath doom-user-dir) filename) (print! (item "Creating %s...") (path filename))
(with-temp-file (doom-path doom-user-dir filename) (with-temp-file filename (insert-file-contents template))
(insert-file-contents template))
(print! (success "Done!"))))) (print! (success "Done!")))))
(let ((template-dir (doom-path doom-emacs-dir "templates"))) (let ((template-dir (doom-path doom-emacs-dir "templates")))
`((,doom-module-init-file `((,doom-module-init-file

View file

@ -799,5 +799,31 @@ However, in batch mode, print to stdout instead of stderr."
"/dev/null"))) "/dev/null")))
(apply fn args))) (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) (provide 'doom-cli-packages)
;;; packages.el ends here ;;; packages.el ends here

View file

@ -26,8 +26,8 @@
(noupdate? ("-U") "Don't update any packages") (noupdate? ("-U") "Don't update any packages")
(purge? ("--gc") "Purge orphaned package repos & regraft them") (purge? ("--gc") "Purge orphaned package repos & regraft them")
(jobs ("-j" "--jobs" num) "How many threads to use for native compilation") (jobs ("-j" "--jobs" num) "How many threads to use for native compilation")
(rebuild? ("-b" "--rebuild") "Rebuild, compile, & symlink installed packages") (rebuild? ("-b" "--rebuild") "Rebuild all installed packages, unconditionally")
(auto? ("-B") "Rebuild packages, but only if necessary") (nobuild? ("-B") "Don't rebuild packages when hostname or Emacs version has changed")
&context context) &context context)
"Synchronize your config with Doom Emacs. "Synchronize your config with Doom Emacs.
@ -52,8 +52,6 @@ OPTIONS:
:benchmark t :benchmark t
(when (doom-profiles-bootloadable-p) (when (doom-profiles-bootloadable-p)
(call! '(profiles sync "--reload"))) (call! '(profiles sync "--reload")))
(when (doom-cli-context-suppress-prompts-p context)
(setq auto? t))
(when jobs (when jobs
(setq native-comp-async-jobs-number (truncate jobs))) (setq native-comp-async-jobs-number (truncate jobs)))
(run-hooks 'doom-before-sync-hook) (run-hooks 'doom-before-sync-hook)
@ -75,11 +73,15 @@ OPTIONS:
(when (and old-host (not (equal old-host (system-name)))) (when (and old-host (not (equal old-host (system-name))))
(print! (warn "Your system has changed since last sync")) (print! (warn "Your system has changed since last sync"))
(setq to-rebuild t)) (setq to-rebuild t))
(when (and to-rebuild (not auto?)) (when (and to-rebuild (not (doom-cli-context-suppress-prompts-p context)))
(or (y-or-n-p (cond (nobuild?
(format! " %s" "Your installed packages will need to be recompiled. Do so now?")) (print! (warn "Packages must be rebuilt, but -B has prevented it. Skipping...")))
(exit! 0)) ((doom-cli-context-get context 'upgrading)
(setq rebuild? t))) (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?) (when (and (not noenvvar?)
(file-exists-p doom-env-file)) (file-exists-p doom-env-file))
(call! '(env))) (call! '(env)))
@ -89,7 +91,9 @@ OPTIONS:
(when (doom-profile-generate) (when (doom-profile-generate)
(print! (item "Restart Emacs or use 'M-x doom/reload' for changes to take effect")) (print! (item "Restart Emacs or use 'M-x doom/reload' for changes to take effect"))
(run-hooks 'doom-after-sync-hook)) (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) t)
(remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h))) (remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h)))

View file

@ -21,6 +21,7 @@
(defcli! ((upgrade up)) (defcli! ((upgrade up))
((packages? ("-p" "--packages") "Only upgrade packages, not Doom") ((packages? ("-p" "--packages") "Only upgrade packages, not Doom")
(jobs ("-j" "--jobs" num) "How many CPUs to use for native compilation") (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) &context context)
"Updates Doom and packages. "Updates Doom and packages.
@ -29,10 +30,11 @@ following shell commands:
cd ~/.emacs.d cd ~/.emacs.d
git pull --rebase git pull --rebase
doom clean
doom sync -u" doom sync -u"
(let* ((force? (doom-cli-context-suppress-prompts-p context)) (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 (cond
(packages? (packages?
;; HACK It's messy to use straight to upgrade straight, due to the ;; 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. ;; Reload Doom's CLI & libraries, in case there were any upstream changes.
;; Major changes will still break, however ;; Major changes will still break, however
(print! (item "Reloading Doom Emacs")) (print! (item "Reloading Doom Emacs"))
(doom-cli-context-put context 'upgrading t)
(exit! "doom" "upgrade" "-p" (exit! "doom" "upgrade" "-p"
(if nobuild? "-B")
(if force? "--force") (if force? "--force")
(if jobs (format "--jobs=%d" jobs)))) (if jobs (format "--jobs=%d" jobs))))
@ -95,6 +99,8 @@ following shell commands:
(sh! "git" "reset" "--hard" (format "origin/%s" branch)) (sh! "git" "reset" "--hard" (format "origin/%s" branch))
(sh! "git" "clean" "-ffd"))) (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) (sh! "git" "remote" "remove" doom-upgrade-remote)
(unwind-protect (unwind-protect
(let (result) (let (result)
@ -135,7 +141,6 @@ following shell commands:
(ignore (print! (error "Aborted"))) (ignore (print! (error "Aborted")))
(print! (start "Upgrading Doom Emacs...")) (print! (start "Upgrading Doom Emacs..."))
(print-group! (print-group!
(doom-compile-clean)
(doom-cli-context-put context 'straight-recipe (doom-upgrade--get-straight-recipe)) (doom-cli-context-put context 'straight-recipe (doom-upgrade--get-straight-recipe))
(or (and (zerop (car (sh! "git" "reset" "--hard" target-remote))) (or (and (zerop (car (sh! "git" "reset" "--hard" target-remote)))
(equal (cdr (sh! "git" "rev-parse" "HEAD")) new-rev)) (equal (cdr (sh! "git" "rev-parse" "HEAD")) new-rev))

View file

@ -265,9 +265,12 @@ localleader prefix."
(set-keymap-parent doom-leader-map mode-specific-map)) (set-keymap-parent doom-leader-map mode-specific-map))
((equal doom-leader-alt-key "C-x") ((equal doom-leader-alt-key "C-x")
(set-keymap-parent doom-leader-map ctl-x-map))) (set-keymap-parent doom-leader-map ctl-x-map)))
(define-key map (kbd doom-leader-alt-key) 'doom/leader)) (define-key map (kbd doom-leader-alt-key) #'doom-leader-map)
(evil-define-key* doom-leader-key-states map (kbd doom-leader-key) 'doom/leader) (define-key map (kbd doom-localleader-alt-key) #'doom-localleader-map))
(evil-define-key* doom-leader-alt-key-states map (kbd doom-leader-alt-key) 'doom/leader)) (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)))) (general-override-mode +1))))

View file

@ -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 ;; FIX: Make sure this only runs at startup to protect us Emacs' interpreter
;; re-evaluating this file when lazy-loading dynamic docstrings from the ;; re-evaluating this file when lazy-loading dynamic docstrings from the
;; byte-compiled init file. ;; 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 ,@(cl-loop for var in doom-autoloads-cached-vars
if (boundp var) if (boundp var)
collect `(set-default ',var ',(symbol-value var))) collect `(set-default ',var ',(symbol-value var)))

View file

@ -8,7 +8,7 @@
:config :config
(set-yas-minor-mode! 'emacs-everywhere-mode) (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 ;; because Doom commonly starts servers and other extraneous services on
;; this hook, which will rarely work well in emacs-everywhere's temporary ;; this hook, which will rarely work well in emacs-everywhere's temporary
;; buffers anyway. ;; buffers anyway.

View file

@ -53,7 +53,7 @@ TAB/S-TAB.")
(corfu-mode +1)))) (corfu-mode +1))))
:config :config
(setq corfu-auto t (setq corfu-auto t
corfu-auto-delay 0.1 corfu-auto-delay 0.18
corfu-auto-prefix 2 corfu-auto-prefix 2
global-corfu-modes '((not global-corfu-modes '((not
erc-mode erc-mode

View file

@ -413,20 +413,6 @@ This generally applies to your private config (`doom-user-dir') or Doom's source
;; ;;
;;; Fontification ;;; 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) (defvar +emacs-lisp--face nil)
;;;###autoload ;;;###autoload
(defun +emacs-lisp-highlight-vars-and-faces (end) (defun +emacs-lisp-highlight-vars-and-faces (end)

View file

@ -115,8 +115,6 @@ See `+emacs-lisp-non-package-mode' for details.")
'emacs-lisp-mode 'emacs-lisp-mode
(append `(;; custom Doom cookies (append `(;; custom Doom cookies
("^;;;###\\(autodef\\|if\\|package\\)[ \n]" (1 font-lock-warning-face t))) ("^;;;###\\(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 ;; highlight defined, special variables & functions
(when +emacs-lisp-enable-extra-fontification (when +emacs-lisp-enable-extra-fontification
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face))))) `((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))))

View file

@ -11,8 +11,6 @@
:interpreter ("\\(?:cached-\\)?nix-shell" . +nix-shell-init-mode) :interpreter ("\\(?:cached-\\)?nix-shell" . +nix-shell-init-mode)
:mode "\\.nix\\'" :mode "\\.nix\\'"
:init :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 (add-to-list 'auto-mode-alist
(cons "/flake\\.lock\\'" (cons "/flake\\.lock\\'"
(if (modulep! :lang json) (if (modulep! :lang json)

View file

@ -1,12 +1,12 @@
;; -*- no-byte-compile: t; -*- ;; -*- no-byte-compile: t; -*-
;;; tools/magit/packages.el ;;; tools/magit/packages.el
(when (package! magit :pin "0963697f24cfbe80f92312044bd9ab28b914b053") (when (package! magit :pin "0e8f25a8d8011328f2bf082232c720b24c2a12c2")
(when (modulep! +forge) (when (modulep! +forge)
(package! forge :pin "68771ca4d53c3aea5c860eeb888cee8e9cb5ca37") (package! forge :pin "2a3b41eb6235b3f39c017c1f86b3928a45c5a64d")
(package! code-review (package! code-review
:recipe (:host github :recipe (:host github
:repo "doomelpa/code-review" :repo "doomelpa/code-review"
:files ("graphql" "code-review*.el")) :files ("graphql" "code-review*.el"))
:pin "e4c34fa284da25d8e0bafbae4300f1db5bdcda44")) :pin "e4c34fa284da25d8e0bafbae4300f1db5bdcda44"))
(package! magit-todos :pin "1e9acc0ba63fbc297001bf334d63cb4326be80df")) (package! magit-todos :pin "332ce763f7336ea356964b92723678aa1ed4640f"))

View file

@ -161,12 +161,13 @@ and cannot run in."
(fboundp 'mac-auto-operator-composition-mode)) (fboundp 'mac-auto-operator-composition-mode))
(add-hook 'doom-init-ui-hook #'mac-auto-operator-composition-mode 'append)) (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, ;; This module does not support Emacs 27 and less, but if we still try to
;; it will end up in catastrophic work-loss errors, so we leave the check here for safety. ;; enable ligatures, it will end up in catastrophic work-loss errors, so we
;; leave the check here for safety.
((and (> emacs-major-version 27) ((and (> emacs-major-version 27)
(or (featurep 'ns) (or (featurep 'ns)
(string-match-p "HARFBUZZ" system-configuration-features)) (featurep 'harfbuzz))
(featurep 'composite)) ; Emacs loads `composite' at startup (featurep 'composite)) ; Emacs loads `composite' at startup
(use-package! ligature (use-package! ligature
:config :config

View file

@ -26,7 +26,7 @@ This must be set before `treemacs' has loaded.")
treemacs-persist-file (concat doom-cache-dir "treemacs-persist") treemacs-persist-file (concat doom-cache-dir "treemacs-persist")
treemacs-last-error-persist-file (concat doom-cache-dir "treemacs-last-error-persist")) treemacs-last-error-persist-file (concat doom-cache-dir "treemacs-last-error-persist"))
:config :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) (treemacs-follow-mode -1)
(set-popup-rule! "^ ?\\*Treemacs" :ignore t) (set-popup-rule! "^ ?\\*Treemacs" :ignore t)

View file

@ -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

View file

@ -318,12 +318,7 @@ workspace, otherwise the new workspace is blank."
end of the workspace list." end of the workspace list."
(interactive (interactive
(list (or current-prefix-arg (list (or current-prefix-arg
(if (modulep! :completion ivy) (completing-read "Switch to workspace: " (+workspace-list-names)))))
(ivy-read "Switch to workspace: "
(+workspace-list-names)
:caller #'+workspace/switch-to
:preselect (+workspace-current-name))
(completing-read "Switch to workspace: " (+workspace-list-names))))))
(when (and (stringp index) (when (and (stringp index)
(string-match-p "^[0-9]+$" index)) (string-match-p "^[0-9]+$" index))
(setq index (string-to-number index))) (setq index (string-to-number index)))

View file

@ -206,13 +206,6 @@ stored in `persp-save-dir'.")
("xt" counsel-projectile-switch-project-action-run-term "invoke term from project root") ("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"))) ("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) (when (modulep! :completion helm)
(after! helm-projectile (after! helm-projectile
(setcar helm-source-projectile-projects-actions (setcar helm-source-projectile-projects-actions