bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#259: delphi-mode does not properly format interface definitions


From: Simon South
Subject: bug#259: delphi-mode does not properly format interface definitions
Date: Thu, 22 May 2008 11:17:45 -0400
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Stefan Monnier wrote:
Can someone confirm whether this patch does the right thing?

It doesn't. I've pasted a short program listing below to test with. The patch I submitted will make delphi-mode indent the definition of TestInterface correctly, except that *everything* between the first instance of "interface" and "implementation" is indented one tab space too far to the right.

The solution will be to have delphi-mode identify "interface", on its own, as a unit section, and "= interface" as the start of an interface definition. My patch makes the function "delphi-composite-type-start" identify "= interface" as a composite type, so that's part of it done. However, this seems to get overridden in delphi-enclosing-indent-of: As I understand it, as the function parses the line it first identifies "= interface" as a composite type and sets the indentation properly, but then later parses "interface" again on its own and cancels the indentation. (My patch makes the function ignore "interface" the second time so the indentation never gets cancelled, but then that triggers the problem illustrated by the code sample below.)

The fix may be as simple as making delphi-enclosing-indent-of interpret "interface" as a unit section only if an equals sign wasn't previously parsed, especially as there already seems to be some logic to do this (see how the "equals-encountered" variable is used). But my LISPmanship is poor and I couldn't get this to work myself.

I'll take another stab at it this weekend, but if someone monitoring this list has experience with programming modes and is looking for an easy enhancement to make, this could be it...

---

{ Sample unit for testing emacs bug #259, "delphi-mode does not
  properly format interface definitions.  This shows the correct
  indentation. }
unit TestIndentation;

interface

function TestFunction: String;

type
  TestInterface = interface
    function TestInterfaceFunction: String;
  end;

implementation

function TestFunction: String;
begin
  Result := 'Test Function Output';
end;

end.

--
Simon South
ssouth@slowcomputing.org






reply via email to

[Prev in Thread] Current Thread [Next in Thread]