all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Simon South <ssouth@slowcomputing.org>
To: bug-gnu-emacs@gnu.org
Subject: bug#260: delphi-mode does not properly format interface definitions
Date: Fri, 16 May 2008 12:33:23 -0400	[thread overview]
Message-ID: <482DB753.7080905@slowcomputing.org> (raw)
In-Reply-To: <482DB340.3050405@slowcomputing.org>

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.


*** 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.







  reply	other threads:[~2008-05-16 16:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8763pf6ajf.fsf@cyd.mit.edu>
2008-05-16 16:16 ` bug#259: delphi-mode does not properly format interface definitions Simon South
2008-05-16 16:33   ` Simon South [this message]
2008-05-18  4:20     ` bug#260: marked as done (delphi-mode does not properly format interface definitions) Emacs bug Tracking System
2008-05-16 17:57   ` bug#259: delphi-mode does not properly format interface definitions Simon South
2008-05-20 15:02     ` Stefan Monnier
2008-05-22 15:17       ` Simon South
2008-05-22 21:55         ` martin rudalics
2008-05-23  8:25         ` Simon South
2008-05-25 11:48           ` Stefan Monnier
2008-09-01 17:35   ` bug#259: marked as done (delphi-mode does not properly format interface definitions) Emacs bug Tracking System

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=482DB753.7080905@slowcomputing.org \
    --to=ssouth@slowcomputing.org \
    --cc=260@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.