Skip to content

Auto-indentation of end #33

Open
Open
@Remillard

Description

@Remillard

This is some strange behavior first noted in the commenting font-lock issue however I'm splitting this out and documenting with some more simple example. I am doing this on that Vanilla Emacs build with ONLY MATLAB loaded. Here's the procedure I followed:

  1. Start a new buffer, titled foo.m.
  2. Verify that the major mode is MATLAB (shown in the modeline)
  3. Line 1: Typed classdef foobar < handle. Then Enter
  4. Line 2: Typed end. Immediately classdef and end are highlighted as being a pair.
  5. Moved point back to the end of Line 1. Enter. Point auto-indents.
  6. Line 2: Typed properties (Access = public). Enter. Point auto-indents.
  7. Line 3: Typed end.

Here's where the problem begins. The second end is immediately back-indented and highlighted with classdef because the syntax scanning doesn't immediately recognize the inner end as belonging to properties. If I move the point to the beginning of the line, and hit <tab> it does NOT properly indent the end to the properties level.

I thought perhaps to make properties be recognized, I needed to add a property, so I went to the end of Line 2, hit enter. It indented to the level of properties but no deeper. I typed a = 1; and then tried to indent the inner end. It would not indent that closure end. I tried to indent a = 1; as well and would not indent to a level deeper than properties.

That said, I have a file typed in MATLAB's editor and it does this fine. And if I pull that file into Emacs, it seems to obey the opening and closure syntax for indentation. Of course in that case I have a lot more body text too, so I don't know what's making the difference.

I also tried, in the example above, going to Line 3 (with the assignment statement), and adding spaces to create the proper indentation, and then I went to Line 4 with the inner end and added spaces to create the proper indentation. I note that this end STILL highlights with the initial classdef keyword. And on both lines, 3 and 4, if I then hit table to try to force it to redo the indentation, it back-indents them both. The final/outer end appears to be marked in error when the point is moved over it.

That's the best I can do. Basically seems like for some reason, there are cases where the syntax engine doesn't correctly identify the next end as belonging to it, creating a nesting error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions