]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/delphi.el
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-196
[gnu-emacs] / lisp / progmodes / delphi.el
index 3a3153096e096889908bed3942ddf71b8b84e2f8..4ebbc54969712f8bf71e760ec520457a4911b610 100644 (file)
@@ -1,4 +1,4 @@
-;; delphi.el --- Major mode for editing Delphi source (Object Pascal) in Emacs
+;;; delphi.el --- major mode for editing Delphi source (Object Pascal) in Emacs
 
 ;; Copyright (C) 1998, 1999 Free Software Foundation, Inc.
 
@@ -38,7 +38,7 @@
 ;; (add-hook 'delphi-mode-hook 'turn-on-font-lock)
 
 ;; If font-lock is not loaded by default, you might have to do:
-;; 
+;;
 ;; (autoload 'font-lock-mode "font-lock")
 ;; (autoload 'turn-on-font-lock "font-lock")
 ;; (setq font-lock-support-mode 'lazy-lock-mode)
 
 (provide 'delphi)
 
-(defconst delphi-version
-  (let ((revision "$Revision: 3.3 $"))
-    (string-match ": \\([^ ]+\\)" revision)
-    (match-string 1 revision))
-  "Version of this delphi mode.")
-;;; $Log: delphi.el,v $
-;;; Revision 3.3  2000/02/01 14:32:21  fx
-;;; (delphi): Add :version to defgroup.
-;;;
-;;; Revision 3.2  1999/08/18 05:08:39  blaak
-;;; checked in with -k by blaak at 1999/08/18 05:08:39
-;;;
-;;; Revision 3.2  1999/08/04 05:09:19  blaak
-;;; Consider assembly sections as blocks, to indent them better.
-;;;
-;;; Revision 3.1  1999/08/04 04:45:47  blaak
-;;; Make auto-indent on newline optional
-;;;
-;;; Revision 3.0  1999/08/03 04:59:02  blaak
-;;; Re-release as an official Emacs language mode
-;;;
-
 (eval-and-compile
   ;; Allow execution on pre Emacs 20 versions.
   (or (fboundp 'when)
@@ -182,28 +160,28 @@ differs from the default."
 
 (defcustom delphi-comment-face 'font-lock-comment-face
   "*Face used to color delphi comments."
-  :type 'facep
+  :type 'face
   :group 'delphi)
 
 (defcustom delphi-string-face 'font-lock-string-face
   "*Face used to color delphi strings."
-  :type 'facep
+  :type 'face
   :group 'delphi)
 
 (defcustom delphi-keyword-face 'font-lock-keyword-face
   "*Face used to color delphi keywords."
-  :type 'facep
+  :type 'face
   :group 'delphi)
 
 (defcustom delphi-other-face nil
   "*Face used to color everything else."
-  :type 'facep
+  :type 'face
   :group 'delphi)
 
 (defconst delphi-directives
   '(absolute abstract assembler automated cdecl default dispid dynamic
     export external far forward index inline message name near nodefault
-    overload override pascal private protected public published read readonly 
+    overload override pascal private protected public published read readonly
     register reintroduce resident resourcestring safecall stdcall stored
     virtual write writeonly)
   "Delphi4 directives.")
@@ -214,9 +192,9 @@ differs from the default."
      and array as asm at begin case class const constructor contains
      destructor dispinterface div do downto else end except exports
      file finalization finally for function goto if implementation implements
-     in inherited initialization interface is label library mod nil not 
+     in inherited initialization interface is label library mod nil not
      of object on or out package packed procedure program property
-     raise record repeat requires result self set shl shr then threadvar 
+     raise record repeat requires result self set shl shr then threadvar
      to try type unit uses until var while with xor
 
      ;; These routines should be keywords, if Borland had the balls.
@@ -264,7 +242,7 @@ are followed by an expression.")
 (defconst delphi-visibilities '(public private protected published automated)
   "Class visibilities.")
 
-(defconst delphi-block-statements 
+(defconst delphi-block-statements
   '(begin try case repeat initialization finalization asm)
   "Statements that contain multiple substatements.")
 
@@ -542,7 +520,7 @@ routine.")
                  ;; We have an end only if there is some string content (at
                  ;; least a starting delimiter).
                  (not (delphi-is-literal-end (1- p)))))
-                 
+
         ;; Special case: strings cannot span lines.
         (and (delphi-is kind delphi-strings) (eq ?\n (char-after (1- p)))))))
 
@@ -584,7 +562,7 @@ routine.")
            ;; We are completing an incomplete literal.
            (let ((kind (delphi-literal-kind (1- search-start))))
              (delphi-complete-literal kind limit)
-             (delphi-set-text-properties 
+             (delphi-set-text-properties
               search-start (point) (delphi-literal-text-properties kind))))
 
           ((re-search-forward
@@ -599,7 +577,7 @@ routine.")
                  (start (match-beginning 0)))
              (delphi-set-text-properties search-start start nil)
              (delphi-complete-literal kind limit)
-             (delphi-set-text-properties 
+             (delphi-set-text-properties
               start (point) (delphi-literal-text-properties kind))))
 
           ;; Nothing found. Mark it as a non-literal.
@@ -751,14 +729,14 @@ routine.")
       (while (< p to)
         ;; Color the token and move past it.
         (setq token (delphi-token-at p))
-        (add-text-properties 
+        (add-text-properties
          (delphi-token-start token) (delphi-token-end token)
          (list 'face (delphi-face-of (delphi-token-kind token)) 'lazy-lock t))
         (setq p (delphi-token-end token))
         (delphi-step-progress p "Fontifying" delphi-fontifying-progress-step))
       (delphi-progress-done)))))
 
-(defconst delphi-ignore-changes t
+(defvar delphi-ignore-changes t
   "Internal flag to control if the delphi-mode responds to buffer changes.
 Defaults to t in case the delphi-after-change function is called on a
 non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
@@ -772,7 +750,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
        (delphi-progress-start)
        ;; Reparse at least from the token previous to the change to the end of
        ;; line after the change.
-       (delphi-parse-region-until-stable 
+       (delphi-parse-region-until-stable
         (delphi-token-start (delphi-token-at (1- change-start)))
         (progn (goto-char change-end) (end-of-line) (point)))
        (delphi-progress-done)))))
@@ -830,7 +808,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
     (catch 'done
       (while token
         (setq kind (delphi-token-kind token))
-        (cond 
+        (cond
          ;; Skip over ()/[] groups.
          ((eq 'close-group kind) (setq token (delphi-group-start token)))
 
@@ -852,10 +830,10 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
     (catch 'done
       (while token
         (setq kind (delphi-token-kind token))
-        (cond 
+        (cond
          ((and (eq 'colon kind)
                (delphi-is (delphi-token-kind last-token)
-                          `(,@delphi-block-statements 
+                          `(,@delphi-block-statements
                             ,@delphi-expr-statements)))
           ;; We hit a label followed by a statement. Indent to the statement.
           (throw 'done nil))
@@ -932,7 +910,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
          ((delphi-composite-type-start token last-token)
           (throw 'done (if stop-on-class last-token token)))
          )
-        (unless (delphi-is token-kind delphi-whitespace) 
+        (unless (delphi-is token-kind delphi-whitespace)
           (setq last-token token))
         (setq token (delphi-previous-token token)))
       ;; Start not found.
@@ -1053,7 +1031,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
 
 (defun delphi-is-use-clause-end (at-token last-token last-colon from-kind)
   ;; True if we are after the end of a uses type clause.
-  (when (and last-token 
+  (when (and last-token
              (not last-colon)
              (eq 'comma (delphi-token-kind at-token))
              (eq 'semicolon from-kind))
@@ -1164,7 +1142,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
                    (delphi-line-indent-of token))))
 
          ;; Assembly sections always indent in from the asm keyword.
-         ((eq token-kind 'asm) 
+         ((eq token-kind 'asm)
           (throw 'done (delphi-stmt-line-indent-of token delphi-indent-level)))
 
          ;; An enclosing statement delimits a previous statement.
@@ -1252,7 +1230,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
 
          ;; An enclosing ":" means a label.
          ((and (eq 'colon token-kind)
-               (delphi-is (delphi-token-kind section-token) 
+               (delphi-is (delphi-token-kind section-token)
                           delphi-block-statements)
                (not last-terminator)
                (not expr-delimited)
@@ -1286,7 +1264,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
         (from-kind (delphi-token-kind from-token))
         (token-kind nil)
         (stmt-start nil)
-        (last-token nil)        
+        (last-token nil)
         (equals-encountered nil)
         (before-equals nil)
         (expr-delimited nil))
@@ -1345,10 +1323,10 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
                  (if stmt-start
                      ;; We are not actually indenting to the case statement,
                      ;; but are within a label expression.
-                     (delphi-stmt-line-indent-of 
+                     (delphi-stmt-line-indent-of
                       stmt-start delphi-indent-level)
                    ;; Indent from the case keyword.
-                   (delphi-stmt-line-indent-of 
+                   (delphi-stmt-line-indent-of
                     token delphi-case-label-indent))))
 
          ;; Body expression statements are enclosing. Indent from the
@@ -1356,7 +1334,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
          ;; it.
          ((delphi-is token-kind delphi-body-expr-statements)
           (throw 'done
-                 (delphi-stmt-line-indent-of 
+                 (delphi-stmt-line-indent-of
                   (or stmt-start token) delphi-indent-level)))
 
          ;; An else statement is enclosing, but it doesn't have an expression.
@@ -1404,7 +1382,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
                  ((+ (delphi-section-indent-of token) delphi-indent-level)))))
 
          ;; Assembly sections always indent in from the asm keyword.
-         ((eq token-kind 'asm) 
+         ((eq token-kind 'asm)
           (throw 'done (delphi-stmt-line-indent-of token delphi-indent-level)))
 
          ;; Stop at an enclosing statement and indent from it.
@@ -1442,18 +1420,18 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
            ;;          + 2;
            ;; which doesn't look right.
            ;;;; Align binary ops with the before token.
-           ;;((delphi-is from-kind delphi-binary-ops) 
+           ;;((delphi-is from-kind delphi-binary-ops)
            ;;(throw 'done (delphi-indent-of before-equals 0)))
 
            ;; Assignments (:=) we skip over to get a normal indent.
            ((eq (delphi-token-kind last-token) 'equals))
 
            ;; Otherwise indent in from the equals.
-           ((throw 'done 
+           ((throw 'done
                    (delphi-indent-of before-equals delphi-indent-level)))))
 
          ;; Remember any "=" we encounter if it has not already been processed.
-         ((eq token-kind 'equals) 
+         ((eq token-kind 'equals)
           (setq equals-encountered token
                 before-equals last-token))
          )
@@ -1489,7 +1467,7 @@ non-delphi buffer. Set to nil in a delphi buffer.  To override, just do:
 
                   ((delphi-is token-kind delphi-match-block-statements)
                    ;; Use the block's indentation.
-                   (let ((block-start 
+                   (let ((block-start
                           (delphi-block-start token 'stop-on-class)))
                      (cond
                       ;; When trailing a body statement, indent to
@@ -2014,7 +1992,6 @@ no args, if that value is non-nil."
 
   ;; We need to keep track of changes to the buffer to determine if we need
   ;; to retokenize changed text.
-  (make-local-hook 'after-change-functions)
   (add-hook 'after-change-functions 'delphi-after-change nil t)
 
   (widen)
@@ -2026,3 +2003,6 @@ no args, if that value is non-nil."
        (delphi-progress-done))))
 
   (run-hooks 'delphi-mode-hook))
+
+;;; arch-tag: 410e192d-e9b5-4397-ad62-12340fc3fa41
+;;; delphi.el ends here