annotate lisp/modes/eiffel3.el @ 153:25f70ba0133c r20-3b3

Import from CVS: tag r20-3b3
author cvs
date Mon, 13 Aug 2007 09:38:25 +0200
parents 54cc21c15cbb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 74
diff changeset
1 ;;; $Id: eiffel3.el,v 1.2 1997/05/29 23:49:51 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;--------------------------------------------------------------------------
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3 ;;; TowerEiffel -- Copyright (c) 1993-1996 Tower Technology Corporation.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; All Rights Reserved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; Use, duplication, or disclosure is subject to restrictions as set forth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; in subdivision (c)(1)(ii) of the Rights in Technical Data and Computer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Software clause at DFARS 252.227-7013.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; This file is made available for use and distribution under the same terms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; as GNU Emacs. Such availability of this elisp file should not be construed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; as granting such availability to the rest of TowerEiffel.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; Portions of the file, as indicated below, were derived from "eiffel.el"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
15 ;;; (developed by Stephen Omohundro, ISE and Bob Weiner) and "eif-mult-fmt.el"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
16 ;;; (developed by Bob Weiner):
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
17 ;;; eiffel.el and eif-mult-fmt.el are Copyright (C) 1989, 1990
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
18 ;;; Free Software Foundation, Inc. and Bob Weiner
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
19 ;;; Available for use and distribution under the same terms as GNU Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Adapted the file for the XEmacs 19.12 distribution. -- jasa (1995/03/11)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;--------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; EIFFEL3 : GNU Emacs mode for Eiffel Version 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; INSTALLATION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; To install, simply copy this file into a directory in your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; load-path and add the following two commands in your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; (setq auto-mode-alist (cons '("\\.e$" . eiffel-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; auto-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; (autoload 'eiffel-mode "eiffel3" "Mode for Eiffel programs" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; TowerEiffel users should do the following instead: See the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; dot-emacs that comes with the TowerEiffel distribution for a sample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; ".emacs" file. If all Tower elisp files are already in your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; load-path, then simply add the following line to your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; (load "tinstall")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; TOWER EIFFEL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; TowerEiffel provides additional Emacs support for Eiffel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; programming that integrates Emacs with Tower's Eiffel compiler,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; documentation, and browsing tools. For more information on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; these tools and their Emacs interface contact:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; Tower Technology Corporation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; 1501 Koenig Dr.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; Austin TX, 78756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; tower@twr.com (to reach a human being)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; info@twr.com (automated file server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; (512)452-1721 (FAX)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; (512)452-9455 (phone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; SUPPORT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; Please send bug reports, fixes or enhancements to:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; elisp@atlanta.twr.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; COMPATIBILITY:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; This file has been tested with XEmacs 19.11. Syntax highlighting is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; primarily supported with font-lock.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; COMMANDS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; eif-backward-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; eif-feature-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; eif-forward-sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; eif-goto-matching-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;; eif-indent-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; eif-indent-construct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; eif-indent-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; eif-newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; eiffel-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;; PUBLIC VARIABLES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; eif-body-comment-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; eif-check-keyword-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;; eif-class-level-comment-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; eif-class-level-kw-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; eif-extra-body-comment-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; eif-extra-check-keyword-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; eif-extra-class-level-comment-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;; eif-extra-class-level-kw-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; eif-extra-feature-level-comment-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; eif-extra-feature-level-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; eif-extra-feature-level-kw-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;; eif-extra-inherit-level-kw-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; eif-extra-then-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; eif-feature-level-comment-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; eif-feature-level-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; eif-feature-level-kw-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; eif-indent-increment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;; eif-inherit-level-kw-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; eif-rescue-keyword-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;; eif-then-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; eiffel-mode-abbrev-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; eiffel-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; eiffel-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; eiffel-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;; PUBLIC FUNCTIONS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; None.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; HISTORY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; Fred Hart - Jul 31, 1992: Created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; Indentation Amount Variables. ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;; ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; The default values correspond to style used in ``Eiffel: The ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; Language''. Note: for TowerEiffel users the values below ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; will be superceded by the values in either tcustom.el or ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; ~/.tcustom.el if it is present. ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defvar eif-indent-increment 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "Default indentation interval (in spaces)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvar eif-class-level-kw-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "Indentation amount for Class level keywords (in number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 eif-indent-increments) (see eif-class-level-keywords variable).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defvar eif-extra-class-level-kw-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 "Number of SPACES to add to eif-class-level-kw-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 actual indentation of a class level keyword. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defvar eif-class-level-comment-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "Indentation of comments at the beginning of the class (in number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 eif-indent-increments)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defvar eif-extra-class-level-comment-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 "Number of SPACES to add to eif-class-level-comment-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 actual indentation of a class level comment. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defvar eif-inherit-level-kw-indent 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "Indentation of keywords falling under the Inherit clause (in number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 eif-indent-increments) (see eif-inherit-level-keywords variable.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (defvar eif-extra-inherit-level-kw-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "Number of SPACES to add to eif-inherit-level-kw-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 actual indentation of an inherit level keyword. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (defvar eif-feature-level-indent 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 "Indentation amount of features. (in number of eif-indent-increments)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defvar eif-extra-feature-level-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 "Number of SPACES to add to eif-feature-level-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 actual indentation of a feature. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defvar eif-feature-level-kw-indent 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 "Indentation of keywords belonging to individual features. (in number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 eif-indent-increments) (see eif-feature-level-keywords variable)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defvar eif-extra-feature-level-kw-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "Number of SPACES to add to eif-feature-level-kw-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 actual indentation of a feature level keyword. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defvar eif-feature-level-comment-indent 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 "Indentation of comments at the beginning of a feature. (in number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 eif-indent-increments)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defvar eif-extra-feature-level-comment-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 "Number of SPACES to add to eif-feature-level-comment-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 actual indentation of a feature level comment. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defvar eif-body-comment-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "Indentation of comments in the body of a routine. (in number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 eif-indent-increments)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (defvar eif-extra-body-comment-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 "Number of SPACES to add to eif-body-comment-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 actual indentation of a routine body comment. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defvar eif-check-keyword-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "Extra indentation for the check clause as described in ETL. (in number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 eif-indent-increments). Default is 0, which is different than in ETL's 1.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defvar eif-extra-check-keyword-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "Number of SPACES to add to eif-check-keyword-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 actual indentation of a check keyword. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (defvar eif-rescue-keyword-indent -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "Extra indentation for the rescue clause as described in ETL. (in number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 eif-indent-increments). Default is -1.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defvar eif-extra-rescue-keyword-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "Number of SPACES to add to eif-rescue-keyword-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 actual indentation of a rescue keyword. Can be negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (defvar eif-then-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 "Indentation for a `then' appearing on a line by itself rather
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 than on the same line as an `if'. (in number of eif-indent-increments)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defvar eif-extra-then-indent 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "Number of SPACES to add to eif-then-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 actual indentation of a `then' appearing on a line by itself. Can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (defvar eif-continuation-indent 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 "Extra indentation for a continued statement line. (in number of eif-indent-increments)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (defvar eif-extra-continuation-indent 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 "Number of SPACES to add to eif-continuation-indent to get the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 actual indentation of a continued statement line. Can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 negative.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;; font-lock, lhilit, and hilit19 support ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; The value for a font variable must either be a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; specifying a valid font, the symbol 'default meaning the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; default font, or the symbol 'context meaning the font of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; surrounding text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; Simlarly, the value for a color variable must either be a string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; specifying a valid color, the symbol 'default meaning the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; default foreground color, or the symbol 'context meaning the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; foregound color of the surrounding text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (if (or (featurep 'font-lock) (featurep 'lhilit) (featurep 'hilit19)) (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (cond ((eq window-system 'pm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defvar eif-comment-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 "The font in which to display comments in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defvar eif-comment-color "firebrick"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 "Color of comments in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defvar eif-hidden-comment-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "The font in which to display hidden comments in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defvar eif-hidden-comment-color "os2darkgreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 "Color of hidden comments in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defvar eif-major-keyword-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 "The font in which to display major keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (defvar eif-major-keyword-color 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 "Color of major keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (defvar eif-assertion-keyword-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 "The font in which to display assertion keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defvar eif-assertion-keyword-color "os2darkblue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "Color of assertion keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defvar eif-minor-keyword-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "The font in which to display minor keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defvar eif-minor-keyword-color 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Color of minor-keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (defvar eif-string-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 "The font in which to display literal strings in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defvar eif-string-color "os2darkcyan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 "Color of literal strings in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (defvar eif-quoted-feature-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 "The font in which to display features names enclosed in `'s in Eiffel and Ace file comments (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defvar eif-quoted-feature-color 'context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "Color of features names enclosed in `'s in Eiffel and Ace file comments (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ((eq window-system 'ns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defvar eif-comment-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "The font in which to display comments in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (defvar eif-comment-color "red3"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "Color of comments in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defvar eif-hidden-comment-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 "The font in which to display hidden comments in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defvar eif-hidden-comment-color "ForestGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 "Color of hidden comments in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defvar eif-major-keyword-font "Courier-Bold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "The font in which to display major keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defvar eif-major-keyword-color 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "Color of major keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defvar eif-assertion-keyword-font "Courier-Bold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "The font in which to display assertion keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (defvar eif-assertion-keyword-color "slate blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "Color of assertion keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (defvar eif-minor-keyword-font "Courier-Bold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 "The font in which to display minor keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (defvar eif-minor-keyword-color 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "Color of minor-keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defvar eif-string-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 "The font in which to display literal strings in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (defvar eif-string-color "sienna"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 "Color of literal strings in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defvar eif-quoted-feature-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "The font in which to display features names enclosed in `'s in Eiffel and Ace file comments (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defvar eif-quoted-feature-color 'context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "Color of features names enclosed in `'s in Eiffel and Ace file comments (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ((eq window-system 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defvar eif-comment-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 "The font in which to display comments in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (defvar eif-comment-color "red3"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "Color of comments in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (defvar eif-hidden-comment-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "The font in which to display hidden comments in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defvar eif-hidden-comment-color "ForestGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 "Color of hidden comments in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defvar eif-major-keyword-font "-*-fixed-bold-*-*-*-*-100-*-*-*-*-*-*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "The font in which to display major keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defvar eif-major-keyword-color 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "Color of major keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (defvar eif-assertion-keyword-font "-*-fixed-bold-*-*-*-*-100-*-*-*-*-*-*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 "The font in which to display assertion keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (defvar eif-assertion-keyword-color "slate blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "Color of assertion keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (defvar eif-minor-keyword-font "-*-fixed-bold-*-*-*-*-100-*-*-*-*-*-*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "The font in which to display minor keywords in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (defvar eif-minor-keyword-color 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 "Color of minor-keywords in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defvar eif-string-font 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 "The font in which to display literal strings in Eiffel and Ace files (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defvar eif-string-color "sienna"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "Color of literal strings in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (defvar eif-quoted-feature-font "-*-times-medium-i-*-*-*-120-*-*-*-*-*-*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 "The font in which to display features names enclosed in `'s in Eiffel and Ace file comments (either a font name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defvar eif-quoted-feature-color 'context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "Color of features names enclosed in `'s in Eiffel and Ace file comments (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (defvar default-foreground-color 'default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "Default text color in Eiffel and Ace files (either a color name string or 'default or 'context)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defvar disable-color nil "Should hilighting not use colors")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (defun eif-set-foreground (face color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 "Set the FACE's foreground color to COLOR if COLOR is a string, to the default foreground color if COLOR is 'default, or to the color of the surrounding text if COLOR is 'context"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (cond ((stringp color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; If the specified color is not useable, use 'default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (condition-case error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (set-face-foreground face color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (message "eif-set-foreground failed for face %s and color %s. Setting to 'default" face color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (eif-set-foreground face 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ((eq color 'context)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (remove-face-property face 'foreground)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ((eq color 'default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (set-face-foreground face (face-foreground 'default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defun eif-set-font (face font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 "Set the FACE's font to FONT if FONT is a string, to the default font if FONT is 'default, or to the font of the surrounding text if FONT is 'context"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (cond ((stringp font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; If the specified font is not useable, use 'default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (condition-case error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (set-face-font face font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (message "eif-set-font failed for face %s and font %s. Setting to 'default" face font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (eif-set-font face 'default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ((eq font 'context)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (set-face-font face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ((eq font 'default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-face-font face (face-font 'default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defun eif-supports-color-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (and (not disable-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (or (and (fboundp 'display-color-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (display-color-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (and (fboundp 'x-display-color-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (x-display-color-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (and (fboundp 'x-color-display-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (x-color-display-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defun eif-init-color ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "Reset the Eiffel fonts and faces from the values of their repective variables"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (make-face 'eif-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (make-face 'eif-hidden-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (make-face 'eif-major-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (make-face 'eif-minor-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (make-face 'eif-quoted-feature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (make-face 'eif-assertion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (make-face 'eif-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (if (eif-supports-color-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (eif-set-foreground 'eif-comment eif-comment-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (eif-set-font 'eif-comment eif-comment-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (eif-set-foreground 'eif-hidden-comment eif-hidden-comment-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (eif-set-font 'eif-hidden-comment eif-hidden-comment-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (eif-set-foreground 'eif-quoted-feature eif-quoted-feature-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (eif-set-font 'eif-quoted-feature eif-quoted-feature-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (eif-set-foreground 'eif-major-keyword eif-major-keyword-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (eif-set-font 'eif-major-keyword eif-major-keyword-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (eif-set-foreground 'eif-minor-keyword eif-minor-keyword-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (eif-set-font 'eif-minor-keyword eif-minor-keyword-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (eif-set-foreground 'eif-assertion eif-assertion-keyword-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (eif-set-font 'eif-assertion eif-assertion-keyword-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (eif-set-foreground 'eif-string eif-string-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (eif-set-font 'eif-string eif-string-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (eif-set-foreground 'eif-comment default-foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (eif-set-font 'eif-comment eif-comment-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (eif-set-foreground 'eif-hidden-comment default-foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (eif-set-font 'eif-hidden-comment eif-hidden-comment-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (eif-set-foreground 'eif-quoted-feature default-foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (eif-set-font 'eif-quoted-feature eif-quoted-feature-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (eif-set-foreground 'eif-major-keyword default-foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (eif-set-font 'eif-major-keyword eif-major-keyword-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (eif-set-foreground 'eif-minor-keyword default-foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (eif-set-font 'eif-minor-keyword eif-minor-keyword-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (eif-set-foreground 'eif-assertion default-foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (eif-set-font 'eif-assertion eif-assertion-keyword-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (eif-set-foreground 'eif-string default-foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (eif-set-font 'eif-string eif-string-font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (cond ((featurep 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (copy-face 'eif-comment 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (copy-face 'eif-string 'font-lock-string-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ((and (featurep 'hilit19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (not (eq 'eif-comment (car hilit-predefined-face-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (setq hilit-predefined-face-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (append '(eif-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 eif-hidden-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 eif-major-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 eif-minor-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 eif-quoted-feature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 eif-assertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 eif-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 hilit-predefined-face-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (eif-init-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 )) ;; matches "(if () (progn" above that checks for a highlighting package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (cond ((featurep 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (copy-face 'eif-comment 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (copy-face 'eif-string 'font-lock-string-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (defconst eiffel-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 '(;; major keywords
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
463 ("\\(\\(^[ \t]*\\|[ \t]+\\)creation\\|^deferred[ \t]+class\\|^expanded[ \t]+class\\|^class\\|^feature\\|^indexing\\|\\(^[ \t]*\\|[ \t]+\\)inherit\\|^obsolete\\)[ \t\n]" 0 eif-major-keyword nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;; assertions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ("\\(^\\|[^_\n]\\<\\)\\(check\\|ensure then\\|ensure\\|invariant\\|require else\\|require\\|variant\\)\\($\\|\\>[^_\n]\\)" 2 eif-assertion nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ;; minor keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ("\\(^\\|[^_\n]\\<\\)\\(alias\\|all\\|and not\\|and then\\|and\\|as\\|debug\\|deferred\\|do\\|else\\|elseif\\|end\\|export\\|external\\|from\\|frozen\\|if not\\|if\\|implies not\\|implies\\|infix\\|inspect\\|is deferred\\|is unique\\|is\\|like\\|local\\|loop\\|not\\|obsolete\\|old\\|once\\|or else\\|or not\\|or\\|prefix\\|redefine\\|rename\\|rescue\\|retry\\|select\\|strip\\|then\\|undefine\\|unique\\|until\\|when\\|xor\\)\\($\\|\\>[^_\n]\\)" 2 eif-minor-keyword nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; hidden comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ("--|.*" 0 eif-hidden-comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; quoted expr's in comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ("`[^`'\n]*'" 0 eif-quoted-feature t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 "Regular expressions to use with font-lock mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defconst ace-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (purecopy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 '(;; major keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ("^system\\|^default\\|^root\\|^cluster\\|^external\\|[ \t\n]end\\($\\|\\>[^_\n]\\)" 0 eif-major-keyword nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;; hidden comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ("--|.*" 0 eif-hidden-comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; quoted expr's in comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ("`[^`'\n]*'" 0 eif-quoted-feature t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 "Ace regular expressions to use with font-lock mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ((featurep 'lhilit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; ---- Eiffel mode -----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;; NOTE: The order of keywords below is generally alphabetical except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;; when one keyword is the prefix of another (e.g. "and" & "and then")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; In such cases, the prefix keyword MUST be the last one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (defvar eiffel-mode-hilit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ("--|.*" nil eif-hidden-comment 4);; hidden comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ("--[^\n|].*\\|--$" nil eif-comment 3);; comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ("`[^`'\n]*'" nil eif-quoted-feature 5);; quoted expr's in comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ("^creation\\|^deferred[ \t]*class\\|^expanded[ \t]*class\\|^class\\|^feature\\|^indexing\\|^inherit\\|^obsolete" nil eif-major-keyword 1);; major keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ("\\(^\\|[^_\n]\\<\\)\\(alias\\|all\\|and not\\|and then\\|and\\|as\\|debug\\|deferred\\|do\\|else\\|elseif\\|end\\|export\\|external\\|from\\|frozen\\|if not\\|if\\|implies not\\|implies\\|infix\\|inspect\\|is deferred\\|is unique\\|is\\|like\\|local\\|loop\\|not\\|obsolete\\|old\\|once\\|or else\\|or not\\|or\\|prefix\\|redefine\\|rename\\|rescue\\|retry\\|select\\|strip\\|then\\|undefine\\|unique\\|until\\|when\\|xor\\)\\($\\|\\>[^_\n]\\)" nil eif-minor-keyword 0 2) ;; minor keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ("\\(^\\|[^_\n]\\<\\)\\(check\\|ensure then\\|ensure\\|invariant\\|require else\\|require\\|variant\\)\\($\\|\\>[^_\n]\\)" nil eif-assertion 2 2) ;; assertions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ("\\(\"\"\\)\\|\\(\"\\([^\"%]\\|%.\\|%\n\\)+\"\\)" nil eif-string 2);; strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (hilit::mode-list-update "Eiffel" eiffel-mode-hilit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ;; ---- Ace mode -----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (defvar ace-mode-hilit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ("--|.*" nil eif-hidden-comment 2);; hidden comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ("--[^\n|].*\\|--$" nil eif-comment 1);; comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ("`[^`'\n]*'" nil eif-quoted-feature 3);; quoted expr's in comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ("^system\\|^default\\|^root\\|^cluster\\|^external\\|[ \t\n]end\\($\\|\\>[^_\n]\\)" nil eif-major-keyword);; major keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (hilit::mode-list-update "Ace" ace-mode-hilit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;; NOTE: The hilit19 colors and fonts are _not_ set via the eif-*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;; faces, fonts, and foreground variables defined above. They
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;; use their own face names which describe the colors and fonts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ;; to use. See hilit19.el for more info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ((featurep 'hilit19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;; ---- Eiffel mode -----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; NOTE: The order of keywords below is generally alphabetical except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;; when one keyword is the prefix of another (e.g. "and" & "and then")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;; In such cases, the prefix keyword MUST be the last one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (hilit-set-mode-patterns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 'eiffel-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ("--|.*" nil eif-hidden-comment 4);; hidden comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ("--[^\n|].*\\|--$" nil eif-comment 3);; comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ("`[^`'\n]*'" nil eif-quoted-feature 5);; quoted expr's in comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ("^creation\\|^deferred[ \t]*class\\|^expanded[ \t]*class\\|^class\\|^feature\\|^indexing\\|^inherit\\|^obsolete" nil eif-major-keyword 1);; major keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 ("\\(^\\|[^_\n]\\<\\)\\(alias\\|all\\|and not\\|and then\\|and\\|as\\|debug\\|deferred\\|do\\|else\\|elseif\\|end\\|export\\|external\\|from\\|frozen\\|if not\\|if\\|implies not\\|implies\\|infix\\|inspect\\|is deferred\\|is unique\\|is\\|like\\|local\\|loop\\|not\\|obsolete\\|old\\|once\\|or else\\|or not\\|or\\|prefix\\|redefine\\|rename\\|rescue\\|retry\\|select\\|strip\\|then\\|undefine\\|unique\\|until\\|when\\|xor\\)\\($\\|\\>[^_\n]\\)" 2 eif-minor-keyword 0) ;; minor keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ("\\(^\\|[^_\n]\\<\\)\\(check\\|ensure then\\|ensure\\|invariant\\|require else\\|require\\|variant\\)\\($\\|\\>[^_\n]\\)" 2 eif-assertion 2) ;; assertions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ("\\(\"\"\\)\\|\\(\"\\([^\"%]\\|%.\\|%\n\\)+\"\\)" nil eif-string 2);; strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; ---- Ace mode -----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (hilit-set-mode-patterns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 'ace-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ("--|.*" nil eif-hidden-comment 2);; hidden comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ("--[^\n|].*\\|--$" nil eif-comment 1);; comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ("`[^`'\n]*'" nil eif-quoted-feature 3);; quoted expr's in comments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ("^system\\|^default\\|^root\\|^cluster\\|^external\\|[ \t\n]end\\($\\|\\>[^_\n]\\)" nil eif-major-keyword);; major keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;;; No user-customizable definitions below this point. ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (defmacro eif-class-level-kw-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 "Indentation amount for Class level keywords (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 '(+ (* eif-class-level-kw-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 eif-extra-class-level-kw-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (defmacro eif-class-level-comment-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 "Indentation amount for Class level comments (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 '(+ (* eif-class-level-comment-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 eif-extra-class-level-comment-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (defmacro eif-inherit-level-kw-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 "Indentation amount for Inherit level keywords (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 '(+ (* eif-inherit-level-kw-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 eif-extra-inherit-level-kw-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (defmacro eif-feature-level-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 "Indentation amount for features (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 '(+ (* eif-feature-level-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 eif-extra-feature-level-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (defmacro eif-feature-level-kw-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 "Indentation amount for Feature level keywords (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 '(+ (* eif-feature-level-kw-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 eif-extra-feature-level-kw-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (defmacro eif-body-comment-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 "Indentation amount for comments in routine bodies (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 '(+ (* eif-body-comment-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 eif-extra-body-comment-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defmacro eif-feature-level-comment-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "Indentation amount for Feature level comments (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 '(+ (* eif-feature-level-comment-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 eif-extra-feature-level-comment-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defmacro eif-check-keyword-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 "Indentation amount for Check keyword (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 '(+ (* eif-check-keyword-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 eif-extra-check-keyword-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (defmacro eif-rescue-keyword-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 "Indentation amount for Rescue keyword (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 '(+ (* eif-rescue-keyword-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 eif-extra-rescue-keyword-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (defmacro eif-then-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 "Indentation amount for `then' appearing on a line by itself (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 '(+ (* eif-then-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 eif-extra-then-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (defmacro eif-continuation-indent-m ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 "Indentation amount for a statement continuation line (in number of spaces)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 '(+ (* eif-continuation-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 eif-extra-continuation-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;;; Keyword Regular Expression Variables. ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (defvar eif-all-keywords-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 "\\(indexing\\|class\\|inherit\\|creation\\|feature\\|invariant\\|rename\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 \\|redefine\\|undefine\\|select\\|export\\|require\\|local\\|deferred\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 \\|do\\|once\\|ensure\\|alias\\|external\\|check\\|rescue\\|debug\\|if\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 \\|inspect\\|from\\|else\\|elseif\\|when\\|until\\|variant\\|loop\\|then\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 \\|obsolete\\|end\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 "Regular Expression to identify the presence of any eiffel keyword in a line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 Does not include `is'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; Note invariant is handled as a special case since it is both a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;; class-level and a from-level keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;; Note obsolete is handled as a special case since it is both a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; class-level and a feature-level keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (defvar eif-class-level-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 "\\(indexing\\|class\\|deferred[ \t]*class\\|expanded[ \t]*class\\|inherit\\|creation\\|feature\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 "Those keywords introducing class-level clauses. Note that `invariant'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 and `obsolete' are not included here since can function as more than one type of keyword. "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (defvar eif-inherit-level-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 "\\(rename\\|redefine\\|undefine\\|select\\|export\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 "Those keywords which introduce subclauses of the inherit clause."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (defvar eif-feature-level-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 "\\(require\\|local\\|deferred\\|do\\|once\\|ensure\\|alias\\|external\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 "Those keywords which are internal to features (in particular, routines)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (defvar eif-end-keyword "end" "The `end' keyword.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defvar eif-end-on-current-line ".*[ \t]end[ \t]*;?[ \t]*\\(--.*\\)?$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 "Regular expression to identify lines ending with the `end' keyword")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (defvar eif-non-id-char-regexp "[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 "The characters that are not part of identifiers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (defvar eif-end-keyword-regexp "[^a-z0-9_]end[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 "The `end' keyword with context.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (defvar eif-end-matching-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 "\\(check\\|class\\|feature\\|rename\\|redefine\\|undefine\\|select\\|export\\|do\\|once\\|deferred\\|external\\|alias\\|if\\|inspect\\|from\\|debug\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 "Those keywords whose clause is terminated by an `end' keyword."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (defvar eif-control-flow-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 "\\(if\\|inspect\\|from\\|debug\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 "Keywords which introduce control-flow constructs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (defvar eif-control-flow-matching-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 "\\(deferred\\|do\\|once\\|if\\|inspect\\|from\\|debug\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 "Keywords whose occurrence prior to a control-flow-keyword causes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 indentation of the control-flow-keyword. Note that technically,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 `end' is part of this list but it is handled separately in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 functions: eif-matching-indent and eif-matching-kw."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (defvar eif-check-keyword "check" "The `check' keyword.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (defvar eif-check-keywords "\\(check\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 "The `check' keyword (with trailing context).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (defvar eif-check-matching-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 "\\(deferred\\|do\\|once\\|if\\|inspect\\|from\\|debug\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 "Keywords whose occurrence prior to a check-keyword causes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 indentation of the check-keyword. Note that technically, `end' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 part of this list but it is handled separately in the functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 eif-matching-indent and eif-matching-kw. (see also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 eif-control-flow-matching-keywords)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (defvar eif-rescue-keyword "rescue" "The `rescue' keyword.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (defvar eif-obsolete-keyword "obsolete" "The `obsolete' keyword.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (defvar eif-rescue-keywords "\\(rescue\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 "The `rescue' keyword (with trailing context).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (defvar eif-rescue-matching-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 "\\(deferred\\|do\\|once\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 "Keywords whose occurrence prior to a rescue-keyword causes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 indentation of the rescue-keyword. Note that technically, `end' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 part of this list but it is handled separately in the functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 eif-matching-indent and eif-matching-kw. (see also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 eif-control-flow-matching-keywords)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (defvar eif-from-level-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 "\\(until\\|variant\\|loop\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 "Keywords occuring inside of a from clause."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (defvar eif-from-keyword "from" "The keyword `from'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (defvar eif-if-or-inspect-level-keywords "\\(elseif\\|else\\|when\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 "Keywords occuring inside of an if or inspect clause."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (defvar eif-if-or-inspect-keyword "\\(if\\|inspect\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 "The `if' or `inspect' keywords."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (defvar eif-then-keyword ".*[ \t)]then[ \t]*$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 "The keyword `then' with possible leading text.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (defvar eif-solitary-then-keyword "then" "The keyword `then'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (defvar eif-then-matching-keywords "\\(if\\|elseif\\|when\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 "Keywords whose occurrence prior to a then-keyword sets the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 indentation of the then-keyword. Note that technically, `end' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 part of this list but it is handled separately in the functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 eif-matching-indent and eif-matching-kw. (see also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 eif-control-flow-matching-keywords)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (defvar eif-invariant-keyword "invariant" "The `invariant' keyword.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (defvar eif-invariant-matching-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 "\\(from\\|feature\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 "Keywords whose occurrence prior to an invariant-keyword causes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 indentation of the invariant-keyword. Note that technically, `end'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 is part of this list but it is handled separately in the functions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 eif-matching-indent and eif-matching-kw. (see also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 eif-control-flow-matching-keywords)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (defvar eif-obsolete-matching-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 "\\(is\\|class\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 "Keywords whose occurrence prior to an obsolete-keyword causes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 indentation of the obsolete-keyword."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (defvar eif-white-space-regexp "[ ]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 "RE to locate whitespace.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (defvar eif-comment-line-regexp "[ ]*\\(--.*\\)$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 "RE to match a line with a comment on it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (defvar eif-non-source-line "[ ]*\\(--.*\\)?$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 "RE to match a line with a only a comment or whitespace.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (defvar eif-variable-or-const-regexp "[^()\n]*:[^=].*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 "RE to match a variable or constant declaration.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (defvar eif-indentation-keywords-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 "\\(indexing\\|class\\|check\\|rescue\\|inherit\\|creation\\|feature\\|invariant\\|rename\\|redefine\\|undefine\\|select\\|export\\|require\\|local\\|deferred\\|do\\|once\\|ensure\\|alias\\|external\\|if\\|inspect\\|from\\|debug\\|else\\|elseif\\|when\\|until\\|variant\\|invariant\\|loop\\|obsolete\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 "RE to identify the presence of any eiffel keyword triggering indentation"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (defvar eif-feature-indentation-keywords-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 "\\(creation\\|feature\\)[^a-z0-9_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 "Keywords which denote the presence of features following them."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (defvar eif-is-keyword-regexp "\\(.*[ )]\\)?is[ ]*\\(--.*\\)?$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 "The `is' keyword (with some context)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (defvar eif-multiline-routine-is-keyword-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ".*([^)]*)\\([ \t\n]*\\|[ \t\n]*:[][ \t\nA-Za-x0-9_,]*\\)is[ ]*\\(--.*\\)?$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 "The `is' keyword (with some context)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (defvar eif-operator-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 "[ ]*\\([@*/+]\\|-[^-]\\|\\<and[ (]\\|\\<or[ (]\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 "Eiffel operators - used to identify continuation lines"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defvar eif-operator-eol-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ".*\\([@*/+-]\\|\\<and\\|\\<or\\|:=\\)[ ]*$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 "Eiffel operators - used to identify continuation lines"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (defvar eif-matching-indent -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 "The indentation of the keyword found on the last call to eif-matching-kw.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 -1 if no match was found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (defvar eif-matching-kw-for-end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ;;; Indentation Functions. ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (defun eif-calc-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 "Calculate the indentation of the current line of eiffel code. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 function generally assumes that the preceding line of code is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 indented properly, although lines containing certain class-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 constructs do not require correct indentation of the preceding line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (let ((indent 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (line-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (originally-looking-at-comment nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (kw-match nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (continuation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (id-colon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; Save location of line-end and skip past leading white space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (setq line-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (re-search-forward eif-white-space-regexp line-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;; Is the line we are trying to indent a comment line?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (setq originally-looking-at-comment (looking-at eif-comment-line-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ;; Look for a keyword on the current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (if (looking-at eif-all-keywords-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 ;; Then we are looking at a keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (cond ((looking-at eif-class-level-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ;; File level keywords (indent defaults to 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (setq indent (eif-class-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 ((looking-at eif-inherit-level-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 ;; Inherit level keywords (indent defaults to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ;; 2*eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (setq indent (eif-inherit-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ((looking-at eif-feature-level-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;; Feature level keywords (indent defaults to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;; (eif-feature-level-indent-m) + eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (setq indent (eif-feature-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ((looking-at eif-end-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;; End keyword (indent to level of matching keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (if (string-match "end"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (eif-matching-kw eif-end-matching-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (if (= eif-matching-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (eif-feature-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (setq indent (eif-class-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (setq indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (- eif-matching-indent eif-indent-increment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (setq indent eif-matching-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (if (<= indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (while (and (< (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (or (forward-char 1) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (looking-at eif-non-source-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (if (not (looking-at eif-non-source-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (setq indent (eif-inherit-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (setq indent (eif-class-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 ((looking-at eif-control-flow-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 ;; Control flow keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 ;; Indent to same level as a preceding "end" or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ;; if no preceding "end" is found, indent to the level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ;; of the preceding "do" plus the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ;; eif-indent-increment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (setq kw-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (eif-matching-kw eif-control-flow-matching-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (cond ((string-match "end" kw-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (setq indent eif-matching-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (setq indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (+ eif-matching-indent eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 ((looking-at eif-check-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 ;; Check keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 ;; Indent to level of preceding "end"+eif-indent-increment or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 ;; if no preceding "end" is found, indent to the level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;; of the preceding eif-check-matching-keywords plus the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 ;; value (eif-indent-increment + eif-check-keyword-indent).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (setq kw-match (eif-matching-kw eif-check-matching-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (cond ((string-match "end" kw-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (setq indent (+ eif-matching-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (eif-check-keyword-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (setq indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (+ eif-matching-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (+ eif-indent-increment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (eif-check-keyword-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ((looking-at eif-rescue-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ;; Rescue keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ;; Indent to level of preceding "end"+eif-indent-increment or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ;; if no preceding "end" is found, indent to the level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ;; of the preceding eif-rescue-matching-keywords plus the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;; value (eif-indent-increment + eif-rescue-keyword-indent).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (setq kw-match (eif-matching-kw eif-rescue-matching-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (cond ((string-match "end" kw-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (setq indent (+ eif-matching-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (eif-rescue-keyword-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (setq indent eif-matching-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ((looking-at eif-from-level-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ;; From level keywords (indent to level of matching "From")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (if (string-match "end" (eif-matching-kw eif-from-keyword))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;; Closest matching KW is `end'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (setq indent (- eif-matching-indent eif-indent-increment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 ;; Closest matching KW is one of `eif-from-keyword'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (setq indent eif-matching-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 ((looking-at eif-if-or-inspect-level-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;; If level keywords (indent to level of matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 ;; "If" or "Inspect")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (if (string-match "end"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (eif-matching-kw eif-if-or-inspect-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ;; Closest matching KW is `end'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (setq indent (- eif-matching-indent eif-indent-increment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 ;; Closest matching KW is one of `eif-if-or-inspect-keyword'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (setq indent eif-matching-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 ((looking-at eif-solitary-then-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 ;; Handles case where "then" appears on a line by itself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; (Indented to the level of the matching if, elseif or when)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (setq indent (+ (eif-matching-indent eif-then-matching-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (eif-then-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 ((looking-at eif-invariant-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;; Invariant keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;; (Indented to the level of the matching from or feature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (if (string-match "from"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (eif-matching-kw eif-invariant-matching-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ;; Then - loop invariant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (setq indent eif-matching-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 ;; Else - class invariant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (setq indent (eif-class-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ((looking-at eif-obsolete-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ;; Obsolete keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ;; (Indented to the level of the matching from or feature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (if (string-match "is"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (eif-matching-kw eif-obsolete-matching-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ;; Then - feature obsolete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (setq indent (eif-feature-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;; Else - class obsolete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (setq indent (eif-class-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ) ;; end of cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ;; Else no keyword on current line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;; are we in a multi-line parenthesis expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (if (or (and (> (eif-in-paren-expression) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (> (setq indent (eif-indent-multi-line)) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (setq indent (eif-manifest-array-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 ;; multi-line parenthesis expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;; Move string continuation lines one column to the left
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (if (looking-at "%")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (setq indent (1- indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ;; Else Find the first preceding line with non-comment source on it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ;; that is not a continuation line of a multi-line parnethesized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ;; expression.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ;; Record whether this line begins with an operator. We assume
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;; that the line is a continuation line if it begins with an operator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (if (looking-at eif-operator-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (setq continuation t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (setq continuation nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;; Record whether the line being indented begins with an "<id> :"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ;; This is used in indenting assertion tag expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (if (looking-at "[ ]*[a-zA-Z0-9_]+[ ]*:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (setq id-colon t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (setq id-colon nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (while (and (looking-at eif-non-source-line) (not (= (point) 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (previous-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (if (eif-line-contains-close-paren)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (setq line-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (re-search-forward eif-white-space-regexp line-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (cond ((and (= (point) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 originally-looking-at-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (setq indent (eif-class-level-comment-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 ;; 'eif-is-keyword-regexp' case must precede
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;; '(not eif-all-keywords-regexp)' case since "is" is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 ;; part of 'eif-all-keywords-regexp'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 ((or (looking-at eif-is-keyword-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (looking-at eif-multiline-routine-is-keyword-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (looking-at eif-obsolete-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (if originally-looking-at-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 ;; Then the line we are trying to indent is a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (setq indent (eif-feature-level-comment-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 ;; Else the line being indented is not a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (setq indent (eif-feature-level-kw-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ((looking-at eif-feature-indentation-keywords-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (setq indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 ((looking-at eif-indentation-keywords-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (if (looking-at eif-end-on-current-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (setq indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (setq indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (+ (eif-current-line-indent) eif-indent-increment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 ((looking-at eif-solitary-then-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (setq indent (- (+ (eif-current-line-indent) eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (eif-then-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 ((looking-at eif-then-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (setq indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 ((looking-at (concat eif-end-keyword eif-non-id-char-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (if (= (setq indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (eif-feature-level-kw-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (setq indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (eif-matching-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (if (string-match eif-check-keyword eif-matching-kw-for-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (setq indent (- indent (eif-check-keyword-indent-m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ((looking-at eif-variable-or-const-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;;Either a variable declaration or a pre or post condition tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (if originally-looking-at-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 ;; Then the line we are trying to indent is a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (if (= (setq indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (eif-feature-level-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 ;; Then - a feature level comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (setq indent (eif-feature-level-comment-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 ;; Else - some other kind of comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (setq indent (+ indent (eif-body-comment-indent-m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 ;; Else the line being indented is not a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (if (setq indent (eif-indent-assertion-continuation id-colon))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (setq indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 ((setq indent (eif-manifest-array-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 ((not (looking-at eif-all-keywords-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (if originally-looking-at-comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ;; Then the line we are trying to indent is a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (cond ((eif-continuation-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (setq indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (+ (- (eif-current-line-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 eif-indent-increment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (eif-body-comment-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 ;; preceding line is at eif-feature-level-indent -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 ;; assume that the preceding line is a parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 ;; class in an inherit clause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 ((= (eif-current-line-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (eif-feature-level-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (setq indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (+ (eif-inherit-level-kw-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (eif-body-comment-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (setq indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (+ (eif-current-line-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (eif-body-comment-indent-m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 ;; Else line being indented is not a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 ;; The line the point is on is the one above the line being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;; indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (if (or continuation (looking-at eif-operator-eol-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;; Then the line being indented is a continuation line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (if (eif-continuation-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 ;; The line preceding the line being indented is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ;; also a continuation line. Indent to the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 ;; line indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (setq indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 ;; Else The line preceding the line being indented is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 ;; not a continuation line. Indent an extra
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 ;; eif-continuation-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (setq indent (+ (eif-current-line-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (eif-continuation-indent-m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;; Else the line being indented is not a continuation line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (if (eif-continuation-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (if id-colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;; Then the line preceding the one being indented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 ;; is an assertion continuation. Indent the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; line to the same level as the preceding assertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (setq indent (eif-indent-assertion-tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 ;; Then the line preceding the one being indented is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;; a continuation line. Un-indent by an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 ;; eif-continuation-indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (setq indent (- (eif-current-line-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 eif-indent-increment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;; Else the line preceding the line being indented is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 ;; also not a continuation line. Use the current indent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (setq indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ) ;; cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 ) ;; if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ) ;; if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 ) ;; save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ) ;; let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (defun eif-continuation-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (or (looking-at eif-operator-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (looking-at eif-operator-eol-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (defun eif-indent-assertion-continuation (id-colon)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 "Are we inside a pre or a post condition clause on a line that is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 continuation of a multi-line assertion beginning with a tag? If so, return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 the indentation of the continuation line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (let ((limit (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (if (re-search-backward (concat eif-feature-level-keywords "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 eif-end-keyword-regexp) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (if (looking-at "ensure\\|require")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (setq limit (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (if (and (not id-colon) (re-search-backward ": *" limit t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (current-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (defun eif-indent-assertion-tag ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 "Are we inside a pre or a post condition clause on a line that is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 continuation of a multi-line assertion beginning with a tag? If so, return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 the indentation of the continuation line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (let (indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (if (re-search-backward "ensure\\|require\\|variant\\|invariant" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (setq indent (+ (eif-current-line-indent) eif-indent-increment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 ;; This option should not occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (error "Could not find assertion tag.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (defun eif-matching-indent (matching-keyword-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 "Search backward from the point looking for one of the keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 in the MATCHING-KEYWORD-REGEXP. Return the indentation of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 keyword found. If an `end' keyword occurs prior to finding one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 the keywords in MATCHING-KEYWORD-REGEXP and it terminates a check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 clause, return the indentation of the `end' minus the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 eif-check-keyword-indent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (let ((search-regexp (concat "[^a-z0-9A-Z_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 eif-end-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 "[^a-z0-9A-Z_]\\|[^a-z0-9A-Z_]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 matching-keyword-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (indent 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (continue t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (while (and (re-search-backward search-regexp 1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (or (eif-in-quoted-string-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (eif-in-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (if (looking-at search-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (if (and (looking-at eif-end-keyword-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (eif-matching-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (string-match eif-check-keyword eif-matching-kw-for-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 ;; The keyword "end" was found that terminated a "check" clause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (setq indent (- (eif-current-line-indent) (eif-check-keyword-indent-m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 ;; Else a keyword in "matching-keyword-regexp" or a normal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ;; "end"was found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (setq indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (message "No matching indent keyword was found")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (defun eif-matching-kw (matching-keyword-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 "Search backward from the point looking for one of the keywords in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 the MATCHING-KEYWORD-REGEXP. Return the keyword found. Also set the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 value of eif-matching-indent to the indentation of the keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 found. If an `end' keyword occurs prior to finding one of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 keywords in MATCHING-KEYWORD-REGEXP and it terminates a check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 clause, set the value of eif-matching-indent to the indentation of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 the `end' minus the value of eif-check-keyword-indent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (let ((search-regexp (concat "[^a-z0-9A-Z_.]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 eif-end-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 "[^a-z0-9A-Z_.]\\|[^a-z0-9A-Z_.]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 matching-keyword-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (keyword "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;; Search backward for a matching keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (while (and (re-search-backward search-regexp 1 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 (or (eif-in-quoted-string-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (eif-in-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (if (looking-at search-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 ;; Then - a keyword was found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (setq keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (buffer-substring (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (if (and (looking-at eif-end-keyword-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (eif-matching-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (string-match eif-check-keyword eif-matching-kw-for-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (setq eif-matching-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (- (eif-current-line-indent) (eif-check-keyword-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (setq eif-matching-indent (eif-current-line-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 ;; Else no keyword was found. I think this is an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (setq eif-matching-indent 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (message "No matching indent keyword was found")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (defun eif-line-contains-close-paren ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 "This function returns t if the current line contains a close paren and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 nil otherwise. If a close paren is found, the point is placed immediately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 after the last close paren on the line. If no paren is found, the point is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 placed at the beginning of the line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (let ((search-min 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (setq search-min (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (if (search-backward ")" search-min t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 ;;;; Not Currently Used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 ;;;(defun eif-quoted-string-on-line-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 ;;; "t if an Eiffel quoted string begins, ends, or is continued
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 ;;; on current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 ;;; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 ;;; (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 ;;; ;; Line must either start with optional whitespace immediately followed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 ;;; ;; by a '%' or include a '\"'. It must either end with a '%' character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 ;;; ;; or must include a second '\"' character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 ;;; (looking-at "^\\([ \t]*%\\|[^\"\n]*\"\\)[^\"\n]*\\(%$\\|\"\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 ;;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 ;;;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (defvar eif-opening-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 "\\<\\(external\\|check\\|deferred\\|do\\|once\\|from\\|if\\|inspect\\)\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 "Keywords that open eiffel nesting constructs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (defvar eif-closing-regexp "\\<end\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 "Keywords that close eiffel nesting constructs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (defvar eif-do-regexp "\\<do\\|once\\|external\\>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 "Keyword that opens eiffel routine body."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (defvar eif-opening-or-closing-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (concat "\\(" eif-opening-regexp "\\|" eif-closing-regexp "\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 "Keywords that open or close eiffel nesting constructs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 ;;; Code to allow indenting whole eiffel blocks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (defun eif-matching-line (&optional return-line-break direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 "Return the character position of the keyword matching the eiffel
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 keyword on the current line. (e.g. a line containing the keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 'do' is matched by a line containing the keyword 'end' and a line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 containing 'end' may be matched by a number of opening keywords.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 If the optional parameter 'return-line-break' is not nil, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 character position returned is the beginning (or end) of the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 containing the matching keyword instead of the position of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 keyword itself. If the second optional parameter, direction, is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 non-null, the current line is not searched for a keyword. Instead,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 if the value of direction is 'forward, the function acts as if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 an eif-opening-regexp is on the current line. If the value of direction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 is 'backward, the function acts as if a eif-closing-regexp is on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 current line. The effect of using the direction parameter is to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 locate either the opening or closing keyword of the syntactic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 construct containing the point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (let ((nesting-level 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (matching-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (search-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (opening-keyword nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (match-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (match-end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (success nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (start-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (modify-syntax-entry ?_ "w ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (setq eif-matching-kw-for-end "");; public variable set by this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (setq start-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (setq search-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ;; Set starting state: If direction was specified use it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 ;; If direction is nil, search for a keyword on the current line
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1439 ;; If the keyword is in eif-opening-regexp, set the search
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;; direction to 'forward, if the keyword on the current line is `end'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ;; set the search direction to 'backward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (cond ((eq direction 'forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (end-of-line);; So we wont see any keywords on the current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (setq nesting-level 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 ((eq direction 'backward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (beginning-of-line);; So we wont see any keywords on the current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (setq nesting-level -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ((and (re-search-forward eif-opening-regexp search-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (not (or (eif-in-quoted-string-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (eif-in-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (setq match-start (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (goto-char match-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (if (not (or (eif-in-quoted-string-p) (eif-in-comment-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (setq nesting-level 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (setq opening-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (cons (buffer-substring match-start (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 opening-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 ((and (progn (beginning-of-line) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (re-search-forward eif-closing-regexp search-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (not (or (eif-in-quoted-string-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (eif-in-comment-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (if (not (or (eif-in-quoted-string-p) (eif-in-comment-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (setq nesting-level -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 ;; Perform the search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (while (not (= nesting-level 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (if (> nesting-level 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 ;; Then search forward for the next keyword not in a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (while (and (re-search-forward eif-opening-or-closing-regexp nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (goto-char (setq match-start (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (setq match-end (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (setq success t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (or (eif-in-quoted-string-p) (eif-in-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (goto-char match-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (setq success nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ;; Else search backward for the next keyword not in a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (while (and (re-search-backward eif-opening-or-closing-regexp nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (goto-char (setq match-start (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (setq success t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (or (eif-in-quoted-string-p) (eif-in-comment-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (setq success nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (cond ((and (looking-at eif-opening-regexp) success)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ;; Found an opening keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (if (> nesting-level 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (if (looking-at eif-do-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (setq nesting-level -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (setq opening-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (cons (buffer-substring match-start (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 opening-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (if (= nesting-level -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (setq eif-matching-kw-for-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (buffer-substring match-start (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (if (looking-at "[ \t\n]+") (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (if (looking-at eif-do-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (goto-char (eif-matching-line nil 'forward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (setq nesting-level -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (setq opening-keyword (cdr opening-keyword))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (if return-line-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (setq nesting-level (1+ nesting-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 ((and (looking-at eif-closing-regexp) success)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ;; Found an opening keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (if (> nesting-level 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 ;; Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (setq opening-keyword (cdr opening-keyword))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (if return-line-break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 ;; Else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (setq opening-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (cons (buffer-substring (match-beginning 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (match-end 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 opening-keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (setq nesting-level (1- nesting-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (t (message (concat "Could not find match"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (if (car opening-keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (concat " for: " (car opening-keyword))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (goto-char start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (setq nesting-level 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 );; cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 );; while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (setq matching-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 );; save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (modify-syntax-entry ?_ "_ ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 );; unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 (set-mark matching-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 );; let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 );; eif-matching-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 ;;; ENHANCEME: Make this function correctly indent more than just routine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 ;;; bodies and their sub-constructs. At the least it should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 ;;; handle whole routines also.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (defun eif-indent-construct ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 "Indents an entire eiffel syntactic construct. It is assumed that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 the point is within a nesting construct ('do', `once', 'check', 'if',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 'from', or 'inspect'). The whole construct is indented up to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 matching end. If the point is not within such a construct, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 only that line is indented"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (let ((end-point 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (if (not (= (point) (point-max))) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (goto-char (eif-matching-line t 'backward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (setq end-point (eif-matching-line t 'forward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (while (< (point) end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (eif-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (defun eif-indent-region (&optional start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 "Indents the lines in the current region"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (let ((start-point (or start (region-beginning)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (end-point (copy-marker (or end (region-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (goto-char start-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (cond ((eq major-mode 'ace-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (while (< (point) end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (if (not (looking-at "[ ]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (ace-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 ((eq major-mode 'eiffel-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (while (< (point) end-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (if (not (looking-at "[ ]*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (eif-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (t (error "Buffer must be in eiffel or ace mode."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 ;;(defun eif-goto-matching-line (&optional direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 ;; "Place the cursor on the line which closes(opens) the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 ;;opening(closing) syntactic construct. For example if the point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 ;;is on `from', executing goto-matching-line places the point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 ;;on the matching `end' and vice-versa."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 ;; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 ;; (if (not direction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 ;; (cond ((save-excursion (beginning-of-line) (looking-at "[ ]*end.*$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 ;; (goto-char (eif-matching-line nil 'backward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 ;; ((looking-at "(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 ;; (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 ;; ((save-excursion (backward-char 1) (looking-at ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 ;; (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 ;; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 ;; (goto-char (eif-matching-line nil 'forward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (defun eif-forward-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 "Place the cursor on the line which closes the current opening syntactic construct. For example if the point is on `from', executing eif-forward-sexp places the point on the matching `end'. This also does matching of parens ala forward-sexp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (cond ((looking-at "[[(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (goto-char (eif-matching-line nil 'forward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (defun eif-backward-sexp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 "Place the cursor on the line which opens the current closing syntactic construct. For example if the point is on the terminating `end' of an `if' statement, executing eif-backward-sexp places the point on the opening `if'. This also does matching of parens ala backward-sexp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (cond ((save-excursion (backward-char 1) (looking-at "[])]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (goto-char (eif-matching-line nil 'backward))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (defun eif-local-indent (amount)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 "Set the value of eif-indent-increment to amount and make the change local to this buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (interactive "NNumber of spaces for eif-indent-increment: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (make-local-variable 'eif-indent-increment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (setq eif-indent-increment amount)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 ;;; Utility Functions. ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (defun eif-feature-quote ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 "Put a `' around the current feature name"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (backward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (insert "`")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (forward-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (insert "'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (if (looking-at "'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (defvar eiffel-mode-abbrev-table nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (define-abbrev-table 'eiffel-mode-abbrev-table ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ;;; ----------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 ;;; This next portion of the file is derived from "eiffel.el"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ;;; Copyright (C) 1989, 1990 Free Software Foundation, Inc. and Bob Weiner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 ;;; Available for use and distribution under the same terms as GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 ;;; ----------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (defvar eiffel-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 "Keymap for Eiffel mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (defvar eiffel-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 "Syntax table in use in Eiffel-mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (if eiffel-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (let ((table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (while (< i ?0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (modify-syntax-entry i "_ " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (setq i (1+ ?9))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (while (< i ?A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (modify-syntax-entry i "_ " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (setq i (1+ ?Z))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (while (< i ?a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (modify-syntax-entry i "_ " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (setq i (1+ ?z))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (while (< i 128)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (modify-syntax-entry i "_ " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (modify-syntax-entry ? " " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (modify-syntax-entry ?- ". 12" table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (modify-syntax-entry ?_ "_ " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (modify-syntax-entry ?\t " " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (modify-syntax-entry ?\n "> " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (modify-syntax-entry ?\f "> " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (modify-syntax-entry ?\" "\" " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (modify-syntax-entry ?\\ "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (modify-syntax-entry ?\( "() " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (modify-syntax-entry ?\) ")( " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (modify-syntax-entry ?\[ "(] " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (modify-syntax-entry ?\] ")[ " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (modify-syntax-entry ?\{ "(} " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (modify-syntax-entry ?\} "){ " table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (modify-syntax-entry ?' "\"" table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (modify-syntax-entry ?` "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (modify-syntax-entry ?/ "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (modify-syntax-entry ?* "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (modify-syntax-entry ?+ "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (modify-syntax-entry ?= "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (modify-syntax-entry ?% "\\" table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (modify-syntax-entry ?< "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 (modify-syntax-entry ?> "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (modify-syntax-entry ?& "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (modify-syntax-entry ?| "." table)
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1773 (modify-syntax-entry ?\; "." table)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (modify-syntax-entry ?: "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (modify-syntax-entry ?! "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (modify-syntax-entry ?. "." table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (setq eiffel-mode-syntax-table table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (if eiffel-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (setq eiffel-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (define-key eiffel-mode-map "\t" 'eif-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (define-key eiffel-mode-map "\C-j" 'eif-newline)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1785 (if (and (boundp 'eif-cr-function) eif-cr-function)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1786 (define-key eiffel-mode-map "\C-m" eif-cr-function)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1787 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (define-key eiffel-mode-map "\M-\C-q" 'eif-indent-construct)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 (define-key eiffel-mode-map "\M-'" 'eif-feature-quote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (define-key eiffel-mode-map "\M-q" 'eif-fill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (defun eiffel-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 "Major mode for editing Eiffel programs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (setq major-mode 'eiffel-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (setq mode-name "Eiffel")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (use-local-map eiffel-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (set-syntax-table eiffel-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 ;; Make local variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 (make-local-variable 'paragraph-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (make-local-variable 'paragraph-separate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (make-local-variable 'paragraph-ignore-fill-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 (make-local-variable 'require-final-newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (make-local-variable 'parse-sexp-ignore-comments)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (make-local-variable 'indent-line-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (make-local-variable 'indent-region-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (make-local-variable 'comment-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (make-local-variable 'comment-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (make-local-variable 'comment-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (make-local-variable 'comment-start-skip)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 ;; Now set their values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (setq paragraph-start (concat "^$\\|" page-delimiter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 paragraph-separate paragraph-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 paragraph-ignore-fill-prefix t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 require-final-newline 'ask
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 parse-sexp-ignore-comments t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 indent-line-function 'eif-indent-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 indent-region-function 'eif-indent-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 comment-start "-- "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 comment-end ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 comment-column 32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 comment-start-skip "--+ *")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (run-hooks 'eiffel-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (setq local-abbrev-table eiffel-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (setq auto-fill-function 'eif-auto-fill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (defun eif-in-comment-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 "t if point is in a comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (and (/= (point) (point-max)) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (search-backward "--" (save-excursion (beginning-of-line) (point)) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1839 ;; ENHANCEME: Currently eif-beginning-of-feature only works for routines.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1840 ;; It should be made more general.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1841 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1842
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1843 (defun eif-beginning-of-feature (&optional arg)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1844 "Move backward to next feature beginning. With argument, do this that many
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1845 times. Returns t unless search stops due to beginning of buffer."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1846 (interactive "p")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1847 (and arg (< arg 0) (forward-char 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1848 (if (or (re-search-backward eif-multiline-routine-is-keyword-regexp
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1849 nil t (or arg 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1850 (re-search-backward eif-is-keyword-regexp
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1851 nil 'move (or arg 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1852 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1853 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1854 (backward-sexp 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1855 (if (looking-at "(")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1856 (backward-word 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1857 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1858 (beginning-of-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1859 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1860 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1861 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1862 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1863
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1864 (defun eif-current-line-indent ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1865 "Return the indentation of the line containing the point."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1866 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1867 (let ((line-end 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1868 (indent 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1869 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1870 (end-of-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1871 (setq line-end (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1872 (beginning-of-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1873 (re-search-forward eif-white-space-regexp line-end t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1874 (setq indent (current-column))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1875 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1876 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1877 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1878
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1879 (defun eif-in-quoted-string-p (&optional non-strict-p)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1880 "t if point is in a quoted string. Optional argument NON-STRICT-P if true
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1881 causes the function to return true even if the point is located in leading
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1882 white space on a continuation line. Normally leading white space is not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1883 considered part of the string."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1884 (let ((initial-regexp "^[ \t]*%\\|[^%]\"\\|%[ \t]*$")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1885 (search-limit (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1886 (count 0)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1887 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1888 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1889 ;; Line must either start with optional whitespace immediately followed
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1890 ;; by a '%' or include a '\"' before the search-limit.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1891 (beginning-of-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1892 (while (re-search-forward initial-regexp search-limit t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1893 (setq count (1+ count))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1894 (if (= count 1) (setq search-limit (1+ search-limit)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1895 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1896 ;; If the number of quotes (including continuation line markers) is odd,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1897 ;; then we are inside of a string. Also if non-strict-p and we are in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1898 ;; the leading white space of a continuation line, then we are in a quote.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1899 (if (= (% count 2) 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1900 t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1901 (beginning-of-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1902 (if non-strict-p
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1903 (if (looking-at "^[ \t]*%")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1904 t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1905 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1906 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1907 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1908 );; if
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1909 );; if
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1910 );; save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1911 );; let
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1912 );; e-in-quoted-string
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1913
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1914 ;;; ----------------------------------------------------------------------
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1915 ;;; End of portion derived from "eiffel.el"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1916 ;;; ----------------------------------------------------------------------
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1917
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (defun eif-comment-prefix ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 "Prefix that starts a comment that begins a line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 Comments that are not the only thing on a line return nil as their prefix."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (let ((limit (point)) len
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (in-string (eif-in-quoted-string-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (cond ((re-search-forward "^[ \t]*--|?[ \t]*" limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (buffer-substring (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 ;; Handle string-literal continuation lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (in-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (re-search-backward "^[ \t]*%\\|[^%]\"" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (re-search-forward "%\\|\"" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (setq len (1- (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (concat (make-string len ? ) "%")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (defun eif-auto-fill ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1946 (let ((fill-prefix (eif-comment-prefix)) (pm (point-marker)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1947 (if (and (> (current-column) fill-column) fill-prefix)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1948 (if (string-match "^[ \t]*%" fill-prefix)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1949 (progn
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (backward-char 1)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1951 (re-search-backward "[^][a-zA-Z0-9]" nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (forward-char 1)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1953 (insert "%\n")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (insert fill-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (goto-char pm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 )
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1957 ;; (do-auto-fill)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1958 (backward-char 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1959 (re-search-backward "\\s-" nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1960 (forward-char 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1961 (insert "\n")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1962 (insert fill-prefix)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1963 (goto-char pm)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 )
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1965 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (defun eif-fill-paragraph ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 "Textually fills Eiffel comments ala fill-paragraph"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (let ((current-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (last-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (para-begin nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 (para-end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (fill-prefix (eif-comment-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 (if fill-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (setq last-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (while (and (not (= (point) last-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (eif-comment-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (setq last-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (if (= (point) last-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (setq para-begin (save-excursion (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 (setq para-begin (1+ (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (goto-char current-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 (setq last-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 (while (and (not (= (point) last-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (eif-comment-prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (setq last-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (if (= (point) last-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (setq para-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (setq para-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (fill-region para-begin para-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (defun eif-newline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 "Insert a newline and indent the new line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (eif-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2025 (defun eif-indent-and-newline ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2026 "Indent the current line. Insert a newline and indent the new line."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2027 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2028 (eif-indent-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2029 (insert "\n")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2030 (eif-indent-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2031 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2032
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (defun eif-indent-line (&optional whole-exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 "Indent the current line as Eiffel code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 With argument, indent any additional lines of the same clause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 rigidly along with this one (not implemented yet)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (let ((indent (eif-calc-indent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (if (not (= indent (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (delete-horizontal-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 (indent-to indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (skip-chars-forward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (defun eif-move-to-prev-non-blank ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 "Moves point to previous line excluding blank lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 Returns t if successful, nil if not."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (re-search-backward "^[ \t]*[^ \t\n]" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 (defvar eif-last-feature-level-indent -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (defvar eif-feature-level-indent-regexp nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 (defun eif-in-paren-expression ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 "Determine if we are inside of a parenthesized expression"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (let ((paren-count 0) (limit 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (if (= eif-last-feature-level-indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (setq limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (re-search-backward eif-feature-level-indent-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (setq eif-last-feature-level-indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 (setq eif-feature-level-indent-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (concat "^" (make-string eif-last-feature-level-indent ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 "[^ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (setq limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (or (re-search-backward eif-feature-level-indent-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (while (re-search-backward "[][()]" limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 (if (looking-at "[[(]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 (setq paren-count (1+ paren-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (setq paren-count (1- paren-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 paren-count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 (defun eif-manifest-array-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 "Determine if we are inside of a manifest array"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (let ((paren-count 0) (indent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (limit 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 (if (= eif-last-feature-level-indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 (setq limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (re-search-backward eif-feature-level-indent-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (setq eif-last-feature-level-indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (setq eif-feature-level-indent-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (concat "^" (make-string eif-last-feature-level-indent ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 "[^ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (setq limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (or (re-search-backward eif-feature-level-indent-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 (while (and (<= paren-count 0) (re-search-backward "<<\\|>>" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (if (looking-at "<<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 (setq paren-count (1+ paren-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (setq paren-count (1- paren-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (if (> paren-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 (let ((eol (save-excursion (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 (setq indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (or (and (re-search-forward "[^< \t]" eol t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 (1- (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (+ (current-column) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 (defun eif-manifest-array-start ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 "Determine the indentation of the statement containing a manifest array"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 (let ((paren-count 0) (indent nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 (limit 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 (if (= eif-last-feature-level-indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 (setq limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 (re-search-backward eif-feature-level-indent-regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 (setq eif-last-feature-level-indent (eif-feature-level-indent-m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 (setq eif-feature-level-indent-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 (concat "^" (make-string eif-last-feature-level-indent ? )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 "[^ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 (setq limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 (or (re-search-backward eif-feature-level-indent-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 (while (and (<= paren-count 0) (re-search-backward "<<\\|>>" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 (if (looking-at "<<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 (setq paren-count (1+ paren-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 (setq paren-count (1- paren-count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (if (> paren-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (let ((limit (progn (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 (if (re-search-forward "^[ \t]*<<" limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 (setq indent (- (current-column) 2 eif-indent-increment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 (re-search-forward "^[ \t]*" limit t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 (setq indent (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 ;;; ----------------------------------------------------------------------
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2176 ;;; The function below is derived from "eif-mult-fmt.el"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 ;;; Copyright (C) 1985 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 ;;; Copyright (C) 1990 Bob Weiner, Motorola Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 ;;; Available for use and distribution under the same terms as GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 ;;; ----------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 (defun eif-indent-multi-line (&optional parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 "Return integer giving appropriate indentation for current Eiffel code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 line between parentheses or double quotes, otherwise -1. Optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 PARSE-START is buffer position at which to begin parsing, default is to begin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 at the feature enclosing or preceding point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 (let ((eif-opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (indent-point (progn (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (eif-ind-val -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 (eif-in-str nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 (eif-paren-depth 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 (retry t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 ;; setting this to a number inhibits calling hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 last-sexp containing-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (if parse-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (goto-char parse-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (eif-beginning-of-feature))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 ;; Find outermost containing sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (while (< (point) indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (setq state (parse-partial-sexp (point) indent-point 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 ;; Find innermost containing sexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (while (and retry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (> (setq eif-paren-depth (elt state 0)) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (setq retry nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 (setq last-sexp (elt state 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (setq containing-sexp (elt state 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 ;; Position following last unclosed open.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 ;; Is there a complete sexp since then?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 (if (and last-sexp (> last-sexp (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 ;; Yes, but is there a containing sexp after that?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (let ((peek (parse-partial-sexp last-sexp indent-point 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (if (setq retry (car (cdr peek))) (setq state peek)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (if retry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 ;; Innermost containing sexp found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (goto-char (1+ containing-sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 (if (not last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 ;; indent-point immediately follows open paren.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 ;; Find the start of first element of containing sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (parse-partial-sexp (point) last-sexp 0 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 (cond ((looking-at "\\s(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 ;; First element of containing sexp is a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 ;; Indent under that list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 ((> (save-excursion (forward-line 1) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 ;; This is the first line to start within the containing sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 (backward-prefix-chars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 ;; Indent beneath first sexp on same line as last-sexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 ;; Again, it's almost certainly a routine call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (goto-char last-sexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 (parse-partial-sexp (point) last-sexp 0 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (backward-prefix-chars))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (setq eif-ind-val (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 ;; Point is at the point to indent under unless we are inside a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (setq eif-in-str (elt state 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (goto-char eif-opoint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (if (not eif-in-str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 ;; Inside a string, indent 1 past string start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 (setq eif-paren-depth 1);; To account for being inside string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (if (re-search-backward "\"" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (setq eif-ind-val (1+ (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (goto-char indent-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (if (looking-at "^[ \t]*[^ \t\n]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (eif-move-to-prev-non-blank))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (setq eif-ind-val (current-column)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (if (> eif-paren-depth 0) eif-ind-val -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 (provide 'eiffel3)