From 6f709a934d712e2cf730a4ec76eda13d3754779e Mon Sep 17 00:00:00 2001 From: wangtianshu Date: Fri, 22 Apr 2022 14:59:32 +0800 Subject: [PATCH] speedup general https://github.com/noctuid/general.el/pull/503 --- lisp/core-keybinds.el | 55 +++++++++++++++++++++------------------ lisp/editor-completion.el | 8 +++--- lisp/editor-mail.el | 3 ++- lisp/editor-misc.el | 42 ++++++++++++++++-------------- lisp/editor-vsc.el | 6 ++--- lisp/lang-emacs-lisp.el | 6 ++--- lisp/lang-latex.el | 20 +++++++------- lisp/lang-misc.el | 14 +++++----- lisp/lang-org.el | 28 ++++++++++---------- 9 files changed, 96 insertions(+), 86 deletions(-) diff --git a/lisp/core-keybinds.el b/lisp/core-keybinds.el index 39f68615..15603054 100644 --- a/lisp/core-keybinds.el +++ b/lisp/core-keybinds.el @@ -24,11 +24,16 @@ :straight t :after evil :config - (general-create-definer tyrant-def - :states '(normal insert motion emacs) - :keymaps 'override - :prefix "SPC" - :non-normal-prefix "M-SPC") + (setq general-emit-autoloads nil) + + (general-define-key + :states '(normal insert motion emacs) + :keymaps 'override + :prefix-map 'tyrant-map + :prefix "SPC" + :non-normal-prefix "M-SPC") + + (general-create-definer tyrant-def :keymaps 'tyrant-map) (tyrant-def "" nil) (general-create-definer despot-def @@ -43,16 +48,16 @@ "SPC u" 'universal-argument-more) (tyrant-def - "SPC" '(execute-extended-command :which-key "M-x") - "TAB" '(alternate-buffer :whick-key "last buffer") - "!" '(shell-command :which-key "shell cmd") + "SPC" '("M-x" . execute-extended-command) + "TAB" '("last buffer" . alternate-buffer) + "!" '("shell cmd" . shell-command) - "a" '(:ignore t :which-key "applications") + "a" (cons "applications" (make-sparse-keymap)) "ac" 'calc-dispatch "ap" 'list-processes "aP" 'proced - "b" '(:ignore t :which-key "buffers") + "b" (cons "buffers" (make-sparse-keymap)) "bb" 'switch-to-buffer "bB" 'ibuffer "bd" 'kill-current-buffer @@ -61,7 +66,7 @@ "bu" 'reopen-killed-buffer "bx" 'kill-buffer-and-window - "c" '(:ignore t :which-key "code") + "c" (cons "code" (make-sparse-keymap)) "cb" 'flymake-show-buffer-diagnostics "cc" 'compile "cn" 'next-error @@ -70,8 +75,8 @@ "cx" 'kill-compilation "c=" 'indent-region-or-buffer - "f" '(:ignore t :which-key "files") - "fC" '(write-file :which-key "copy-file") + "f" (cons "files" (make-sparse-keymap)) + "fC" '("copy-file" . write-file) "fD" 'delete-current-buffer-file "fe" 'find-library "fE" 'sudo-edit @@ -82,18 +87,18 @@ "fr" 'read-only-mode "fR" 'rename-current-buffer-file "fs" 'save-buffer - "fv" '(:ignore t :which-key "variables") + "fv" (cons "variables" (make-sparse-keymap)) "fvd" 'add-dir-local-variable "fvf" 'add-file-local-variable "fvp" 'add-file-local-variable-prop-line - "F" '(:ignore t :which-key "frame") + "F" (cons "frame" (make-sparse-keymap)) "Fd" 'delete-frame "FD" 'delete-other-frames "Fn" 'make-frame "Fo" 'other-frame - "h" '(:ignore t :which-key "help") + "h" (cons "help" (make-sparse-keymap)) "ha" 'apropos "hb" 'describe-bindings "hc" 'describe-char @@ -108,32 +113,32 @@ "hp" 'describe-package "ht" 'describe-text-properties "hv" 'describe-variable - "hP" '(:ignore t :which-key "profiler") + "hP" (cons "profiler" (make-sparse-keymap)) "hPs" 'profiler-start "hPk" 'profiler-stop "hPr" 'profiler-report - "j" '(:ignore t :which-key "jump") + "j" (cons "jump" (make-sparse-keymap)) "ji" 'imenu "jg" 'avy-goto-char-2 - "m" '(:ignore t :which-key "major mode") + "m" (cons "major mode" (make-sparse-keymap)) - "p" '(:keymap project-prefix-map :which-key "projects") + "p" (cons "projects" project-prefix-map) - "q" '(:ignore t :which-key "quit") + "q" (cons "quit" (make-sparse-keymap)) "qd" 'restart-emacs-debug-init "qr" 'restart-emacs "qR" 'restart-emacs-without-desktop "qq" 'save-buffers-kill-terminal "qQ" 'kill-emacs - "s" '(:ignore t :which-key "spelling") + "s" (cons "spelling" (make-sparse-keymap)) "sb" 'flyspell-buffer "sn" 'flyspell-goto-next-error "sr" 'flyspell-region - "T" '(:ignore t :which-key "toggles") + "T" (cons "toggles" (make-sparse-keymap)) "Ta" 'auto-fill-mode "Td" 'toggle-debug-on-error "Tf" 'display-fill-column-indicator-mode @@ -144,9 +149,9 @@ "Tw" 'whitespace-mode "TW" 'toggle-word-wrap - "u" '(universal-argument :which-key "universal arg") + "u" '("universal arg" . universal-argument) - "w" '(:ignore t :which-key "windows") + "w" (cons "windows" (make-sparse-keymap)) "w TAB" 'alternate-window "w+" 'window-layout-toggle "wb" 'switch-to-minibuffer-window diff --git a/lisp/editor-completion.el b/lisp/editor-completion.el index c7158720..ea3edbf7 100644 --- a/lisp/editor-completion.el +++ b/lisp/editor-completion.el @@ -88,10 +88,10 @@ [remap imenu] 'consult-imenu [remap apropos] 'consult-apropos) (tyrant-def - "jI" '(consult-imenu-multi :which-key "imenu-multi") - "fl" '(consult-find :which-key "locate-files") - "jj" '(consult-line :which-key "search lines") - "jJ" '(consult-line-multi :which-key "search lines a/ buffers") + "jI" '("imenu-multi" . consult-imenu-multi) + "fl" '("locate-files" . consult-find) + "jj" '("search lines" . consult-line) + "jJ" '("search lines a/ buffers" . consult-line-multi) "Tt" 'consult-minor-mode-menu) (org-mode-map [remap consult-imenu] 'consult-org-heading diff --git a/lisp/editor-mail.el b/lisp/editor-mail.el index 1a2ebb40..045d2e81 100644 --- a/lisp/editor-mail.el +++ b/lisp/editor-mail.el @@ -10,7 +10,8 @@ (use-package mu4e :load-path "/usr/local/share/emacs/site-lisp/mu/mu4e" - :commands (mu4e-org-open + :commands (mu4e + mu4e-org-open mu4e-org-store-link) :init (setq mu4e-maildir "$XDG_DATA_HOME/mail" diff --git a/lisp/editor-misc.el b/lisp/editor-misc.el index 9578a59b..991374d6 100644 --- a/lisp/editor-misc.el +++ b/lisp/editor-misc.el @@ -253,6 +253,10 @@ reuse it's window, otherwise create new one." (use-package winum :straight t :hook (after-init . winum-mode) + :init + (with-eval-after-load 'which-key + (push '((nil . "winum-select-window-[1-9]") . t) which-key-replacement-alist) + (push '((nil . "buffer-to-window-[1-9]") . t) which-key-replacement-alist)) :config (setq winum-auto-assign-0-to-minibuffer t winum-auto-setup-mode-line t @@ -297,25 +301,25 @@ stays on current" (swap-buffers-to-window ,n t)))))) :general (tyrant-def - "0" '(winum-select-window-0-or-10 :which-key "select window 0 or 10") - "1" '(winum-select-window-1 :which-key ("1\.\.9" . "select window 1..9")) - "2" '(winum-select-window-2 :which-key t) - "3" '(winum-select-window-3 :which-key t) - "4" '(winum-select-window-4 :which-key t) - "5" '(winum-select-window-5 :which-key t) - "6" '(winum-select-window-6 :which-key t) - "7" '(winum-select-window-7 :which-key t) - "8" '(winum-select-window-8 :which-key t) - "9" '(winum-select-window-9 :which-key t) - "b1" '(buffer-to-window-1 :which-key ("1\.\.9" . "Move buffer to window 1..9")) - "b2" '(buffer-to-window-2 :which-key t) - "b3" '(buffer-to-window-3 :which-key t) - "b4" '(buffer-to-window-4 :which-key t) - "b5" '(buffer-to-window-5 :which-key t) - "b6" '(buffer-to-window-6 :which-key t) - "b7" '(buffer-to-window-7 :which-key t) - "b8" '(buffer-to-window-8 :which-key t) - "b9" '(buffer-to-window-9 :which-key t))) + "0" '("select window 0 or 10" . winum-select-window-0-or-10) + "1" '("select window 1..9" . winum-select-window-1) + "2" 'winum-select-window-2 + "3" 'winum-select-window-3 + "4" 'winum-select-window-4 + "5" 'winum-select-window-5 + "6" 'winum-select-window-6 + "7" 'winum-select-window-7 + "8" 'winum-select-window-8 + "9" 'winum-select-window-9 + "b1" '("Move buffer to window 1..9" . buffer-to-window-1) + "b2" 'buffer-to-window-2 + "b3" 'buffer-to-window-3 + "b4" 'buffer-to-window-4 + "b5" 'buffer-to-window-5 + "b6" 'buffer-to-window-6 + "b7" 'buffer-to-window-7 + "b8" 'buffer-to-window-8 + "b9" 'buffer-to-window-9)) (use-package wakatime-mode :straight t diff --git a/lisp/editor-vsc.el b/lisp/editor-vsc.el index db10e61e..b60f1c57 100644 --- a/lisp/editor-vsc.el +++ b/lisp/editor-vsc.el @@ -38,7 +38,7 @@ (advice-add 'magit-diff-visit-worktree-file :after #'org-reveal-advice) :general (tyrant-def - "g" '(:ignore t :which-key "git") + "g" (cons "git" (make-sparse-keymap)) "gb" 'magit-blame "gc" 'magit-clone "gd" 'magit-diff @@ -110,7 +110,7 @@ (call-interactively 'git-link-commit))) :general (tyrant-def - "gL" '(:ignore t :which-key "links") + "gL" (cons "links" (make-sparse-keymap)) "gLc" 'git-link-commit "gLC" 'git-link-commit-copy-url-only "gLl" 'git-link @@ -123,7 +123,7 @@ (setq gitignore-templates-api 'github) :general (tyrant-def - "gI" '(:ignore t :which-key "gitignore") + "gI" (cons "gitignore" (make-sparse-keymap)) "gIn" 'gitignore-templates-new-file "gIi" 'gitignore-templates-insert)) diff --git a/lisp/lang-emacs-lisp.el b/lisp/lang-emacs-lisp.el index a7064d0b..478be519 100644 --- a/lisp/lang-emacs-lisp.el +++ b/lisp/lang-emacs-lisp.el @@ -12,14 +12,14 @@ :config (despot-def :keymaps '(emacs-lisp-mode-map lisp-interaction-mode-map) "'" 'ielm - "c" '(:ignore t :which-key "compile") + "c" (cons "compile" (make-sparse-keymap)) "cc" 'emacs-lisp-byte-compile - "e" '(:ignore t :which-key "eval") + "e" (cons "eval" (make-sparse-keymap)) "eb" 'eval-buffer "ee" 'eval-last-sexp "er" 'eval-region "ef" 'eval-defun - "t" '(:ignore t :which-key "tests") + "t" (cons "tests" (make-sparse-keymap)) "tb" 'ert-run-tests-buffer "tq" 'ert)) diff --git a/lisp/lang-latex.el b/lisp/lang-latex.el index 75add5b1..008055bd 100644 --- a/lisp/lang-latex.el +++ b/lisp/lang-latex.el @@ -68,7 +68,7 @@ "a" 'TeX-command-run-all ;; C-c C-a "b" 'TeX-build ;; TeX-doc is a very slow function - "h" '(:ignore t :which-key "help") + "h" (cons "help" (make-sparse-keymap)) "hd" 'TeX-doc "k" 'TeX-kill-job ;; C-c C-k "l" 'TeX-recenter-output-buffer ;; C-c C-l @@ -76,18 +76,18 @@ "n" 'TeX-next-error ;; C-c ` "N" 'TeX-previous-error ;; M-g p "v" 'TeX-view ;; C-c C-v - "x" '(:ignore t :which-key "text/fonts") + "x" (cons "text/fonts" (make-sparse-keymap)) "xb" 'font-bold "xc" 'font-code "xe" 'font-emphasis "xi" 'font-italic "xr" 'font-clear "xo" 'font-oblique - "xf" '(:ignore t :which-key "fonts") + "xf" (cons "fonts" (make-sparse-keymap)) "xfc" 'font-small-caps "xff" 'font-sans-serif "xfr" 'font-serif - "z" '(:ignore t :which-key "fold") + "z" (cons "fold" (make-sparse-keymap)) "z=" 'TeX-fold-math "zb" 'TeX-fold-buffer "zB" 'TeX-fold-clearout-buffer @@ -106,14 +106,14 @@ "." 'LaTeX-mark-environment ;; C-c . "c" 'LaTeX-close-environment ;; C-c ] "e" 'LaTeX-environment ;; C-c C-e - "f" '(:ignore t :which-key "fill") + "f" (cons "fill" (make-sparse-keymap)) "fe" 'LaTeX-fill-environment ;; C-c C-q C-e "fp" 'LaTeX-fill-paragraph ;; C-c C-q C-p "fr" 'LaTeX-fill-region ;; C-c C-q C-r "fs" 'LaTeX-fill-section ;; C-c C-q C-s - "i" '(:ignore t :which-key "insert") + "i" (cons "insert" (make-sparse-keymap)) "ii" 'LaTeX-insert-item ;; C-c C-j - "p" '(:ignore t :which-key "preview") + "p" (cons "preview" (make-sparse-keymap)) "pb" 'preview-buffer "pc" 'preview-clearout "pd" 'preview-document @@ -123,9 +123,9 @@ "pr" 'preview-region "ps" 'preview-section "s" 'LaTeX-section ;; C-c C-s - "x" '(:ignore t :which-key "text/fonts") + "x" (cons "text/fonts" (make-sparse-keymap)) "xB" 'font-medium - "xf" '(:ignore t :which-key "fonts") + "xf" (cons "fonts" (make-sparse-keymap)) "xfa" 'font-calligraphic "xfn" 'font-normal "xfu" 'font-upright @@ -142,7 +142,7 @@ (despot-def (TeX-mode-map LaTeX-mode-map) :major-modes '(tex-mode latex-mode) - "r" '(:ignore t :which-key "reftex") + "r" (cons "reftex" (make-sparse-keymap)) "rc" 'reftex-citation "rg" 'reftex-grep-document "ri" 'reftex-index-selection-or-word diff --git a/lisp/lang-misc.el b/lisp/lang-misc.el index 32153227..175eeb08 100644 --- a/lisp/lang-misc.el +++ b/lisp/lang-misc.el @@ -52,7 +52,7 @@ ">" 'markdown-indent-region "<" 'markdown-outdent-region "-" 'markdown-insert-hr - "c" '(:ignore t :which-key "command") + "c" (cons "command" (make-sparse-keymap)) "c]" 'markdown-complete-buffer "cc" 'markdown-check-refs "ce" 'markdown-export @@ -63,7 +63,7 @@ "cv" 'markdown-export-and-preview "cw" 'markdown-kill-ring-save "f" 'markdown-follow-thing-at-point - "h" '(:ignore t :which-key "header") + "h" (cons "header" (make-sparse-keymap)) "hi" 'markdown-insert-header-dwim "hI" 'markdown-insert-header-setext-dwim "h1" 'markdown-insert-header-atx-1 @@ -74,7 +74,7 @@ "h6" 'markdown-insert-header-atx-6 "h!" 'markdown-insert-header-setext-1 "h@" 'markdown-insert-header-setext-2 - "i" '(:ignore t :which-key "insert") + "i" (cons "insert" (make-sparse-keymap)) "if" 'markdown-insert-footnote "ii" 'markdown-insert-image "il" 'markdown-insert-link @@ -82,10 +82,10 @@ "iu" 'markdown-insert-uri "k" 'markdown-kill-thing-at-point "N" 'markdown-next-link - "l" '(:ignore t :which-key "lists") + "l" (cons "lists" (make-sparse-keymap)) "li" 'markdown-insert-list-item "P" 'markdown-previous-link - "t" '(:ignore t :which-key "table") + "t" (cons "table" (make-sparse-keymap)) "tp" 'markdown-table-move-row-up "tn" 'markdown-table-move-row-down "tf" 'markdown-table-move-column-right @@ -97,13 +97,13 @@ "ts" 'markdown-table-sort-lines "td" 'markdown-table-convert-region "tt" 'markdown-table-transpose - "T" '(:ignore t :which-key "toggle") + "T" (cons "toggles" (make-sparse-keymap)) "Ti" 'markdown-toggle-inline-images "Tl" 'markdown-toggle-url-hiding "Tm" 'markdown-toggle-markup-hiding "Tt" 'markdown-toggle-gfm-checkbox "Tw" 'markdown-toggle-wiki-links - "x" '(:ignore t :which-key "text") + "x" (cons "text" (make-sparse-keymap)) "xb" 'markdown-insert-bold "xB" 'markdown-insert-gfm-checkbox "xc" 'markdown-insert-code diff --git a/lisp/lang-org.el b/lisp/lang-org.el index d70bde14..88560b49 100644 --- a/lisp/lang-org.el +++ b/lisp/lang-org.el @@ -422,7 +422,7 @@ "M-RET" 'org-meta-return "a" 'org-agenda "A" 'org-attach - "b" '(:ignore t :which-key "babel") + "b" (cons "babel" (make-sparse-keymap)) "ba" 'org-babel-sha1-hash "bb" 'org-babel-execute-buffer "bc" 'org-babel-check-src-block @@ -446,7 +446,7 @@ "bz" 'org-babel-switch-to-session "bZ" 'org-babel-switch-to-session-with-code "c" 'org-capture - "C" '(:ignore t :which-key "clocks") + "C" (cons "clocks" (make-sparse-keymap)) "Cc" 'org-clock-cancel "Cd" 'org-clock-display "Ce" 'org-evaluate-time-range @@ -457,13 +457,13 @@ "Co" 'org-clock-out "CR" 'org-clock-report "Cr" 'org-resolve-clocks - "d" '(:ignore t :which-key "dates") + "d" (cons "dates" (make-sparse-keymap)) "dd" 'org-deadline "ds" 'org-schedule "dt" 'org-time-stamp "dT" 'org-time-stamp-inactive "e" 'org-export-dispatch - "i" '(:ignore t :which-key "insert") + "i" (cons "insert" (make-sparse-keymap)) "ia" 'org-attach "ib" 'org-insert-structure-template "ic" 'org-cite-insert @@ -480,7 +480,7 @@ "is" 'org-insert-subheading "it" 'org-set-tags-command "p" 'org-priority - "s" '(:ignore t :which-key "trees/subtrees") + "s" (cons "trees/subtrees" (make-sparse-keymap)) "sa" 'org-toggle-archive-tag "sA" 'org-archive-to-archive-sibling "s$" 'org-archive-subtree-default @@ -496,11 +496,11 @@ "sR" 'org-datetree-refile "ss" 'org-sparse-tree "sS" 'org-sort - "t" '(:ignore t :which-key "tables") + "t" (cons "tables" (make-sparse-keymap)) "ta" 'org-table-align "tb" 'org-table-blank-field "tc" 'org-table-convert - "td" '(:ignore t :which-key "delete") + "td" (cons "delete" (make-sparse-keymap)) "tdc" 'org-table-delete-column "tdr" 'org-table-kill-row "te" 'org-table-eval-formula @@ -508,7 +508,7 @@ "tf" 'org-table-field-info "th" 'org-table-previous-field "tH" 'org-table-move-column-left - "ti" '(:ignore t :which-key "insert") + "ti" (cons "insert" (make-sparse-keymap)) "tic" 'org-table-insert-column "tih" 'org-table-insert-hline "tiH" 'org-table-hline-and-move @@ -524,11 +524,11 @@ "tp" 'org-plot/gnuplot "tr" 'org-table-recalculate "ts" 'org-table-sort-lines - "tt" '(:ignore t :which-key "toggle") + "tt" (cons "toggles" (make-sparse-keymap)) "ttf" 'org-table-toggle-formula-debugger "tto" 'org-table-toggle-coordinate-overlays "tw" 'org-table-wrap-region - "T" '(:ignore t :which-key "toggles") + "T" (cons "toggles" (make-sparse-keymap)) "Tc" 'org-toggle-checkbox "Te" 'org-toggle-pretty-entities "Ti" 'org-toggle-inline-images @@ -536,7 +536,7 @@ "Tt" 'org-show-todo-tree "TV" 'space-doc-mode "Tx" 'org-latex-preview - "x" '(:ignore t :which-key "text") + "x" (cons "text" (make-sparse-keymap)) "xb" 'org-bold "xc" 'org-code "xi" 'org-italic @@ -549,11 +549,11 @@ (general-def 'normal org-mode-map "RET" 'org-open-at-point) :general (tyrant-def - "o" '(:ignore t :which-key "org") + "o" (cons "org" (make-sparse-keymap)) "o/" 'org-occur-in-agenda-files "oa" 'org-agenda "oc" 'org-capture - "oC" '(:ignore t :which-key "clock") + "oC" (cons "clock" (make-sparse-keymap)) "oCc" 'org-clock-cancel "oCg" 'org-clock-goto "oCi" 'org-clock-in-last @@ -715,7 +715,7 @@ go to `org-datetree-file-format' file based on TIME." (define-key magit-section-mode-map "SPC" nil) :general (tyrant-def - "or" '(:ignore t :which-key "roam") + "or" (cons "roam" (make-sparse-keymap)) "orb" 'org-roam-buffer-toggle "orf" 'org-roam-node-find "ori" 'org-roam-node-insert