Closed blueyed closed 9 years ago
What is your exact use-case?
What you need this command for might affect the appropriate interface. For example, it could turn out that this feature should not be a command, but rather an option that makes DetectIndent always echo
its settings when you load a file. What you need this for also determines the optimal content and format of the output – single-line or multiline; whether to show lines’ statistics or just the values of variables, etc.
One thing you can do already is set verbose=1
to always show debug information. You must press Enter manually to get past the displayed debug information, so it’s not seamless. But you could press Enter all the time, and then use the :messages
command to see what was printed if you find you need it later.
an option that makes DetectIndent always echo its settings when you load a file
That can be done with :verb DetectIndent
already.
My use case is to look at what :DetectIndent
, which I run automatically, might have messed up.
Running it again with :verb
does not help then, and using :verb
always is too noisy - that would be even worse with :set verbose
.. :)
I don’t understand. Since you have :DetectIndent
set to run automatically, what is wrong with manually running :verb DetectIndent
to check what it changed? When I try running that command, it still outputs its “Initial buffer settings changed” message, which has the information you want. Of course, that command will also overwrite the existing values of ts
, sw
, sts
, and et
, but since they were already overwritten by :DetectIndent
, then it will effectively do nothing.
Do you manually edit the values of those options after :DetectIndent
automatically runs, but before realizing that you want to see what DetectIndent detected? I am having trouble imagining a case when you know how you want to manually edit those options before you inspect the existing values with :verb DetectIndent
.
When I try running that command, it still outputs its “Initial buffer settings changed” message, which has the information you want.
That are the values that got changed already, see https://github.com/roryokane/detectindent/blob/master/plugin/detectindent.vim#L217-223.
So this issue might get fixed also by making DetectIndent only remember / set the initial values once, e.g. in a buffer local variable.
This issue might get fixed also by making DetectIndent only remember / set the initial values once, e.g. in a buffer local variable.
DetectIndent already does this. I have done a little refactoring to make that clearer. The buffer’s initial values are saved in a buffer-local variable b:detectindent_original_buffer_settings
, only the first time :DetectIndent
is run. Those initial values are then used to build the “Changes from the buffer’s initial settings” message.
Testing it by hand, it seems to be working properly. If I open a new file and type some three-spaced text in, then run :verb DetectIndent
, the message includes “tabstop changed from 4 to 3”. If I rerun :verb DetectIndent
without changing the file, the message still says “tabstop changed from 4 to 3”. And if I change the indentation to two spaces and rerun :verb DetectIndent
, the message now says “tabstop changed from 4 to 2”. In all messages, DetectIndent remembered that the original value was 4, not 3.
Does that solve your problem?
Since you haven’t replied to say that :verb DetectIndent
isn’t working for you, I am guessing that my previous post was enough to solve your problem.
While there is
:verb DetectIndent
, this will process the buffer again.It would be nice to have
DetectIndentInfo
, which would display the detected/applied settings from the last run.