diff options
| author | Ray Blaak | 1999-08-03 06:17:58 +0000 |
|---|---|---|
| committer | Ray Blaak | 1999-08-03 06:17:58 +0000 |
| commit | 95c1652d1c7cffd8ddd76604e76c1216d9f179a8 (patch) | |
| tree | c082a75209f30d4ba6849ce65134ccce04f704c2 | |
| parent | 36dfd5909a56d22d75a826aefb218ec885e08829 (diff) | |
| download | emacs-95c1652d1c7cffd8ddd76604e76c1216d9f179a8.tar.gz emacs-95c1652d1c7cffd8ddd76604e76c1216d9f179a8.zip | |
checked in with -k by blaak at 1999/08/03 06:17:58
| -rw-r--r-- | lisp/progmodes/delphi.el | 115 |
1 files changed, 66 insertions, 49 deletions
diff --git a/lisp/progmodes/delphi.el b/lisp/progmodes/delphi.el index 5409e2970c7..55ab9cdd566 100644 --- a/lisp/progmodes/delphi.el +++ b/lisp/progmodes/delphi.el | |||
| @@ -7,20 +7,19 @@ | |||
| 7 | 7 | ||
| 8 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 9 | 9 | ||
| 10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | 10 | ;; GNU Emacs is free software; you can redistribute it and/or modify it under |
| 11 | ;; it under the terms of the GNU General Public License as published by | 11 | ;; the terms of the GNU General Public License as published by the Free |
| 12 | ;; the Free Software Foundation; either version 2, or (at your option) | 12 | ;; Software Foundation; either version 2, or (at your option) any later |
| 13 | ;; any later version. | 13 | ;; version. |
| 14 | 14 | ||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | 15 | ;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY |
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 18 | ;; GNU General Public License for more details. | 18 | ;; details. |
| 19 | 19 | ||
| 20 | ;; You should have received a copy of the GNU General Public License | 20 | ;; You should have received a copy of the GNU General Public License along with |
| 21 | ;; along with GNU Emacs; see the file COPYING. If not, write to | 21 | ;; GNU Emacs; see the file COPYING. If not, write to the Free Software |
| 22 | ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 | ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 23 | ;; Boston, MA 02111-1307, USA. | ||
| 24 | 23 | ||
| 25 | ;;; Commentary: | 24 | ;;; Commentary: |
| 26 | 25 | ||
| @@ -32,50 +31,47 @@ | |||
| 32 | ;; (setq auto-mode-alist | 31 | ;; (setq auto-mode-alist |
| 33 | ;; (cons '("\\.\\(pas\\|dpr\\|dpk\\)$" . delphi-mode) auto-mode-alist)) | 32 | ;; (cons '("\\.\\(pas\\|dpr\\|dpk\\)$" . delphi-mode) auto-mode-alist)) |
| 34 | 33 | ||
| 34 | ;; To get keyword, comment, and string literal coloring, be sure that font-lock | ||
| 35 | ;; is running. One can manually do M-x font-lock-mode in a Delphi buffer, or | ||
| 36 | ;; one can put in .emacs: | ||
| 37 | ;; | ||
| 38 | ;; (add-hook 'delphi-mode-hook 'turn-on-font-lock) | ||
| 39 | |||
| 40 | ;; If font-lock is not loaded by default, you might have to do: | ||
| 41 | ;; | ||
| 42 | ;; (autoload 'font-lock-mode "font-lock") | ||
| 43 | ;; (autoload 'turn-on-font-lock "font-lock") | ||
| 44 | ;; (setq font-lock-support-mode 'lazy-lock-mode) | ||
| 45 | ;; | ||
| 46 | ;; Lazy lock is very necessary for faster screen updates. | ||
| 47 | |||
| 48 | ;; For good performance, be sure to byte-compile delphi.el, e.g. | ||
| 49 | ;; | ||
| 50 | ;; M-x byte-compile-file <give the path to delphi.el when prompted> | ||
| 51 | |||
| 52 | ;; This will generate delphi.elc, which will be loaded instead of delphi.el | ||
| 53 | ;; when delphi-mode is autoloaded. | ||
| 54 | |||
| 35 | ;; When you have entered Delphi mode, you may get more info by pressing | 55 | ;; When you have entered Delphi mode, you may get more info by pressing |
| 36 | ;; C-h m. | 56 | ;; C-h m. |
| 37 | 57 | ||
| 38 | ;; This delphi mode implementation is fairly tolerant of syntax | 58 | ;; This delphi mode implementation is fairly tolerant of syntax errors, relying |
| 39 | ;; errors, relying as much as possible on the indentation of the | 59 | ;; as much as possible on the indentation of the previous statement. This also |
| 40 | ;; previous statement. This also makes it faster and simpler, since | 60 | ;; makes it faster and simpler, since there is less searching for properly |
| 41 | ;; there is less searching for properly constructed beginnings. | 61 | ;; constructed beginnings. |
| 42 | 62 | ||
| 43 | ;;; Code: | 63 | ;;; Code: |
| 44 | 64 | ||
| 45 | (provide 'delphi) | 65 | (provide 'delphi) |
| 46 | 66 | ||
| 47 | (defconst delphi-version | 67 | (defconst delphi-version |
| 48 | (let ((revision "$Revision: 2.5 $")) | 68 | (let ((revision "$Revision: 3.0 $")) |
| 49 | (string-match ": \\([^ ]+\\)" revision) | 69 | (string-match ": \\([^ ]+\\)" revision) |
| 50 | (match-string 1 revision)) | 70 | (match-string 1 revision)) |
| 51 | "Version of this delphi mode.") | 71 | "Version of this delphi mode.") |
| 52 | ;;; $Log: delphi.el,v $ | 72 | ;;; $Log: delphi.el,v $ |
| 53 | ;;; Revision 2.5 1999/07/24 21:45:22 blaak | 73 | ;;; Revision 3.0 1999/08/03 04:59:02 blaak |
| 54 | ;;; Misc changes to make debugging easier, and to conform to major mode | 74 | ;;; Re-release as an official Emacs language mode |
| 55 | ;;; standards (i.e. don't require font-lock -- that forces its existence). | ||
| 56 | ;;; | ||
| 57 | ;;; Revision 2.3 1999/07/20 07:55:38 blaak | ||
| 58 | ;;; o One can now undo the effects of delphi-fill-comment. | ||
| 59 | ;;; o Object declarations are now formatted properly. | ||
| 60 | ;;; | ||
| 61 | ;;; Revision 2.2 1999/07/01 04:16:07 blaak | ||
| 62 | ;;; Handle multiple parameters on a line correctly, e.g., | ||
| 63 | ;;; procedure Foo (arg1 : T; arg2 : T; arg3 : T; | ||
| 64 | ;;; arg3 : T; // should be aligned with arg1, | ||
| 65 | ;;; // not arg2 or arg3 | ||
| 66 | ;;; | ||
| 67 | ;;; Revision 2.1 1999/05/21 06:37:19 blaak | ||
| 68 | ;;; Indent properly after simple class declarations, even if they span | ||
| 69 | ;;; multiple lines. E.g. | ||
| 70 | ;;; type TMetaClass = class of TClass; | ||
| 71 | ;;; type TSimpleClass = class | ||
| 72 | ;;; (TBaseClass); | ||
| 73 | ;;; type TForwardClass = class; | ||
| 74 | ;;; | ||
| 75 | ;;; Revision 2.0 1999/05/09 06:31:53 blaak | ||
| 76 | ;;; Re-release. Pre 2.0 versions considered development versions and their | ||
| 77 | ;;; histories dropped. Delphi mode is what it is. | ||
| 78 | ;;; | ||
| 79 | ;;; | 75 | ;;; |
| 80 | 76 | ||
| 81 | (eval-and-compile | 77 | (eval-and-compile |
| @@ -506,7 +502,7 @@ routine.") | |||
| 506 | (double-quoted-string . "[\"\n]"))))) | 502 | (double-quoted-string . "[\"\n]"))))) |
| 507 | 503 | ||
| 508 | (defun delphi-is-literal-start (p) | 504 | (defun delphi-is-literal-start (p) |
| 509 | ;; True if the point p is at the end point of a (completed) literal. | 505 | ;; True if the point p is at the start point of a (completed) literal. |
| 510 | (let* ((kind (delphi-literal-kind p)) | 506 | (let* ((kind (delphi-literal-kind p)) |
| 511 | (pattern (delphi-literal-start-pattern kind))) | 507 | (pattern (delphi-literal-start-pattern kind))) |
| 512 | (or (null kind) ; Non-literals are considered as start points. | 508 | (or (null kind) ; Non-literals are considered as start points. |
| @@ -826,10 +822,31 @@ non-delphi buffer. Set to nil in a delphi buffer. To override, just do: | |||
| 826 | (delphi-indent-of last-token offset))) | 822 | (delphi-indent-of last-token offset))) |
| 827 | 823 | ||
| 828 | (defun delphi-stmt-line-indent-of (from-token &optional offset) | 824 | (defun delphi-stmt-line-indent-of (from-token &optional offset) |
| 829 | ;; Like `delphi-line-indent-of' except is also stops on a use clause or ":". | 825 | ;; Like `delphi-line-indent-of' except is also stops on a use clause, and |
| 830 | (apply #'delphi-line-indent-of | 826 | ;; colons that precede statements (i.e. case labels). |
| 831 | from-token offset `(;colon | 827 | (let ((token (delphi-previous-token from-token)) |
| 832 | ,@delphi-use-clauses))) | 828 | (last-token from-token) |
| 829 | (kind nil)) | ||
| 830 | (catch 'done | ||
| 831 | (while token | ||
| 832 | (setq kind (delphi-token-kind token)) | ||
| 833 | (cond | ||
| 834 | ((and (eq 'colon kind) | ||
| 835 | (delphi-is (delphi-token-kind last-token) | ||
| 836 | `(,@delphi-block-statements | ||
| 837 | ,@delphi-expr-statements))) | ||
| 838 | ;; We hit a label followed by a statement. Indent to the statement. | ||
| 839 | (throw 'done nil)) | ||
| 840 | |||
| 841 | ;; Skip over ()/[] groups. | ||
| 842 | ((eq 'close-group kind) (setq token (delphi-group-start token))) | ||
| 843 | |||
| 844 | ((delphi-is kind `(newline open-group ,@delphi-use-clauses)) | ||
| 845 | ;; Stop at the beginning of the line, an open group, or a use clause | ||
| 846 | (throw 'done nil))) | ||
| 847 | (unless (delphi-is kind delphi-whitespace) (setq last-token token)) | ||
| 848 | (setq token (delphi-previous-token token)))) | ||
| 849 | (delphi-indent-of last-token offset))) | ||
| 833 | 850 | ||
| 834 | (defun delphi-open-group-indent (token last-token &optional offset) | 851 | (defun delphi-open-group-indent (token last-token &optional offset) |
| 835 | ;; Returns the indent relative to an unmatched ( or [. | 852 | ;; Returns the indent relative to an unmatched ( or [. |
| @@ -1217,7 +1234,7 @@ non-delphi buffer. Set to nil in a delphi buffer. To override, just do: | |||
| 1217 | ;; Block and mid block tokens are always enclosing | 1234 | ;; Block and mid block tokens are always enclosing |
| 1218 | ((delphi-is token-kind delphi-begin-enclosing-tokens) | 1235 | ((delphi-is token-kind delphi-begin-enclosing-tokens) |
| 1219 | (throw 'done | 1236 | (throw 'done |
| 1220 | (delphi-line-indent-of token delphi-indent-level))) | 1237 | (delphi-stmt-line-indent-of token delphi-indent-level))) |
| 1221 | 1238 | ||
| 1222 | ;; Declaration sections and routines are delimiters, unless they | 1239 | ;; Declaration sections and routines are delimiters, unless they |
| 1223 | ;; are part of a nested routine. | 1240 | ;; are part of a nested routine. |