From: Simon South <ssouth@slowcomputing.org>
To: 259@emacsbugs.donarmstrong.com
Subject: bug#259: delphi-mode does not properly format interface definitions
Date: Fri, 23 May 2008 04:25:26 -0400 [thread overview]
Message-ID: <48367F76.1020902@slowcomputing.org> (raw)
In-Reply-To: <48358E99.4010001@slowcomputing.org>
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)
next prev parent reply other threads:[~2008-05-23 8:25 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 ` 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 [this message]
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=48367F76.1020902@slowcomputing.org \
--to=ssouth@slowcomputing.org \
--cc=259@emacsbugs.donarmstrong.com \
/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.