From 689dc6a1e4b0aab9e94143e6bf7ccad8953bf411 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 19 Jun 2021 19:42:22 +0100 Subject: [PATCH] fix(editor): improve filtering performance of M-x when marginalia is active The default 'marginalia-annotate-command annotation method for M-x candidates has a small but perceivable performance impact as you type. The 'marginalia-annotate-binding method does not have any perceivable performance impact. Also I only really care about seeing keybindings in the M-x list, I can definitely live without command descriptions. --- modules/editor/siren-marginalia.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/editor/siren-marginalia.el b/modules/editor/siren-marginalia.el index 11894fb..9f413ef 100644 --- a/modules/editor/siren-marginalia.el +++ b/modules/editor/siren-marginalia.el @@ -10,7 +10,22 @@ :bind (:map minibuffer-local-map ("M-A" . marginalia-cycle)) :init - (marginalia-mode +1)) + (marginalia-mode +1) + + (defun siren-marginalia-setup () + (interactive) + (mapc + (lambda (x) + (pcase (car x) + ;; Default command category to 'marginalia-annotate-binding instead of + ;; 'marginalia-annotate-command which has a slight performance impact + ;; when filtering M-x candidates. + ('command (setcdr x (cons 'marginalia-annotate-binding + (remq 'marginalia-annotate-binding (cdr x))))))) + marginalia-annotator-registry)) + + :config + (siren-marginalia-setup)) (provide 'siren-marginalia) ;;; siren-marginalia.el ends here