From 67e5dda526597c2797bec632d92a3577edc92133 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 20 Aug 2024 16:27:34 -0400 Subject: [PATCH 01/13] fix(format): void-function +javascript-npm-conf error Amend: c0a1b9efc9a8 Close: #8005 --- modules/editor/format/config.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/editor/format/config.el b/modules/editor/format/config.el index cbd1ea30c..3b011cbee 100644 --- a/modules/editor/format/config.el +++ b/modules/editor/format/config.el @@ -102,5 +102,9 @@ This is controlled by `+format-on-save-disabled-modes'." ".prettierrc.toml") if (locate-dominating-file default-directory file) return t) - (assq 'prettier (+javascript-npm-conf))) + (when-let ((pkg (locate-dominating-file default-directory "package.json"))) + (require 'json) + (let ((json-key-type 'alist)) + (assq 'prettier + (json-read-file (expand-file-name "package.json" pkg)))))) (apheleia-formatters-indent "--use-tabs" "--tab-width")))))))) From abf19aa63e67ca92b2caa94d947cfb59d7a4ee4e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 20 Aug 2024 16:36:22 -0400 Subject: [PATCH 02/13] tweak(format): +format/region: emit message on success --- modules/editor/format/autoload/format.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/editor/format/autoload/format.el b/modules/editor/format/autoload/format.el index 44498cfa2..fe78af107 100644 --- a/modules/editor/format/autoload/format.el +++ b/modules/editor/format/autoload/format.el @@ -68,14 +68,21 @@ (defalias '+format/buffer #'apheleia-format-buffer) ;;;###autoload -(defun +format/region (beg end &optional _arg) +(defun +format/region (beg end &optional _arg interactive) "Format the selected region. WARNING: if the formatter doesn't support partial formatting, this command tries to pretend the active selection is the contents of a standalone file, but this may not always work. Keep your undo keybind handy!" - (interactive "rP") - (+format-region beg end)) + (interactive (list (doom-region-beginning) + (doom-region-end) + current-prefix-arg + 'interactive)) + (+format-region + beg end + (lambda () + (when interactive + (message "Region reformatted!"))))) ;;;###autoload (defun +format/region-or-buffer () From d1e5a285fe6a53200f354c0c46c5315075db5f05 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 20 Aug 2024 16:44:23 -0400 Subject: [PATCH 03/13] fix(vc): git-timemachine: enable font-lock-mode --- modules/emacs/vc/config.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/emacs/vc/config.el b/modules/emacs/vc/config.el index d0a4f2190..dd2f47c7c 100644 --- a/modules/emacs/vc/config.el +++ b/modules/emacs/vc/config.el @@ -92,6 +92,10 @@ info in the `header-line-format' is a more visible indicator." (propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face) date-full date-relative)))) + ;; HACK: `delay-mode-hooks' suppresses font-lock-mode in later versions of + ;; Emacs, so git-timemachine buffers end up unfontified. + (add-hook 'git-timemachine-mode-hook #'font-lock-mode) + (after! evil ;; Rehash evil keybindings so they are recognized (add-hook 'git-timemachine-mode-hook #'evil-normalize-keymaps)) From c1c3b521d6c9af240f6841a0994f95149811ffea Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 20 Aug 2024 18:07:42 -0400 Subject: [PATCH 04/13] bump: :editor evil emacs-evil/evil-collection@e49d8e96ccc8 -> emacs-evil/evil-collection@772571fc6762 emacs-evil/evil@30ebe6df27c3 -> emacs-evil/evil@5db0bdc7dcd9 --- modules/editor/evil/init.el | 2 ++ modules/editor/evil/packages.el | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/editor/evil/init.el b/modules/editor/evil/init.el index 3b754c2d0..3b10badab 100644 --- a/modules/editor/evil/init.el +++ b/modules/editor/evil/init.el @@ -116,6 +116,7 @@ variable for an explanation of the defaults (in comments). See (csv "csv-mode") (custom cus-edit) cus-theme + dape dashboard daemons deadgrep @@ -175,6 +176,7 @@ variable for an explanation of the defaults (in comments). See helpful hg-histedit hungry-delete + hyrolo ibuffer (image image-mode) image-dired diff --git a/modules/editor/evil/packages.el b/modules/editor/evil/packages.el index 4b11e3582..41f09ff0e 100644 --- a/modules/editor/evil/packages.el +++ b/modules/editor/evil/packages.el @@ -1,7 +1,7 @@ ;; -*- no-byte-compile: t; -*- ;;; editor/evil/packages.el -(package! evil :pin "30ebe6df27c36fdf2ea3c82a916edec31acc2647") +(package! evil :pin "5db0bdc7dcd9300b983526d37cbe480f35e36211") (package! evil-args :pin "a8151556f63c9d45d0c44c8a7ef9e5a542f3cdc7") (package! evil-easymotion :pin "f96c2ed38ddc07908db7c3c11bcd6285a3e8c2e9") (package! evil-embrace :pin "3081d37811b6a3dfaaf01d578c7ab7a746c6064d") @@ -35,4 +35,4 @@ (package! neotree) (autoload 'neotree-make-executor "neotree" nil nil 'macro)) - (package! evil-collection :pin "e49d8e96ccc83d2bf7583c124582fc1ef076b15c")) + (package! evil-collection :pin "772571fc6762b6cd1d35cc869e266de9a5c6022b")) From 41dab49c17041aab84bb667c4caee19661a17d9b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 20 Aug 2024 21:36:08 -0400 Subject: [PATCH 05/13] fix(biblio): s/+roam/+roam2 This change accidentally snuck into 109aa2c. Fix: #8008 Amend: 109aa2c15963 --- modules/tools/biblio/packages.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/tools/biblio/packages.el b/modules/tools/biblio/packages.el index 968c31dac..9c140f415 100644 --- a/modules/tools/biblio/packages.el +++ b/modules/tools/biblio/packages.el @@ -10,7 +10,7 @@ (when (modulep! :completion vertico) (package! citar :pin "07d2a63c99fe35cbd468f8e6a322de05f1a29469") (package! citar-embark :pin "07d2a63c99fe35cbd468f8e6a322de05f1a29469") - (when (modulep! :lang org +roam) + (when (modulep! :lang org +roam2) (package! citar-org-roam :pin "82d47b5df1926627f56a09055c69b49b31cbbb9f"))) (package! parsebib :pin "ace9df707108b17759c004c7387655277122d4c1") From 5e70fe169764bd272e73adbe56d67251fe9a886a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 20 Aug 2024 21:41:12 -0400 Subject: [PATCH 06/13] bump: :tools magit magit/forge@a56eb3cbb27c -> magit/forge@1e7ee99c7f76 magit/magit@cf94190410ef -> magit/magit@3b37048688e5 Due to a force push upstream, the magit ref we were pinned to no longer worked, prompting this bump. Fix: #8007 --- modules/tools/magit/packages.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/tools/magit/packages.el b/modules/tools/magit/packages.el index eae7e87f0..0c4a6bcc1 100644 --- a/modules/tools/magit/packages.el +++ b/modules/tools/magit/packages.el @@ -1,9 +1,9 @@ ;; -*- no-byte-compile: t; -*- ;;; tools/magit/packages.el -(package! magit :pin "cf94190410ef163fd102cdbcb67f28599d31eabc") +(package! magit :pin "3b37048688e50ba5897945ce08eeaed34433c9b7") (when (modulep! +forge) - (package! forge :pin "a56eb3cbb27c61387d35cbff6b036a2c1bc1559d") + (package! forge :pin "1e7ee99c7f76034e40210a6fd6007015b1998f6d") (package! code-review :recipe (:host github :repo "doomelpa/code-review" From c78e49e862d4f3b5351968709a099eaf6d557cc6 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 20 Aug 2024 21:49:10 -0400 Subject: [PATCH 07/13] tweak(corfu): corfu-auto-delay = 0.24 Increase the delay slightly, to stave off slowness with slower backends. --- modules/completion/corfu/config.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/completion/corfu/config.el b/modules/completion/corfu/config.el index f368d1a69..46be4ad0f 100644 --- a/modules/completion/corfu/config.el +++ b/modules/completion/corfu/config.el @@ -56,7 +56,7 @@ TAB/S-TAB.") (corfu-mode +1)))) :config (setq corfu-auto t - corfu-auto-delay 0.18 + corfu-auto-delay 0.24 corfu-auto-prefix 2 global-corfu-modes '((not erc-mode circe-mode From f3e9920e802bb19cd77a463af944dd3fabe3ef90 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 21 Aug 2024 00:11:21 -0400 Subject: [PATCH 08/13] bump: magit magit/magit@3b37048688e5 -> magit/magit@2da34f1317c6 - Whoops. The HEAD of magit's melpa branch is auto-generated and rebased to the front, so pinning to its HEAD will always eventually break. Fix: #8007 Amend: 5e70fe169764 --- modules/emacs/vc/packages.el | 2 +- modules/tools/magit/packages.el | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/emacs/vc/packages.el b/modules/emacs/vc/packages.el index 6fe091a4f..d471201e1 100644 --- a/modules/emacs/vc/packages.el +++ b/modules/emacs/vc/packages.el @@ -6,7 +6,7 @@ (package! smerge-mode :built-in t) (package! browse-at-remote :pin "76aa27dfd469fcae75ed7031bb73830831aaccbf") -(package! git-commit :pin "55656a31cc4fe6c8996c621f4cf14aa4a1bfe47d") +(package! git-commit :pin "2da34f1317c619ec2dfb9e0d969449261ca7f31f") (package! git-timemachine ;; The original lives on codeberg.org; which has uptime issues. :recipe (:host github :repo "emacsmirror/git-timemachine") diff --git a/modules/tools/magit/packages.el b/modules/tools/magit/packages.el index 0c4a6bcc1..ea1a2db1b 100644 --- a/modules/tools/magit/packages.el +++ b/modules/tools/magit/packages.el @@ -1,7 +1,10 @@ ;; -*- no-byte-compile: t; -*- ;;; tools/magit/packages.el -(package! magit :pin "3b37048688e50ba5897945ce08eeaed34433c9b7") +;; NOTE: Always bump this to HEAD~1, not HEAD, because the latest commit on +;; magit's melpa branch is auto-generated and moved to HEAD every time there's +;; a commit to its main branch. +(package! magit :pin "2da34f1317c619ec2dfb9e0d969449261ca7f31f") (when (modulep! +forge) (package! forge :pin "1e7ee99c7f76034e40210a6fd6007015b1998f6d") (package! code-review From a6c3c6842a4cd282c2a23d3ff1bc3d6fd98cdb96 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 21 Aug 2024 02:11:55 -0400 Subject: [PATCH 09/13] refactor(dired): use dirvish-preview-environment - Remove +dired--suppress-hooks-in-previews-a, because Dirvish already does this. - Exploit dirvish-preview-environment instead of hardcoding the enable-local-variables let-binding for the child process. Its defaults are more reasonable. --- modules/emacs/dired/config.el | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index 37cc5a292..5521bea09 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -199,18 +199,13 @@ Fixes #3939: unsortable dired entries on Windows." (if (and (file-directory-p (car args)) (eq (car-safe result) 'dired)) `(dired . (,@(butlast (cdr result)) - ,(format "(let ((enable-local-variables nil)) %s)" + ,(format "(let %s %s)" + (prin1-to-string + (mapcar (lambda (env) `(,(car env) ,(cdr env))) + (remove '(inhibit-message . t) dirvish-preview-environment))) (car (last (cdr result)))))) result))) - ;; HACK: Suppress mode hooks when previewing files, as they may contain - ;; expensive or disruptive functionality that isn't needed just for - ;; previewing them. - ;; REVIEW: Upstream this later? - (defadvice! +dired--suppress-hooks-in-previews-a (fn &rest args) - :around #'dirvish--find-file-temporarily - (delay-mode-hooks (apply fn args))) - ;; HACK: Dirvish will complain that pdf-tools is required to preview PDFs, ;; even if the package is installed, so I advise it to try autoloading it ;; before complaining, otherwise complain if epdfinfo hasn't been built yet. From 4ed3e75f5f89b2907d7e78b6701bb0ad7acef273 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 21 Aug 2024 02:14:57 -0400 Subject: [PATCH 10/13] fix(dired): fail gracefully if pdf-tools isn't installed Will throw a "void-variable pdf-info-epdfinfo-program" error if pdf-tools isn't installed (or `:tools pdf` is disabled). --- modules/emacs/dired/config.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index 5521bea09..e94673551 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -213,8 +213,8 @@ Fixes #3939: unsortable dired entries on Windows." (defadvice! +dired--autoload-pdf-tools-a (fn &rest args) :around #'dirvish-pdf-dp (when (equal (nth 1 args) "pdf") - (require 'pdf-tools nil t) - (if (file-exists-p pdf-info-epdfinfo-program) + (if (and (require 'pdf-tools nil t) + (file-exists-p pdf-info-epdfinfo-program)) (apply fn args) '(info . "`epdfinfo' program required to preview pdfs; run `M-x pdf-tools-install'"))))) From fe15b1daf335544d3c85d84746394a4711325c4c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 21 Aug 2024 03:22:38 -0400 Subject: [PATCH 11/13] fix(dired): remove keybind to nonexistent command Amend: e82dab325727 Co-authored-by: kalwk --- modules/emacs/dired/config.el | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index e94673551..c303ec911 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -143,7 +143,6 @@ Fixes #3939: unsortable dired entries on Windows." :n "F" #'dirvish-layout-toggle :n "z" #'dirvish-history-jump :n "gh" #'dirvish-subtree-up - :n "gl" #'dirvish-subtree-down :m "[h" #'dirvish-history-go-backward :m "]h" #'dirvish-history-go-forward :m "[e" #'dirvish-emerge-next-group From ded3f5ec834942044b5caae6ca220270660b466b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 21 Aug 2024 04:33:06 -0400 Subject: [PATCH 12/13] fix(vc-gutter): runaway diff-hl threads & immortal buffers This was an elusive bug caused by two upstream behaviors: 1. `kill-buffer` will silently refuse to kill a buffer if there is a thread associated with it. 2. `global-diff-hl-mode` activates `diff-hl-mode` in *most* buffers, even invisible ones. This calls `diff-hl-update` each time it does. This isn't a problem *unless* you have `diff-hl-update-async` enabled, because it creates a thread every time `diff-hl-update` is called. That means for every buffer -- real or transient -- you have a new thread queued. And this caused two main issues: 1. Temporary buffers are often opened and closed very rapidly (often faster than the thread can complete), so they weren't getting cleaned up. I hope you weren't too attached to your memory, because you'll have a lot of buried buffers to feed before long! 2. In cases where `diff-hl-update` simply takes a long time, multiple calls to it would queue more threads. When Emacs eventually yields the CPU to them, you'll get random, impossible-to-predict-or-track-down freezes. Joy! This may very well be enough reason to disable `diff-hl-update-async` by default, but I didn't want to give up on it *just* yet, despite how inelegant this solution is... Fix: #7954 Fix: #7991 --- modules/ui/vc-gutter/config.el | 55 ++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/modules/ui/vc-gutter/config.el b/modules/ui/vc-gutter/config.el index 342848be7..17c976359 100644 --- a/modules/ui/vc-gutter/config.el +++ b/modules/ui/vc-gutter/config.el @@ -83,7 +83,6 @@ Respects `diff-hl-disable-on-remote'." (setq diff-hl-flydiff-delay 0.5) ; default: 0.3 ;; PERF: don't block Emacs when updating vc gutter (setq diff-hl-update-async t) - ;; UX: get realtime feedback in diffs after staging/unstaging hunks. (setq diff-hl-show-staged-changes nil) @@ -140,4 +139,56 @@ Respects `diff-hl-disable-on-remote'." :around #'diff-hl-revert-hunk (let ((pt (point))) (prog1 (apply fn args) - (goto-char pt))))) + (goto-char pt)))) + + ;; FIX: `global-diff-hl-mode' enables `diff-hl-mode' *everywhere*, which calls + ;; `diff-hl-update'. If `diff-hl-update-async' is non-nil, this means a new + ;; thread is spawned for *every* buffer, whether they're visible or not. Not + ;; only can this slow a lot down, but `kill-buffer' will silently refuse to + ;; kill buffers with a thread associated with it. Chaos ensues (see #7991 + ;; and #7954). + ;; REVIEW: Report this upstream. + (defun +vc-gutter--kill-thread (&optional block?) + (when-let ((th +vc-gutter--diff-hl-thread)) + (when (thread-live-p th) + (thread-signal th 'quit nil) + (when block? + (condition-case _ + (thread-join th) + ((quit error) nil)))))) + + (defvar-local +vc-gutter--diff-hl-thread nil) + (defadvice! +vc-gutter--debounce-threads-a (&rest _) + :override #'diff-hl-update + (unless (or inhibit-redisplay + non-essential + delay-mode-hooks + (null (buffer-file-name (buffer-base-buffer))) + (null (get-buffer-window (current-buffer)))) + (if (and diff-hl-update-async + (not + (run-hook-with-args-until-success 'diff-hl-async-inhibit-functions + default-directory))) + (progn + (+vc-gutter--kill-thread) + (setq +vc-gutter--diff-hl-thread + (make-thread (lambda () + (unwind-protect + (diff-hl--update-safe) + (setq +vc-gutter--diff-hl-thread nil))) + "diff-hl--update-safe"))) + (diff-hl--update)) + t)) + + (defadvice! +vc-gutter--only-tick-on-success-a (&rest _) + :override #'diff-hl-update-once + (unless (equal diff-hl--modified-tick (buffer-chars-modified-tick)) + (when (diff-hl-update) + (setq diff-hl--modified-tick (buffer-chars-modified-tick))))) + + ;; HACK: This advice won't work in *all* cases (it's a C function, and any + ;; calls to it from C won't trigger advice), but the thread issues above are + ;; triggered from Elisp's buffer API (from what I can tell). + (defadvice! +vc-gutter--kill-diff-hl-thread-a (buf) + :before #'kill-buffer + (with-current-buffer buf (+vc-gutter--kill-thread t)))) From ff9c59df468bcba569067f3c72c5c05b26c0d00a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 21 Aug 2024 05:01:45 -0400 Subject: [PATCH 13/13] tweak(vc-gutter): disable diff-hl-mode in pdf-view-mode --- modules/ui/vc-gutter/config.el | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ui/vc-gutter/config.el b/modules/ui/vc-gutter/config.el index 17c976359..80b3f2314 100644 --- a/modules/ui/vc-gutter/config.el +++ b/modules/ui/vc-gutter/config.el @@ -77,6 +77,7 @@ Respects `diff-hl-disable-on-remote'." :config (set-popup-rule! "^\\*diff-hl" :select nil :size '+popup-shrink-to-fit) + (setq diff-hl-global-modes '(not image-mode pdf-view-mode)) ;; PERF: A slightly faster algorithm for diffing. (setq vc-git-diff-switches '("--histogram")) ;; PERF: Slightly more conservative delay before updating the diff