reddit / emacs
Why is (fringe-mode 2) so slow?
cat-head · 2022-12-21 10:36
I'm curious about why `(fringe-mode 2)` is so relatively slow. It adds about half a second to my init time. ~~My solution is (run-with-idle-timer 1 nil (lambda () (fringe-mode 2))) and works well enough for my needs, but I don't understand why removing fringes would take so long?~~ Edit: to be clear, I mean that just putting `(fringe-mode 2)` on the init file is slow. The solution with the timer was to delay the execution until after init.
eli-zaretskii · 2022-12-21 13:11
You are forcing Emacs to redisplay all of your frames every single second of idle time.
cat-head · 2022-12-21 13:50
Thanks for the answer Eli, and sorry if I don't understand. Do you mean that `(fringe-mode 2)` forces redisplay every single second of idle time, or that `(run-with-idle-timer 1 nil (lambda () (fringe-mode 2)))` does that?
Edit: I wasn't clear, what is slow on my end is calling `(fringe-mode 2)` alone.
cjk101010 · 2022-12-21 14:21
The idle timer causes a redraw every single second of idle time
cat-head · 2022-12-21 14:33
Edit: I think I wasn't clear. What is slow is `(fringe-mode 2)`. The thing with the timer was to delay its execution, but I see that it is a bad solution. But the question is why does `(fringe-mode 2)` alone take so long (~ 0.1-0.4 ms, the rest of the init time is 0.5 ms).
eli-zaretskii · 2022-12-21 18:53
It causes redisplay, yes.
Why are you doing this? Doesn't setting left-fring and right-fringe with setq-default do what you want?
xtifr · 2022-12-21 20:37
At a guess, it's because it has to try to adjust everything that goes into the fringe to fit into two pixels, which may not work very well in some cases. Some things (especially third-party packages) may not be prepared to handle values other than the usual 0, 1, 4, or 8.
This is purely a guess, though. Still, might be worth seeing what happens if you run emacs -q and then call (fringe-mode 2).
(I am curious what you're trying to achieve. Two pixels doesn't seem like enough pixels to do anything useful, but seems like too much if you just want a minimal fringe.)
cat-head · 2022-12-21 22:22
> Why are you doing this?
Because that's what the [internet](https://emacsredux.com/blog/2015/01/18/customizing-the-fringes/) says I should do.
> Doesn't setting left-fring and right-fringe with setq-default do what you want?
Nope, nothing happens with:
(setq-default right-fringe 2)
(setq-default left-fringe 2)
cat-head · 2022-12-21 22:25
> This is purely a guess, though. Still, might be worth seeing what happens if you run emacs -q and then call (fringe-mode 2).
It takes 'a lot' of time, about 0.1~0.2 seconds
> (I am curious what you're trying to achieve. Two pixels doesn't seem like enough pixels to do anything useful, but seems like too much if you just want a minimal fringe.)
I think it [looks pretty](https://imgur.com/NbKsdqI)
pajuch · 2022-12-22 11:19
Agreed, can't stand the default space. Makes the code look like it's floating and is harder for me to navigate
eli-zaretskii · 2022-12-22 15:37
> Why are you doing this?
>
> Because that's what the internet says I should do.
It says to do it only once. Why are you doing it every second from a timer?
cat-head · 2022-12-22 17:48
The question was why doing it once is so slow. The timer thing was because I wanted to delay it's execution to after init (but now I understand that's the wrong way of delaying it). Forget about the timer, I am just interested in understanding why that command takes so long to run.
eli-zaretskii · 2022-12-22 17:52
How long is "so long"?
And how many frames do you have visible when you invoke that command?
And finally, what kind of build (which toolkit etc.) on which OS are you using?
cat-head · 2022-12-22 17:59
Long is about 0.3-0.4 seconds, some times more. There are no frames open since this is in the init file. I am in linux (ubuntu), gtk, and gccemacs 28.2. This is a general thing I've observed, that if I put commands that change the appearance of emacs in the init like removing menus or side bars, these take relatively long to run (also about 0.3 or 0.4 s, but for those I put them in the .Xresources and that's fast). To be clear, this is not a complaint, I am just curious as to why these commands take so much longer than, say, loading a color theme, or pretty much loading any other single package.
eli-zaretskii · 2022-12-22 19:26
How long they take if you invoke them after Emacs started?
cat-head · 2022-12-22 19:59
It seems to be faster, about 0.2-0.3 seconds.
eli-zaretskii · 2022-12-22 20:09
That's still very slow. It takes one tenth of that on my system.
Maybe it's your toolkit, I don't know.