From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#259: delphi-mode does not properly format interface definitions Date: Tue, 20 May 2008 11:02:30 -0400 Message-ID: References: <482DB340.3050405@slowcomputing.org> <482DCB0F.2080602@slowcomputing.org> Reply-To: Stefan Monnier , 259@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1211296402 13042 80.91.229.12 (20 May 2008 15:13:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 20 May 2008 15:13:22 +0000 (UTC) Cc: Ray Blaak , 259@emacsbugs.donarmstrong.com To: Simon South Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 20 17:14:00 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 1JyTW3-0002R6-Qo for geb-bug-gnu-emacs@m.gmane.org; Tue, 20 May 2008 17:12:40 +0200 Original-Received: from localhost ([127.0.0.1]:48008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyTVJ-0006AA-Nz for geb-bug-gnu-emacs@m.gmane.org; Tue, 20 May 2008 11:11:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JyTVD-00069X-BL for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 11:11:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JyTVC-00068t-3a for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 11:11:46 -0400 Original-Received: from [199.232.76.173] (port=51494 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JyTVB-00068j-Rz for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 11:11:45 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:55674) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JyTV9-0004NC-P8 for bug-gnu-emacs@gnu.org; Tue, 20 May 2008 11:11:44 -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 m4KFBfWJ010858; Tue, 20 May 2008 08:11:42 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m4KFA4DV009804; Tue, 20 May 2008 08:10:04 -0700 X-Loop: don@donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Tue, 20 May 2008 15:10: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: Original-Received: via spool by 259-submit@emacsbugs.donarmstrong.com id=B259.12112957697761 (code B ref 259); Tue, 20 May 2008 15:10:04 +0000 Original-Received: (at 259) by emacsbugs.donarmstrong.com; 20 May 2008 15:02:49 +0000 Original-Received: from ceviche.home (206-248-174-248.dsl.teksavvy.com [206.248.174.248]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m4KF2ZcI007755 for <259@emacsbugs.donarmstrong.com>; Tue, 20 May 2008 08:02:37 -0700 Original-Received: by ceviche.home (Postfix, from userid 20848) id 201A6B422F; Tue, 20 May 2008 11:02:30 -0400 (EDT) In-Reply-To: <482DCB0F.2080602@slowcomputing.org> (Simon South's message of "Fri, 16 May 2008 13:57:35 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Tue, 20 May 2008 11:11:46 -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:18065 Archived-At: tag 259 +patch > A bug snuck through in my original patch. I've pasted a fixed version > below. > What the patch does is make delphi-mode indent by default after the > "interface" keyword. This works fine for interface definitions and > actually works fairly well overall, since the keywords that typically > follow "interface" used in the other sense (like "uses" and "type") > cancel the indentation and give the intended formatting. However, it > fails when "interface" is used as a unit separator and followed by > "function" or "procedure", for instance. Can someone confirm whether this patch does the right thing? Stefan > *** delphi.el.orig Thu May 15 17:57:29 2008 > --- delphi.el Fri May 16 12:19:25 2008 > *************** > *** 262,271 **** > (defconst delphi-decl-sections '(type const var label resourcestring) > "Denotes the start of a declaration section.") > (defconst delphi-class-types '(class object) > "Class types.") > ! (defconst delphi-composite-types `(,@delphi-class-types record) > "Types that contain declarations within them.") > (defconst delphi-unit-sections > --- 262,275 ---- > (defconst delphi-decl-sections '(type const var label resourcestring) > "Denotes the start of a declaration section.") > + (defconst delphi-interface-types '(dispinterface interface) > + "Interface types.") > + > (defconst delphi-class-types '(class object) > "Class types.") > ! (defconst delphi-composite-types > ! `(,@delphi-class-types ,@delphi-interface-types record) > "Types that contain declarations within them.") > (defconst delphi-unit-sections > *************** > *** 859,866 **** > (delphi-stmt-line-indent-of token delphi-indent-level)))) > (defun delphi-composite-type-start (token last-token) > ! ;; Returns true (actually the last-token) if the pair equals (= > class) or (= > ! ;; record), and nil otherwise. > (if (and (eq 'equals (delphi-token-kind token)) > (delphi-is (delphi-token-kind last-token) > delphi-composite-types)) > last-token)) > --- 863,870 ---- > (delphi-stmt-line-indent-of token delphi-indent-level)))) > (defun delphi-composite-type-start (token last-token) > ! ;; Returns true (actually the last-token) if the pair equals (= > class), (= > ! ;; interface), or (= record), and nil otherwise. > (if (and (eq 'equals (delphi-token-kind token)) > (delphi-is (delphi-token-kind last-token) > delphi-composite-types)) > last-token)) > *************** > *** 1252,1258 **** > (throw 'done (delphi-line-indent-of token 0))) > ;; Unit statements mean we indent right to the left. > ! ((delphi-is token-kind delphi-unit-statements) (throw 'done 0)) > ) > (unless (delphi-is token-kind delphi-whitespace) > (setq last-token token)) > --- 1256,1264 ---- > (throw 'done (delphi-line-indent-of token 0))) > ;; Unit statements mean we indent right to the left. > ! ((and (delphi-is token-kind delphi-unit-statements) > ! (not (delphi-composite-type-start token last-token))) > ! (throw 'done 0)) > ) > (unless (delphi-is token-kind delphi-whitespace) > (setq last-token token)) > *************** > *** 1351,1357 **** > delphi-indent-level))) > ;; In unit sections we indent right to the left. > ! ((delphi-is token-kind delphi-unit-sections) (throw 'done 0)) > ;; A previous terminator means we can stop. > ((delphi-is token-kind delphi-previous-terminators) > --- 1357,1365 ---- > delphi-indent-level))) > ;; In unit sections we indent right to the left. > ! ((and (delphi-is token-kind delphi-unit-sections) > ! (not (delphi-is token-kind delphi-interface-types))) > ! (throw 'done 0)) > ;; A previous terminator means we can stop. > ((delphi-is token-kind delphi-previous-terminators) > *************** > *** 1457,1463 **** > ;; Indent to the matching start ( or [. > (delphi-indent-of (delphi-group-start token))) > ! ((delphi-is token-kind delphi-unit-statements) 0) > ((delphi-is token-kind delphi-comments) > ;; In a comment. > --- 1465,1474 ---- > ;; Indent to the matching start ( or [. > (delphi-indent-of (delphi-group-start token))) > ! ((and (delphi-is token-kind delphi-unit-statements) > ! (not > ! (delphi-is token-kind delphi-interface-types))) > ! 0) > ((delphi-is token-kind delphi-comments) > ;; In a comment.