* bug#259: delphi-mode does not properly format interface definitions
@ 2008-05-16 16:16 ` Simon South
2008-05-16 16:33 ` bug#260: " Simon South
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Simon South @ 2008-05-16 16:16 UTC (permalink / raw
To: bug-gnu-emacs
delphi-mode doesn't properly indent interface definition, things like
this:
type
IHelloWorld = interface(IInvokable)
['{D613A992-AB12-0978-80D1-02B40DF72551}']
function HelloWorld: String; stdcall;
end;
This is because it doesn't distinguish between the "interface" keyword
used as a unit separator (i.e., as opposed to "implementation") and
used like a class declaration, as above.
As a result, delphi-mode will incorrectly indent the above code this
way:
type
IHelloWorld = interface(IInvokable)
['{D613A992-AB12-0978-80D1-02B40DF72551}']
function HelloWorld: String; stdcall;
end;
I've taken a stab at updating delphi.el to distinguish between these
cases and support "dispinterface" properly as well (patch below) but I
don't understand the existing code well enough yet to finish it. (I
suspect more changes need to be made to the delphi-enclosing-indent-of
function.) Perhaps someone more familiar with this sort of thing
could help me complete it?
In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600)
of 2007-06-02 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'
*** delphi.el.orig Thu May 15 17:57:29 2008
--- delphi.el Fri May 16 12:07:37 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,1475 ----
;; 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)))
! 1)
! 0)
((delphi-is token-kind delphi-comments)
;; In a comment.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#260: delphi-mode does not properly format interface definitions
2008-05-16 16:16 ` bug#259: delphi-mode does not properly format interface definitions Simon South
@ 2008-05-16 16:33 ` Simon South
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-09-01 17:35 ` bug#259: marked as done (delphi-mode does not properly format interface definitions) Emacs bug Tracking System
2 siblings, 1 reply; 10+ messages in thread
From: Simon South @ 2008-05-16 16:33 UTC (permalink / raw
To: bug-gnu-emacs
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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#259: delphi-mode does not properly format interface definitions
2008-05-16 16:16 ` bug#259: delphi-mode does not properly format interface definitions Simon South
2008-05-16 16:33 ` bug#260: " Simon South
@ 2008-05-16 17:57 ` Simon South
2008-05-20 15:02 ` Stefan Monnier
2008-09-01 17:35 ` bug#259: marked as done (delphi-mode does not properly format interface definitions) Emacs bug Tracking System
2 siblings, 1 reply; 10+ messages in thread
From: Simon South @ 2008-05-16 17:57 UTC (permalink / raw
To: 259
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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#260: marked as done (delphi-mode does not properly format interface definitions)
2008-05-16 16:33 ` bug#260: " Simon South
@ 2008-05-18 4:20 ` Emacs bug Tracking System
0 siblings, 0 replies; 10+ messages in thread
From: Emacs bug Tracking System @ 2008-05-18 4:20 UTC (permalink / raw
To: Stefan Monnier
[-- Attachment #1: Type: text/plain, Size: 839 bytes --]
Your message dated Sun, 18 May 2008 00:11:07 -0400
with message-id <jwvprrkl0am.fsf-monnier+emacsbugreports@gnu.org>
and subject line Close
has caused the Emacs bug report #260,
regarding delphi-mode does not properly format interface definitions
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)
--
260: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=260
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems
[-- Attachment #2: Type: message/rfc822, Size: 6779 bytes --]
From: Simon South <ssouth@slowcomputing.org>
To: bug-gnu-emacs@gnu.org
Subject: Re: delphi-mode does not properly format interface definitions
Date: Fri, 16 May 2008 12:33:23 -0400
Message-ID: <482DB753.7080905@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.
[-- Attachment #3: Type: message/rfc822, Size: 1030 bytes --]
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: 260-done@emacsbugs.donarmstrong.com
Subject: Close
Date: Sun, 18 May 2008 00:11:07 -0400
Message-ID: <jwvprrkl0am.fsf-monnier+emacsbugreports@gnu.org>
Duplicate of 259
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#259: delphi-mode does not properly format interface definitions
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
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2008-05-20 15:02 UTC (permalink / raw
To: Simon South; +Cc: Ray Blaak, 259
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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#259: delphi-mode does not properly format interface definitions
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
0 siblings, 2 replies; 10+ messages in thread
From: Simon South @ 2008-05-22 15:17 UTC (permalink / raw
To: 259
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#259: delphi-mode does not properly format interface definitions
2008-05-22 15:17 ` Simon South
@ 2008-05-22 21:55 ` martin rudalics
2008-05-23 8:25 ` Simon South
1 sibling, 0 replies; 10+ messages in thread
From: martin rudalics @ 2008-05-22 21:55 UTC (permalink / raw
To: Simon South, 259
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
> 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...
Merely for fun: I once spent some time writing my own pascal mode but
never finished it. I attach a copy (you simply have to load it and
do M-x pas-mode in the buffer you're visiting). Tell me if it DTRT.
[-- Attachment #2: pas-mode.el.gz --]
[-- Type: application/x-gzip, Size: 19737 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#259: delphi-mode does not properly format interface definitions
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
1 sibling, 1 reply; 10+ messages in thread
From: Simon South @ 2008-05-23 8:25 UTC (permalink / raw
To: 259
Here's a patch that I believe is correct. This adds proper support for
the "dispinterface" keyword and for the "interface" keyword when used to
define interfaces.
I've tested this on the sample unit I posted earlier and on some other
files and it works fine. I'll put together a more complete test case
and post it here as well if it's useful.
The changes are:
- Added a "delphi-interface-types" constant to identify the "interface"
and "dispinterface" keywords.
- Updated the definition of "delphi-composite-types" to include
interface types.
- Updated the description of "delphi-composite-type-start" to include
interface types (and to mention "object", which was previously missing).
- Modified the "delphi-enclosing-indent-of" function to recognize the
dual meaning of "interface". When that keyword is encountered, the
function searches backwards to find the previous non-whitespace token.
If that token is an equals sign, "interface" is interpreted as the start
of an interface definition; otherwise it's assumed to be the start of a
unit section.
- Updated the copyright and authorship notices. (Let's see if the email
addresses make it through...)
---
*** delphi.el.orig Thu May 15 17:57:29 2008
--- delphi.el Fri May 23 04:01:37 2008
***************
*** 1,9 ****
;;; delphi.el --- major mode for editing Delphi source (Object
Pascal) in Emacs
! ;; Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007
;; Free Software Foundation, Inc.
! ;; Author: Ray Blaak <blaak@infomatch.com>
;; Maintainer: FSF (Blaak's email addr bounces, Aug 2005)
;; Keywords: languages
--- 1,10 ----
;;; delphi.el --- major mode for editing Delphi source (Object
Pascal) in Emacs
! ;; Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008
;; Free Software Foundation, Inc.
! ;; Authors: Ray Blaak <blaak@infomatch.com>,
! ;; Simon South <ssouth@member.fsf.org>
;; Maintainer: FSF (Blaak's email addr bounces, Aug 2005)
;; Keywords: languages
***************
*** 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
--- 263,276 ----
(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))
--- 864,872 ----
(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), (=
! ;; dispinterface), (= interface), (= object), 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))
***************
*** 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,1385 ----
delphi-indent-level)))
;; In unit sections we indent right to the left.
! ((delphi-is token-kind delphi-unit-sections)
! (throw 'done
! ;; Handle specially the case of "interface", which
can be used
! ;; to start either a unit section or an interface
definition.
! (if (delphi-is token-kind delphi-interface-types)
! (progn
! ;; Find the previous non-whitespace token.
! (while (progn
! (setq last-token token
! token (delphi-previous-token token)
! token-kind (delphi-token-kind
token))
! (and token
! (delphi-is token-kind
! delphi-whitespace))))
! ;; If this token is an equals sign, "interface"
is being
! ;; used to start an interface definition and we
should
! ;; treat it as a composite type; otherwise, we
should
! ;; consider it the start of a unit section.
! (if (and token (eq token-kind 'equals))
! (delphi-line-indent-of last-token
! delphi-indent-level)
! 0))
! 0)))
;; A previous terminator means we can stop.
((delphi-is token-kind delphi-previous-terminators)
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#259: delphi-mode does not properly format interface definitions
2008-05-23 8:25 ` Simon South
@ 2008-05-25 11:48 ` Stefan Monnier
0 siblings, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2008-05-25 11:48 UTC (permalink / raw
To: Simon South; +Cc: 259
> Here's a patch that I believe is correct. This adds proper support for the
> "dispinterface" keyword and for the "interface" keyword when used to
> define interfaces.
Thank you. This change is a bit too large to be considered as a "tiny
change" (which don't require copyright papers). So before we can
install it, we need you to sign the corresponding paperwork.
Would you be willing to sign a copyright assignment for it? If so,
please fill&email the form below as instructed, so that the FSF can send
you the relevant papers to sign.
Also, delphi-mode is "orphaned" (it doesn't have a maintainer) and since
you seem to be using it and have some knowledge of it, would you be
willing to be the official maintainer of the package?
Stefan
Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.
Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
[What is the name of the program or package you're contributing to?]
Emacs
[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]
[Do you have an employer who might have a basis to claim to own
your changes? Do you attend a school which might make such a claim?]
[For the copyright registration, what country are you a citizen of?]
[What year were you born?]
[Please write your email address here.]
[Please write your postal address here.]
[Which files have you changed so far, and which new files have you written
so far?]
delphi.el
^ permalink raw reply [flat|nested] 10+ messages in thread
* bug#259: marked as done (delphi-mode does not properly format interface definitions)
2008-05-16 16:16 ` bug#259: delphi-mode does not properly format interface definitions Simon South
2008-05-16 16:33 ` bug#260: " Simon South
2008-05-16 17:57 ` bug#259: delphi-mode does not properly format interface definitions Simon South
@ 2008-09-01 17:35 ` Emacs bug Tracking System
2 siblings, 0 replies; 10+ messages in thread
From: Emacs bug Tracking System @ 2008-09-01 17:35 UTC (permalink / raw
To: Chong Yidong
[-- Attachment #1: Type: text/plain, Size: 828 bytes --]
Your message dated Mon, 01 Sep 2008 13:28:04 -0400
with message-id <8763pf6ajf.fsf@cyd.mit.edu>
and subject line Re: Delphi mode
has caused the Emacs bug report #259,
regarding delphi-mode does not properly format interface definitions
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)
--
259: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=259
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems
[-- Attachment #2: Type: message/rfc822, Size: 7360 bytes --]
From: Simon South <ssouth@slowcomputing.org>
To: bug-gnu-emacs@gnu.org
Subject: delphi-mode does not properly format interface definitions
Date: Fri, 16 May 2008 12:16:00 -0400
Message-ID: <482DB340.3050405@slowcomputing.org>
delphi-mode doesn't properly indent interface definition, things like
this:
type
IHelloWorld = interface(IInvokable)
['{D613A992-AB12-0978-80D1-02B40DF72551}']
function HelloWorld: String; stdcall;
end;
This is because it doesn't distinguish between the "interface" keyword
used as a unit separator (i.e., as opposed to "implementation") and
used like a class declaration, as above.
As a result, delphi-mode will incorrectly indent the above code this
way:
type
IHelloWorld = interface(IInvokable)
['{D613A992-AB12-0978-80D1-02B40DF72551}']
function HelloWorld: String; stdcall;
end;
I've taken a stab at updating delphi.el to distinguish between these
cases and support "dispinterface" properly as well (patch below) but I
don't understand the existing code well enough yet to finish it. (I
suspect more changes need to be made to the delphi-enclosing-indent-of
function.) Perhaps someone more familiar with this sort of thing
could help me complete it?
In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600)
of 2007-06-02 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'
*** delphi.el.orig Thu May 15 17:57:29 2008
--- delphi.el Fri May 16 12:07:37 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,1475 ----
;; 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)))
! 1)
! 0)
((delphi-is token-kind delphi-comments)
;; In a comment.
[-- Attachment #3: Type: message/rfc822, Size: 1632 bytes --]
From: Chong Yidong <cyd@stupidchicken.com>
To: Simon South <ssouth@slowcomputing.org>
Cc: 259-done@emacsbugs.donarmstrong.com
Subject: Re: Delphi mode
Date: Mon, 01 Sep 2008 13:28:04 -0400
Message-ID: <8763pf6ajf.fsf@cyd.mit.edu>
Simon South <ssouth@slowcomputing.org> writes:
> Chong Yidong wrote:
>> I didn't receive a reply from you previously, so maybe it got lost.
>> Your copyright assignment for Emacs changes has arrived; could you send
>> me the updated patch to delphi mode, so that I can check it into CVS?
>
> Very sorry Chong, this slipped off my radar the first time
> around. Here's the patch, against the source in CVS this morning.
Checked in. Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-09-01 17:35 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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 ` bug#260: " Simon South
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
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.