annotate lisp/modes/eiffel3.el @ 0:376386a54a3c r19-14

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