From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Simon South Newsgroups: gmane.emacs.bugs Subject: bug#259: delphi-mode does not properly format interface definitions Date: Thu, 22 May 2008 11:17:45 -0400 Message-ID: <48358E99.4010001@slowcomputing.org> References: <482DB340.3050405@slowcomputing.org> <482DCB0F.2080602@slowcomputing.org> Reply-To: Simon South , 259@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1211491026 19747 80.91.229.12 (22 May 2008 21:17:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 May 2008 21:17:06 +0000 (UTC) To: 259@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu May 22 23:17:43 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JzIAE-0006ty-W3 for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 May 2008 23:17:31 +0200 Original-Received: from localhost ([127.0.0.1]:47772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzI9U-0004Po-BC for geb-bug-gnu-emacs@m.gmane.org; Thu, 22 May 2008 17:16:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JzClg-0004LB-6T for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 11:31:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JzCld-0004J4-Ny for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 11:31:46 -0400 Original-Received: from [199.232.76.173] (port=41515 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzCld-0004J0-JY for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 11:31:45 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:44650) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JzCld-0002b4-7r for bug-gnu-emacs@gnu.org; Thu, 22 May 2008 11:31:45 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4MFVg5Y012067; Thu, 22 May 2008 08:31:42 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m4MFP4v4009850; Thu, 22 May 2008 08:25:04 -0700 X-Loop: don@donarmstrong.com Resent-From: Simon South Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 22 May 2008 15:25:04 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 259 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: patch Original-Received: via spool by 259-submit@emacsbugs.donarmstrong.com id=B259.12114694718549 (code B ref 259); Thu, 22 May 2008 15:25:04 +0000 Original-Received: (at 259) by emacsbugs.donarmstrong.com; 22 May 2008 15:17:51 +0000 Original-Received: from postalmail-a6.g.dreamhost.com (balanced.mail.policyd.dreamhost.com [208.97.132.119]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4MFHmeW008543 for <259@emacsbugs.donarmstrong.com>; Thu, 22 May 2008 08:17:49 -0700 Original-Received: from [192.168.30.235] (unknown [24.244.216.58]) by postalmail-a6.g.dreamhost.com (Postfix) with ESMTP id 223C088F5F; Thu, 22 May 2008 08:17:47 -0700 (PDT) User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) In-Reply-To: X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Thu, 22 May 2008 11:31:46 -0400 X-Mailman-Approved-At: Thu, 22 May 2008 17:16:23 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:18102 Archived-At: 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