Open orlandini opened 3 years ago
There isn't a way. It sounds like this should be possible with some more generic feature, like, instead of adding dtrt-indent-mode to a hook, add a function that delays it? Also, it sounds to me like there might be other things you want to delay.
While I'm sure it'd be great to delay other things, I should say that dtrt-indent was certainly noticeable.
I don't have enough lisp knowledge to think of a way to deal with it, but should I find something I will comment here in case somebody is interested.
Should I close the issue then?
Feel free to keep it open!
Not exactly what you asked for @orlandini but how about enabling it just before first indent? That seems even better to me than a delay. Something like this appears to work:
(require 'dtrt-indent)
(add-hook
'pre-command-hook
(lambda ()
(when (and (not dtrt-indent-mode)
(memq this-command
`(,indent-line-function
,indent-region-function
,(key-binding "\t")
indent-according-to-mode
indent-region
indent-sexp)))
(dtrt-indent-mode 1))))
Could probably be optimized slightly, and there might be a few corner cases (functions not included in the list) but shouldn't be too hard to make work reliably.
@rrthomas I'm going to use this for a while, if it holds up perhaps this would be a nice feature. Something like dtrt-indent-lazy-flag
. It could optionally be buffer-local which would let you set lazy mode depending on major mode, say.
@jscheid im looking forward to testing it! Thanks a lot.
When using functions such as
projectile-replace
, every time I visit a buffer dtrt scans the file for detecting the indent. Is there a way to set a delay for this to happen?I am often visiting 300+ files at a time, and it would be great if dtrt-indent didn't try to set the
c-basic-offset
unless I stayed in the buffer for half a second, for instance.