-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add :general-config and add FAQ entry on avoiding performance issues #503
Add :general-config and add FAQ entry on avoiding performance issues #503
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #503 +/- ##
==========================================
- Coverage 69.40% 69.19% -0.21%
==========================================
Files 1 1
Lines 1000 1003 +3
==========================================
Hits 694 694
- Misses 306 309 +3 ☔ View full report in Codecov by Sentry. |
0af9940
to
61291f1
Compare
61291f1
to
d135880
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for writing this and your continued work on general.el!
I think others will find it super helpful.
By the way, I'm curious what you've used to measure startup time if you don't mind sharing. I've been out of the loop for a while and curious what options are out there. I was trying this fork of benchmark-init.el since the original was broken, but I don't recall if it was all that useful. |
d135880
to
50c0669
Compare
Yes, I just used benchmark-init. |
@noctuid Hi, If I bind keys in a prefix map, the which-key settings are not working. (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)
(tyrant-def
"b" '(:ignore t :which-key "buffers")
"bb" 'switch-to-buffer
"bB" 'ibuffer
"bd" 'kill-current-buffer
"bm" 'switch-to-messages-buffer
"bs" 'switch-to-scratch-buffer
"bu" 'reopen-killed-buffer
"bx" 'kill-buffer-and-window) previous: (general-create-definer tyrant-def
:states '(normal insert motion emacs)
:keymaps 'override
:prefix "SPC"
:non-normal-prefix "M-SPC")
(tyrant-def "" nil)
(tyrant-def
"b" '(:ignore t :which-key "buffers")
"bb" 'switch-to-buffer
"bB" 'ibuffer
"bd" 'kill-current-buffer
"bm" 'switch-to-messages-buffer
"bs" 'switch-to-scratch-buffer
"bu" 'reopen-killed-buffer
"bx" 'kill-buffer-and-window) |
Prefer not using At some point I will add a new keyword I will update the readme to discourage using |
@noctuid I have another question: I want to create a major mode prefix definer, how can I do that. (general-define-key
:states '(normal insert motion emacs)
:keymaps 'override
:prefix-map 'despot-map
:major-modes t
:prefix "SPC m"
:non-normal-prefix "M-SPC m")
(general-create-definer despot-def :keymaps 'despot-map)
(despot-def "" nil) previous works: (general-create-definer despot-def
:states '(normal insert motion emacs)
:keymaps 'override
:major-modes t
:prefix "SPC m"
:non-normal-prefix "M-SPC m")
(despot-def "" nil) |
If I understand correctly, you will use this definer with different keymaps, in which case you should remove the (general-create-definer despot--prefix-def
:states '(normal insert motion emacs)
:prefix "SPC m"
:non-normal-prefix "M-SPC m")
(defmacro despot-def (keymap &rest args)
"Define keys using major-mode leader prefixes (\"SPC m\" or \"M-SPC m\").
KEYMAP should be an unquoted symbol. ARGS should be `general-def' args."
(let ((prefix-map (intern (format "general-despot-%s" keymap))))
`(progn
(unless (boundp ',prefix-map)
(despot--prefix-def ,keymap :prefix-map ',prefix-map))
(general-def ,prefix-map ,@args))))
;; example usage; if you use a a syntax different from this, some changes to despot-def will be necessary
(despot-def emacs-lisp-mode-map "d" #'eval-defun) This example code has some limitations/caveats. It will only work for a single keymap per use. Let me know if you use I'll have to think about the best way to handle more complex use cases and add support for them. Eventually, there will be some way to opt-in to creating prefix maps automatically (e.g. can put |
Thanks, sorry I was a little vague, but you got it. This example is enough. |
Thanks to @tshu-w for asking about the which-key prefixes as I actually had not noticed that the which-key labels weren't working anymore, and thanks @noctuid for providing the solution. For anyone else who comes by reading this, note that it's actually Maybe it's something worth noting in the readme @noctuid as it's something that could easily be overlooked at the time when making these changes only to notice it later and not be super clear on what may have caused it. |
Yeah once I have some time I will update the documentation for these things and possibly add some helpers to simplify things. I also forgot to mention that I also used profile-dotemacs, which is a lot more fine-grained/useful than benchmark-init for code that you have in your init (instead of just requires). |
Ah I see, thanks! For others: |
Hi, I'm facing another issue that I cannot define for minor-mode after using (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)
(tyrant-def eglot--managed-mode :definer 'minor-mode
"ce" (cons "eglot" (make-sparse-keymap))
"cea" 'eglot-code-actions
"ceb" 'eglot-events-buffer
"cer" 'eglot-rename
"ceR" 'eglot-reconnect
"cex" 'eglot-shutdown
"ceX" 'eglot-shutdown-all
"ce=" 'eglot-format) previous: (general-create-definer tyrant-def
:states '(normal insert motion emacs)
:keymaps 'override
:prefix "SPC"
:non-normal-prefix "M-SPC")
(tyrant-def "" nil)
(tyrant-def eglot--managed-mode :definer 'minor-mode
"ce" (cons "eglot" (make-sparse-keymap))
"cea" 'eglot-code-actions
"ceb" 'eglot-events-buffer
"cer" 'eglot-rename
"ceR" 'eglot-reconnect
"cex" 'eglot-shutdown
"ceX" 'eglot-shutdown-all
"ce=" 'eglot-format) |
I think the issue is you're reusing your global/override-mode-map definer for non-global keybindings. This worked before because there was no You should create a separate definer that doesn't have Alternatively, if you never need to use (tyrant-def
:predicate '(bound-and-true-p eglot--managed-mode)
:infix "c"
"ea" #'eglot-code-actions
...) The predicate isn't technically necessary but will prevent errors. |
I forget to remove
I got it, thx a lot. |
Fixes #502.