aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRay Blaak1999-08-18 05:08:39 +0000
committerRay Blaak1999-08-18 05:08:39 +0000
commit06c24636be221267b3eda4e55ae8742c536ec151 (patch)
tree27d17ad9e9649d6ab6650ae461fae8a0e67c9efc
parent28514cd97bf227897c13e1183f16909fbb9aaedf (diff)
downloademacs-06c24636be221267b3eda4e55ae8742c536ec151.tar.gz
emacs-06c24636be221267b3eda4e55ae8742c536ec151.zip
checked in with -k by blaak at 1999/08/18 05:08:39
-rw-r--r--lisp/progmodes/delphi.el67
1 files changed, 48 insertions, 19 deletions
diff --git a/lisp/progmodes/delphi.el b/lisp/progmodes/delphi.el
index 55ab9cdd566..343566d4c84 100644
--- a/lisp/progmodes/delphi.el
+++ b/lisp/progmodes/delphi.el
@@ -65,11 +65,17 @@
65(provide 'delphi) 65(provide 'delphi)
66 66
67(defconst delphi-version 67(defconst delphi-version
68 (let ((revision "$Revision: 3.0 $")) 68 (let ((revision "$Revision: 3.2 $"))
69 (string-match ": \\([^ ]+\\)" revision) 69 (string-match ": \\([^ ]+\\)" revision)
70 (match-string 1 revision)) 70 (match-string 1 revision))
71 "Version of this delphi mode.") 71 "Version of this delphi mode.")
72;;; $Log: delphi.el,v $ 72;;; $Log: delphi.el,v $
73;;; Revision 3.2 1999/08/04 05:09:19 blaak
74;;; Consider assembly sections as blocks, to indent them better.
75;;;
76;;; Revision 3.1 1999/08/04 04:45:47 blaak
77;;; Make auto-indent on newline optional
78;;;
73;;; Revision 3.0 1999/08/03 04:59:02 blaak 79;;; Revision 3.0 1999/08/03 04:59:02 blaak
74;;; Re-release as an official Emacs language mode 80;;; Re-release as an official Emacs language mode
75;;; 81;;;
@@ -152,12 +158,21 @@ end; end;"
152 :type 'boolean 158 :type 'boolean
153 :group 'delphi) 159 :group 'delphi)
154 160
155(defcustom delphi-tab-always-indent t 161(defcustom delphi-tab-always-indents t
156 "*Non-nil means TAB in Delphi mode should always reindent the current line, 162 "*Non-nil means TAB in Delphi mode should always reindent the current line,
157regardless of where in the line point is when the TAB command is used." 163regardless of where in the line point is when the TAB command is used."
158 :type 'boolean 164 :type 'boolean
159 :group 'delphi) 165 :group 'delphi)
160 166
167(defcustom delphi-newline-always-indents t
168 "*Non-nil means NEWLINE in Delphi mode should always reindent the current
169line, insert a blank line and move to the default indent column of the blank
170line. If nil, then no indentation occurs, and NEWLINE does the usual
171behaviour. This is useful when one needs to do customized indentation that
172differs from the default."
173 :type 'boolean
174 :group 'delphi)
175
161(defcustom delphi-comment-face 'font-lock-comment-face 176(defcustom delphi-comment-face 'font-lock-comment-face
162 "*Face used to color delphi comments." 177 "*Face used to color delphi comments."
163 :type 'facep 178 :type 'facep
@@ -243,7 +258,7 @@ are followed by an expression.")
243 "Class visibilities.") 258 "Class visibilities.")
244 259
245(defconst delphi-block-statements 260(defconst delphi-block-statements
246 '(begin try case repeat initialization finalization) 261 '(begin try case repeat initialization finalization asm)
247 "Statements that contain multiple substatements.") 262 "Statements that contain multiple substatements.")
248 263
249(defconst delphi-mid-block-statements 264(defconst delphi-mid-block-statements
@@ -1141,11 +1156,18 @@ non-delphi buffer. Set to nil in a delphi buffer. To override, just do:
1141 ;; Indent to use clause keyword. 1156 ;; Indent to use clause keyword.
1142 (delphi-line-indent-of token)))) 1157 (delphi-line-indent-of token))))
1143 1158
1159 ;; Assembly sections always indent in from the asm keyword.
1160 ((eq token-kind 'asm)
1161 (throw 'done (delphi-stmt-line-indent-of token delphi-indent-level)))
1162
1144 ;; An enclosing statement delimits a previous statement. 1163 ;; An enclosing statement delimits a previous statement.
1145 ;; We try to use the existing indent of the previous statement, 1164 ;; We try to use the existing indent of the previous statement,
1146 ;; otherwise we calculate from the enclosing statement. 1165 ;; otherwise we calculate from the enclosing statement.
1147 ((delphi-is token-kind delphi-previous-enclosing-statements) 1166 ((delphi-is token-kind delphi-previous-enclosing-statements)
1148 (throw 'done (if last-token (delphi-line-indent-of last-token) 1167 (throw 'done (if last-token
1168 ;; Otherwise indent to the last token
1169 (delphi-line-indent-of last-token)
1170 ;; Just indent from the enclosing keyword
1149 (delphi-line-indent-of token delphi-indent-level)))) 1171 (delphi-line-indent-of token delphi-indent-level))))
1150 1172
1151 ;; A class or record declaration also delimits a previous statement. 1173 ;; A class or record declaration also delimits a previous statement.
@@ -1374,6 +1396,10 @@ non-delphi buffer. Set to nil in a delphi buffer. To override, just do:
1374 1396
1375 ((+ (delphi-section-indent-of token) delphi-indent-level))))) 1397 ((+ (delphi-section-indent-of token) delphi-indent-level)))))
1376 1398
1399 ;; Assembly sections always indent in from the asm keyword.
1400 ((eq token-kind 'asm)
1401 (throw 'done (delphi-stmt-line-indent-of token delphi-indent-level)))
1402
1377 ;; Stop at an enclosing statement and indent from it. 1403 ;; Stop at an enclosing statement and indent from it.
1378 ((delphi-is token-kind delphi-enclosing-statements) 1404 ((delphi-is token-kind delphi-enclosing-statements)
1379 (throw 'done (delphi-stmt-line-indent-of 1405 (throw 'done (delphi-stmt-line-indent-of
@@ -1620,23 +1646,25 @@ before the indent, the point is moved to the indent."
1620 (delphi-debug-tokenize-region (window-start) (window-end))) 1646 (delphi-debug-tokenize-region (window-start) (window-end)))
1621 1647
1622(defun delphi-newline () 1648(defun delphi-newline ()
1623 "Terminate the current line with a newline and indent the next." 1649 "Terminate the current line with a newline and indent the next, unless
1650`delphi-newline-always-indents' is nil, in which case no reindenting occurs."
1624 (interactive) 1651 (interactive)
1625 ;; Remove trailing spaces 1652 ;; Remove trailing spaces
1626 (delete-horizontal-space) 1653 (delete-horizontal-space)
1627 (newline) 1654 (newline)
1628 ;; Indent both the (now) previous and current line first. 1655 (when delphi-newline-always-indents
1629 (save-excursion 1656 ;; Indent both the (now) previous and current line first.
1630 (previous-line 1) 1657 (save-excursion
1631 (delphi-indent-line)) 1658 (previous-line 1)
1632 (delphi-indent-line)) 1659 (delphi-indent-line))
1660 (delphi-indent-line)))
1633 1661
1634 1662
1635(defun delphi-tab () 1663(defun delphi-tab ()
1636 "Indent the current line or insert a TAB, depending on the value of 1664 "Indent the current line or insert a TAB, depending on the value of
1637delphi-tab-always-indent and the current line position." 1665`delphi-tab-always-indents' and the current line position."
1638 (interactive) 1666 (interactive)
1639 (if (or delphi-tab-always-indent ; We are always indenting 1667 (if (or delphi-tab-always-indents ; We are always indenting
1640 ;; Or we are before the first non-space character on the line. 1668 ;; Or we are before the first non-space character on the line.
1641 (save-excursion (skip-chars-backward delphi-space-chars) (bolp))) 1669 (save-excursion (skip-chars-backward delphi-space-chars) (bolp)))
1642 (delphi-indent-line) 1670 (delphi-indent-line)
@@ -1897,9 +1925,9 @@ comment block. If not in a // comment, just does a normal newline."
1897 (list '("\r" delphi-newline) 1925 (list '("\r" delphi-newline)
1898 '("\t" delphi-tab) 1926 '("\t" delphi-tab)
1899 '("\177" backward-delete-char-untabify) 1927 '("\177" backward-delete-char-untabify)
1900 '("\C-cd" delphi-find-current-def) 1928;; '("\C-cd" delphi-find-current-def)
1901 '("\C-cx" delphi-find-current-xdef) 1929;; '("\C-cx" delphi-find-current-xdef)
1902 '("\C-cb" delphi-find-current-body) 1930;; '("\C-cb" delphi-find-current-body)
1903 '("\C-cu" delphi-find-unit) 1931 '("\C-cu" delphi-find-unit)
1904 '("\M-q" delphi-fill-comment) 1932 '("\M-q" delphi-fill-comment)
1905 '("\M-j" delphi-new-comment-line) 1933 '("\M-j" delphi-new-comment-line)
@@ -1916,9 +1944,6 @@ This is ok since we do our own keyword/comment/string face coloring.")
1916(defun delphi-mode (&optional skip-initial-parsing) 1944(defun delphi-mode (&optional skip-initial-parsing)
1917 "Major mode for editing Delphi code. \\<delphi-mode-map> 1945 "Major mode for editing Delphi code. \\<delphi-mode-map>
1918\\[delphi-tab]\t- Indents the current line for Delphi code. 1946\\[delphi-tab]\t- Indents the current line for Delphi code.
1919\\[delphi-find-current-def]\t- Find previous definition of identifier at the point.
1920\\[delphi-find-current-xdef]\t- Find definition, but also in external units.
1921\\[delphi-find-current-body]\t- Find the body of the identifier at the point.
1922\\[delphi-find-unit]\t- Search for a Delphi source file. 1947\\[delphi-find-unit]\t- Search for a Delphi source file.
1923\\[delphi-fill-comment]\t- Fill the current comment. 1948\\[delphi-fill-comment]\t- Fill the current comment.
1924\\[delphi-new-comment-line]\t- If in a // comment, do a new comment line. 1949\\[delphi-new-comment-line]\t- If in a // comment, do a new comment line.
@@ -1933,9 +1958,13 @@ Customization:
1933 Extra indentation for blocks in compound statements. 1958 Extra indentation for blocks in compound statements.
1934 `delphi-case-label-indent' (default 0) 1959 `delphi-case-label-indent' (default 0)
1935 Extra indentation for case statement labels. 1960 Extra indentation for case statement labels.
1936 `delphi-tab-always-indent' (default t) 1961 `delphi-tab-always-indents' (default t)
1937 Non-nil means TAB in Delphi mode should always reindent the current line, 1962 Non-nil means TAB in Delphi mode should always reindent the current line,
1938 regardless of where in the line point is when the TAB command is used. 1963 regardless of where in the line point is when the TAB command is used.
1964 `delphi-newline-always-indents' (default t)
1965 Non-nil means NEWLINE in Delphi mode should always reindent the current
1966 line, insert a blank line and move to the default indent column of the
1967 blank line.
1939 `delphi-search-path' (default .) 1968 `delphi-search-path' (default .)
1940 Directories to search when finding external units. 1969 Directories to search when finding external units.
1941 `delphi-verbose' (default nil) 1970 `delphi-verbose' (default nil)