reddit / emacs

Infinite search: smartparens pair highlighting

jjbatard · 2022-11-30 14:54
Hello everyone. When I'm editing a big org-mode file sometimes I mistype an extra bracket somewhere and emacs freezes. This started happening just after I enabled smartparens' pair highlighting using `(show-smartparens-global-mode +1)` in my `~/.doom.d/config.el` file, so it's pretty clear its because of it scanning the whole buffer looking for the matching bracket to highlight. Is there a variable I can set to give a line / chars / milliseconds roof to this? Thank you all. UPDATE: I just realized it is not about the highlighting itself, but smartparents in general. I toggled `show-smartparents-global-mode`, I had no highligting but the freezing happened anyway.
JawitK · 2022-11-30 17:30
How big is the file ?
jjbatard · 2022-11-30 18:20
They're all around 2-3k lines.
eleven_cupfuls · 2022-11-30 21:27
smartparens has `sp-forward-bound-fn` and `sp-backward-bound-fn` which might work if you set them to functions that return something like the position at the beginning/end of the current function.
jjbatard · 2022-11-30 21:34
Sorry man, I'm a n00b actually, I understood like half of the things you wrote. Can you please explain a little easier? Like what do you mean as setting them to functions? Aren't them function already?
Sam_Who_Likes_cake · 2022-11-30 21:47
I believe smartparens has to scan the whole file to find the corresponding parenthesis. I’m not sure there is another way to parenthesis match without checking at least everything before the point of interest. I used to have those problems and do not. Try increasing the garbage collection size. Also try to natively compile the packages.
iwahbe · 2022-12-01 01:17
The package `smartparens` define variables `sp-forward-bound-fn` and `sp-backward-bound-fn`. You can assign functions to these variables to control how far `smartparens` searches. For example, if you only want `smartparens` to search forward by 1000 characters, you could do ```emacs-lisp (setq sp-forward-bound-fn (lambda () (min (point-max) (+ (point) 1000)))) ```
jjbatard · 2022-12-01 08:22
Thank you a lot. It seems just right, the thing is my emacs seem to completely ignore whatever `setq` thing I implement in `~/.doom.d/config.el`.Other variables i had to set in the past i've resorted to setting them with `customize`, but it always was some single value (eg `t` or `nil`), not elaborated stuff like this. Another example of something I can't seem to set is this:`(setq initial-frame-alist '(fullscreen,maximized))` Do you have any idea as to why and how to fix that? Thank you again
iwahbe · 2022-12-01 19:39
You can't set anything? Just to confirm, putting `(setq initial-frame-alist '(fullscreen maximized))` in your config and then running `(eval initial-frame-alist)` returns `nil`? I have no idea there, except to assume that your config is not being evaluated. For setting a parameter for `smartparens`, did you make sure to set it after the package was loaded. Look into the `use-package! :config` and `after!` macros for that.
jjbatard · 2022-12-02 09:35
No it gets evaluated. Yes I think it's because I didn't put the `after!` macro. Please tell me if I'm wrong: for "evaluating" you mean opening that `eshell` elisp terminal and running the command there, with the parentheses?