Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #6984
    gning
    Participant

    I’m trying to indent and outdent blocks by a single column. I tried temporarily setting Document.Config.Indent.IndentColumns to 1 but the value stays unchanged, and likewise for TabColumns. The help seems to be saying that these properties are settable, but it won’t do anything but indent by the previously set width.

    #6985
    Yutaka Emura
    Keymaster

    gning wrote:
    I’m trying to indent and outdent blocks by a single column. I tried temporarily setting Document.Config.Indent.IndentColumns to 1 but the value stays unchanged, and likewise for TabColumns. The help seems to be saying that these properties are settable, but it won’t do anything but indent by the previously set width.

    Do you need to use a macro? If not, you can change indent/tab numbers in the Configuration Properties > General > Tab/Indent.

    #6992
    gning
    Participant

    I want to indent blocks by one column in addition to being able to indent them by the normal distance. I want two separate commands. Coarse and fine tuning, so to speak.

    #6993
    Yutaka Emura
    Keymaster

    gning wrote:
    I want to indent blocks by one column in addition to being able to indent them by the normal distance. I want two separate commands. Coarse and fine tuning, so to speak.

    I see. Please try this:


    cfg = Document.Config;
    cfg.Indent.IndentColumns = 1;
    cfg.Save();

    #7092
    gning
    Participant

    It still indents by the full amount. Even if I just change the value and call Save() and don’t restore any old value, all indentation is still by the old amount.

    I’m using release 7.02, by the way.

    #7093
    Yutaka Emura
    Keymaster

    gning wrote:
    It still indents by the full amount. Even if I just change the value and call Save() and don’t restore any old value, all indentation is still by the old amount.

    I’m using release 7.02, by the way.

    How about TabColumns insread of IndentColumns?

    Why do you still use 7.02? Can you try the newest version?

    #7146
    gning
    Participant

    OK I upgraded to 8.0.4, and the macro still does the same thing — the values of IndentColumns and TabColumns don’t change when you assign to them.

    #7193
    gning
    Participant

    Well, I did find the Insert Spaces plugin, but that’s clumsy to use and only goes inward, not outward. Better than nothin’…

    #7196
    Yutaka Emura
    Keymaster

    gning wrote:
    Well, I did find the Insert Spaces plugin, but that’s clumsy to use and only goes inward, not outward. Better than nothin’…

    This is a macro to change the tab/indent length. I hope this helps.


    cfg = document.Config;
    do {
    n = prompt( "Enter new indent/tab length in characters:", cfg.Indent.TabColumns );
    } while( n <= 0 || n > 16 );
    cfg.Indent.IndentColumns = cfg.Indent.TabColumns = n;
    cfg.Save();

    #9427
    gning
    Participant

    Bringing back an old issue here… this problem is not fixed in 10.0.8 (x64). Here is my latest attempt at a macro to indent by one space… note that it tries to force the editor into indent-with-spaces-only mode:

    var icfg = Document.Config.Indent;
    var oldIC = icfg.IndentColumns;
    var oldTC = icfg.TabColumns;
    var oldIS = icfg.InsertSpaces;
    icfg.IndentColumns = icfg.TabColumns = 1;
    icfg.InsertSpaces = true;
    Document.Config.Save();
    Editor.ExecuteCommandByID(4358); // indent (as with Tab key)
    icfg.IndentColumns = oldIC;
    icfg.TabColumns = oldTC;
    icfg.InsertSpaces = oldIS;
    Document.Config.Save();

    With alerts, I have verified that the values of the column properties do change to 1… but the indent I end up with is still a tab character, not a space. Exactly as if I had just pressed the tab key without changing any settings.

    #9430
    Yutaka Emura
    Keymaster

    Hi gning,

    I will look into this issue in future versions.
    Thanks for letting me know!

    #29863
    gning
    Participant

    Revisiting an old thread… because after fifteen years I am still encountering the same ancient bug!

    I am trying to write a macro to reflow an indented paragraph. This requires measuring the indent, unindenting by that number of spaces, temporarily reducing the margin, reflowing, reindenting, and restoring the margin. It also requires temporarily setting the indent amount. And I still can’t set it to another value. I also can’t update MarginNormal.— when I assign a new value, the old value is still there when I read it back.

    Even worse, IndentColumns contains 8 even though the actual indent in the active config is 4. (TabColumns is also incorrectly returning 8.)

    I’m now on 19.8, and I could update to 24, but I don’t want any AI features.

    #29864
    gning
    Participant

    I tried to see if it was the version of EmEditor that was the problem… I’d been using the v19 64-bit windows installer version, so I tried the v24 32-bit portable version as an alternative. It has the same bug, just like when I first encountered it in v7.

    Assuming that this feature maybe works for others but not for me, I also tried running it as an administrator to see if that made any difference. It didn’t.

    I’d totally forgotten that this was an old bug. I was rather surprised when I searched the forum for anyone else talking about this bug and found myself, back when I was still running Windows 2000 because I didn’t like XP. (Now I have Windows 10 Pro 22H2.)

    #29865
    Yutaka Emura
    Keymaster

    Hello,

    Could you please summarize your issue as if you were writing about it for the first time? Provide an example to clarify the problem. Include both the current behavior and the expected behavior. You may also post or send screenshots to help explain the issue. Please include only the relevant information. Thank you.

    #29866
    gning
    Participant

    Ooookay.

    Bug: assignment does not change value of IndentColumns, TabColumns, or MarginNormal

    var oldIC = document.Config.Indent.IndentColumns;
    var oldTC = document.Config.Indent.TabColumns;
    var oldMr = document.Config.General.MarginNormal;
    
    document.Config.Indent.IndentColumns = 1;
    document.Config.Indent.TabColumns = 1;
    document.Config.General.MarginNormal = oldMr - 8;
    document.Config.Save();
    
    alert("Indent size changed from " + oldIC + " to " + document.Config.Indent.IndentColumns +
          ", tab size changed from " + oldTC + " to " + document.Config.Indent.TabColumns +
          ", margin changed from " + oldMr + " to " + document.Config.General.MarginNormal + ", and config saved.");
    
    document.Config.General.MarginNormal = oldMr;
    document.Config.Indent.IndentColumns = oldIC;
    document.Config.Indent.TabColumns = oldTC;
    document.Config.Save();

    Expected result: alert shows new values, and indenting or reformatting a paragraph uses those new values.

    Actual result: alert shows values unchanged, and indenting or reformatting applies the old values.
    alert showing unchanged values

    #29867
    gning
    Participant

    As an aside, I had said “Even worse, IndentColumns contains 8 even though the actual indent in the active config is 4. (TabColumns is also incorrectly returning 8.)” Turns out this was incorrect — I was mistaken. The bug is just that the values are not settable in javascript, not that it was loading any incorrect value originally.

    #29868
    gning
    Participant

    I tried using the V8 engine. I made a clean Windows 10 install in a VM, installed Chrome, then did a full install of the latest 64 bit EmEditor, with registration. The V8 engine showed the same bug.

    #29869
    Yutaka Emura
    Keymaster

    As I wrote on February 25, 2009, please write like this:

    
    cfg = Document.Config;
    cfg.Indent.IndentColumns = 1;
    cfg.Save();
    

    Your example should be:

    
    cfg = Document.Config;
    var oldIC = cfg.Indent.IndentColumns;
    var oldTC = cfg.Indent.TabColumns;
    var oldMr = cfg.General.MarginNormal;
    
    cfg.Indent.IndentColumns = 1;
    cfg.Indent.TabColumns = 1;
    cfg.General.MarginNormal = oldMr - 8;
    cfg.Save();
    
    alert("Indent size changed from " + oldIC + " to " + cfg.Indent.IndentColumns +
          ", tab size changed from " + oldTC + " to " + cfg.Indent.TabColumns +
          ", margin changed from " + oldMr + " to " + cfg.General.MarginNormal + ", and config saved.");
    
    cfg.General.MarginNormal = oldMr;
    cfg.Indent.IndentColumns = oldIC;
    cfg.Indent.TabColumns = oldTC;
    cfg.Save();
    
    #29870
    gning
    Participant

    Hey, that did fix it! And I was sure I’d already tried it with a separate cfg variable. Thanks.

    Why would using a separate reference make a difference? Is accessing document.Config creating a separate object instance each time, or something?

    Now I just need to work out why my paragraph reflow has stopped working, when it worked correctly as long as the margins were wrong.

    #29871
    gning
    Participant

    If there’s an issue that causes document.Config to not return the same object when referenced twice, or something like that, I do think it should be explicitly documented, with warnings on various settable config properties.

    (My macro does fully work now.)

Viewing 20 posts - 1 through 20 (of 20 total)
  • You must be logged in to reply to this topic.