Mercurial > emacs
annotate lisp/progmodes/icon.el @ 32302:ef87e043f166
*** empty log message ***
author | Dave Love <fx@gnu.org> |
---|---|
date | Sun, 08 Oct 2000 17:53:13 +0000 |
parents | 4888d3b1cf29 |
children | 5323492591dd |
rev | line source |
---|---|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
210
diff
changeset
|
1 ;;; icon.el --- mode for editing Icon code |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
210
diff
changeset
|
2 |
845 | 3 ;; Copyright (C) 1989 Free Software Foundation, Inc. |
4 | |
12910
8aa95606db04
Define user options with defvar, not defconst.
Richard M. Stallman <rms@gnu.org>
parents:
10874
diff
changeset
|
5 ;; Author: Chris Smith <csmith@convex.com> |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
6 ;; Created: 15 Feb 89 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: languages |
36 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
36 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
26 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
27 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
28 ;; A major mode for editing the Icon programming language. |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
29 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
30 ;;; Code: |
36 | 31 |
32 (defvar icon-mode-abbrev-table nil | |
33 "Abbrev table in use in Icon-mode buffers.") | |
34 (define-abbrev-table 'icon-mode-abbrev-table ()) | |
35 | |
36 (defvar icon-mode-map () | |
37 "Keymap used in Icon mode.") | |
38 (if icon-mode-map | |
39 () | |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
40 (let ((map (make-sparse-keymap "Icon"))) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
41 (setq icon-mode-map (make-sparse-keymap)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
42 (define-key icon-mode-map "{" 'electric-icon-brace) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
43 (define-key icon-mode-map "}" 'electric-icon-brace) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
44 (define-key icon-mode-map "\e\C-h" 'mark-icon-function) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
45 (define-key icon-mode-map "\e\C-a" 'beginning-of-icon-defun) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
46 (define-key icon-mode-map "\e\C-e" 'end-of-icon-defun) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
47 (define-key icon-mode-map "\e\C-q" 'indent-icon-exp) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
48 (define-key icon-mode-map "\177" 'backward-delete-char-untabify) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
49 (define-key icon-mode-map "\t" 'icon-indent-command) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
50 |
32299
4888d3b1cf29
(icon-mode-map): Add name to menu-bar keymap.
Dave Love <fx@gnu.org>
parents:
32155
diff
changeset
|
51 (define-key icon-mode-map [menu-bar] (make-sparse-keymap "Icon")) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 (define-key icon-mode-map [menu-bar icon] |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
53 (cons "Icon" map)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
54 (define-key map [beginning-of-icon-defun] '("Beginning of function" . beginning-of-icon-defun)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 (define-key map [end-of-icon-defun] '("End of function" . end-of-icon-defun)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
56 (define-key map [comment-region] '("Comment Out Region" . comment-region)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 (define-key map [indent-region] '("Indent Region" . indent-region)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
58 (define-key map [indent-line] '("Indent Line" . icon-indent-command)) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 (put 'eval-region 'menu-enable 'mark-active) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 (put 'comment-region 'menu-enable 'mark-active) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
61 (put 'indent-region 'menu-enable 'mark-active))) |
36 | 62 |
63 (defvar icon-mode-syntax-table nil | |
64 "Syntax table in use in Icon-mode buffers.") | |
65 | |
66 (if icon-mode-syntax-table | |
67 () | |
68 (setq icon-mode-syntax-table (make-syntax-table)) | |
69 (modify-syntax-entry ?\\ "\\" icon-mode-syntax-table) | |
70 (modify-syntax-entry ?# "<" icon-mode-syntax-table) | |
71 (modify-syntax-entry ?\n ">" icon-mode-syntax-table) | |
72 (modify-syntax-entry ?$ "." icon-mode-syntax-table) | |
73 (modify-syntax-entry ?/ "." icon-mode-syntax-table) | |
74 (modify-syntax-entry ?* "." icon-mode-syntax-table) | |
75 (modify-syntax-entry ?+ "." icon-mode-syntax-table) | |
76 (modify-syntax-entry ?- "." icon-mode-syntax-table) | |
77 (modify-syntax-entry ?= "." icon-mode-syntax-table) | |
78 (modify-syntax-entry ?% "." icon-mode-syntax-table) | |
79 (modify-syntax-entry ?< "." icon-mode-syntax-table) | |
80 (modify-syntax-entry ?> "." icon-mode-syntax-table) | |
81 (modify-syntax-entry ?& "." icon-mode-syntax-table) | |
82 (modify-syntax-entry ?| "." icon-mode-syntax-table) | |
83 (modify-syntax-entry ?\' "\"" icon-mode-syntax-table)) | |
84 | |
17633 | 85 (defgroup icon nil |
86 "Mode for editing Icon code." | |
87 :group 'languages) | |
88 | |
89 (defcustom icon-indent-level 4 | |
90 "*Indentation of Icon statements with respect to containing block." | |
91 :type 'integer | |
92 :group 'icon) | |
93 | |
94 (defcustom icon-brace-imaginary-offset 0 | |
95 "*Imagined indentation of a Icon open brace that actually follows a statement." | |
96 :type 'integer | |
97 :group 'icon) | |
98 | |
99 (defcustom icon-brace-offset 0 | |
100 "*Extra indentation for braces, compared with other text in same context." | |
101 :type 'integer | |
102 :group 'icon) | |
36 | 103 |
17633 | 104 (defcustom icon-continued-statement-offset 4 |
105 "*Extra indent for Icon lines not starting new statements." | |
106 :type 'integer | |
107 :group 'icon) | |
108 | |
109 (defcustom icon-continued-brace-offset 0 | |
110 "*Extra indent for Icon substatements that start with open-braces. | |
111 This is in addition to `icon-continued-statement-offset'." | |
112 :type 'integer | |
113 :group 'icon) | |
36 | 114 |
17633 | 115 (defcustom icon-auto-newline nil |
116 "*Non-nil means automatically newline before and after braces Icon code. | |
117 This applies when braces are inserted." | |
118 :type 'boolean | |
119 :group 'icon) | |
120 | |
121 (defcustom icon-tab-always-indent t | |
122 "*Non-nil means TAB in Icon mode should always reindent the current line. | |
123 It will then reindent, regardless of where in the line point is | |
124 when the TAB command is used." | |
19834
63f793f84d0f
(icon-tab-always-indent): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents:
18381
diff
changeset
|
125 :type 'boolean |
17633 | 126 :group 'icon) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
127 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
128 (defvar icon-imenu-generic-expression |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
129 '((nil "^[ \t]*procedure[ \t]+\\(\\sw+\\)[ \t]*(" 1)) |
17633 | 130 "Imenu expression for Icon mode. See `imenu-generic-expression'.") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
131 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
132 |
36 | 133 |
9055
2e089bdec449
(icon-mode): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
134 ;;;###autoload |
36 | 135 (defun icon-mode () |
136 "Major mode for editing Icon code. | |
137 Expression and list commands understand all Icon brackets. | |
138 Tab indents for Icon code. | |
139 Paragraphs are separated by blank lines only. | |
140 Delete converts tabs to spaces as it moves back. | |
141 \\{icon-mode-map} | |
142 Variables controlling indentation style: | |
143 icon-tab-always-indent | |
144 Non-nil means TAB in Icon mode should always reindent the current line, | |
145 regardless of where in the line point is when the TAB command is used. | |
146 icon-auto-newline | |
147 Non-nil means automatically newline before and after braces | |
148 inserted in Icon code. | |
149 icon-indent-level | |
150 Indentation of Icon statements within surrounding block. | |
151 The surrounding block's indentation is the indentation | |
152 of the line on which the open-brace appears. | |
153 icon-continued-statement-offset | |
154 Extra indentation given to a substatement, such as the | |
155 then-clause of an if or body of a while. | |
156 icon-continued-brace-offset | |
157 Extra indentation given to a brace that starts a substatement. | |
210 | 158 This is in addition to `icon-continued-statement-offset'. |
36 | 159 icon-brace-offset |
160 Extra indentation for line if it starts with an open brace. | |
161 icon-brace-imaginary-offset | |
162 An open brace following other text is treated as if it were | |
163 this far to the right of the start of its line. | |
164 | |
210 | 165 Turning on Icon mode calls the value of the variable `icon-mode-hook' |
166 with no args, if that value is non-nil." | |
36 | 167 (interactive) |
168 (kill-all-local-variables) | |
169 (use-local-map icon-mode-map) | |
170 (setq major-mode 'icon-mode) | |
171 (setq mode-name "Icon") | |
172 (setq local-abbrev-table icon-mode-abbrev-table) | |
173 (set-syntax-table icon-mode-syntax-table) | |
174 (make-local-variable 'paragraph-start) | |
10874
7ad2cc4e9963
(icon-mode): Remove ^ from paragraph-start & paragraph-separate.
Boris Goldowsky <boris@gnu.org>
parents:
9055
diff
changeset
|
175 (setq paragraph-start (concat "$\\|" page-delimiter)) |
36 | 176 (make-local-variable 'paragraph-separate) |
177 (setq paragraph-separate paragraph-start) | |
178 (make-local-variable 'indent-line-function) | |
179 (setq indent-line-function 'icon-indent-line) | |
180 (make-local-variable 'require-final-newline) | |
181 (setq require-final-newline t) | |
182 (make-local-variable 'comment-start) | |
183 (setq comment-start "# ") | |
184 (make-local-variable 'comment-end) | |
185 (setq comment-end "") | |
186 (make-local-variable 'comment-start-skip) | |
187 (setq comment-start-skip "# *") | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
188 (make-local-variable 'comment-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
189 (setq comment-indent-function 'icon-comment-indent) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
190 ;; font-lock support |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
191 (make-local-variable 'font-lock-defaults) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
192 (setq font-lock-defaults |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
193 '((icon-font-lock-keywords |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
194 icon-font-lock-keywords-1 icon-font-lock-keywords-2) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
195 nil nil ((?_ . "w")) beginning-of-defun |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
196 ;; Obsoleted by Emacs 19.35 parse-partial-sexp's COMMENTSTOP. |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
197 ;(font-lock-comment-start-regexp . "#") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
198 (font-lock-mark-block-function . mark-defun))) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
199 ;; imenu support |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
200 (make-local-variable 'imenu-generic-expression) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
201 (setq imenu-generic-expression icon-imenu-generic-expression) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
202 ;; hideshow support |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
203 ;; we start from the assertion that `hs-special-modes-alist' is autoloaded. |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
204 (unless (assq 'icon-mode hs-special-modes-alist) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
205 (setq hs-special-modes-alist |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
206 (cons '(icon-mode "\\<procedure\\>" "\\<end\\>" nil |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
207 icon-forward-sexp-function) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
208 hs-special-modes-alist))) |
36 | 209 (run-hooks 'icon-mode-hook)) |
210 | |
210 | 211 ;; This is used by indent-for-comment to decide how much to |
212 ;; indent a comment in Icon code based on its context. | |
36 | 213 (defun icon-comment-indent () |
214 (if (looking-at "^#") | |
215 0 | |
216 (save-excursion | |
217 (skip-chars-backward " \t") | |
218 (max (if (bolp) 0 (1+ (current-column))) | |
219 comment-column)))) | |
220 | |
221 (defun electric-icon-brace (arg) | |
222 "Insert character and correct line's indentation." | |
223 (interactive "P") | |
224 (let (insertpos) | |
225 (if (and (not arg) | |
226 (eolp) | |
227 (or (save-excursion | |
228 (skip-chars-backward " \t") | |
229 (bolp)) | |
230 (if icon-auto-newline | |
231 (progn (icon-indent-line) (newline) t) | |
232 nil))) | |
233 (progn | |
234 (insert last-command-char) | |
235 (icon-indent-line) | |
236 (if icon-auto-newline | |
237 (progn | |
238 (newline) | |
239 ;; (newline) may have done auto-fill | |
240 (setq insertpos (- (point) 2)) | |
241 (icon-indent-line))) | |
242 (save-excursion | |
243 (if insertpos (goto-char (1+ insertpos))) | |
244 (delete-char -1)))) | |
245 (if insertpos | |
246 (save-excursion | |
247 (goto-char insertpos) | |
248 (self-insert-command (prefix-numeric-value arg))) | |
249 (self-insert-command (prefix-numeric-value arg))))) | |
250 | |
251 (defun icon-indent-command (&optional whole-exp) | |
252 (interactive "P") | |
253 "Indent current line as Icon code, or in some cases insert a tab character. | |
210 | 254 If `icon-tab-always-indent' is non-nil (the default), always indent current |
255 line. Otherwise, indent the current line only if point is at the left margin | |
36 | 256 or in the line's indentation; otherwise insert a tab. |
257 | |
210 | 258 A numeric argument, regardless of its value, means indent rigidly all the |
259 lines of the expression starting after point so that this line becomes | |
260 properly indented. The relative indentation among the lines of the | |
261 expression are preserved." | |
36 | 262 (if whole-exp |
263 ;; If arg, always indent this line as Icon | |
264 ;; and shift remaining lines of expression the same amount. | |
265 (let ((shift-amt (icon-indent-line)) | |
266 beg end) | |
267 (save-excursion | |
268 (if icon-tab-always-indent | |
269 (beginning-of-line)) | |
270 (setq beg (point)) | |
271 (forward-sexp 1) | |
272 (setq end (point)) | |
273 (goto-char beg) | |
274 (forward-line 1) | |
275 (setq beg (point))) | |
276 (if (> end beg) | |
277 (indent-code-rigidly beg end shift-amt "#"))) | |
278 (if (and (not icon-tab-always-indent) | |
279 (save-excursion | |
280 (skip-chars-backward " \t") | |
281 (not (bolp)))) | |
282 (insert-tab) | |
283 (icon-indent-line)))) | |
284 | |
285 (defun icon-indent-line () | |
286 "Indent current line as Icon code. | |
287 Return the amount the indentation changed by." | |
288 (let ((indent (calculate-icon-indent nil)) | |
289 beg shift-amt | |
290 (case-fold-search nil) | |
291 (pos (- (point-max) (point)))) | |
292 (beginning-of-line) | |
293 (setq beg (point)) | |
294 (cond ((eq indent nil) | |
295 (setq indent (current-indentation))) | |
30947 | 296 ((looking-at "^#") |
36 | 297 (setq indent 0)) |
298 (t | |
299 (skip-chars-forward " \t") | |
300 (if (listp indent) (setq indent (car indent))) | |
301 (cond ((and (looking-at "else\\b") | |
302 (not (looking-at "else\\s_"))) | |
303 (setq indent (save-excursion | |
304 (icon-backward-to-start-of-if) | |
305 (current-indentation)))) | |
306 ((or (= (following-char) ?}) | |
307 (looking-at "end\\b")) | |
308 (setq indent (- indent icon-indent-level))) | |
309 ((= (following-char) ?{) | |
310 (setq indent (+ indent icon-brace-offset)))))) | |
311 (skip-chars-forward " \t") | |
312 (setq shift-amt (- indent (current-column))) | |
313 (if (zerop shift-amt) | |
314 (if (> (- (point-max) pos) (point)) | |
315 (goto-char (- (point-max) pos))) | |
316 (delete-region beg (point)) | |
317 (indent-to indent) | |
318 ;; If initial point was within line's indentation, | |
319 ;; position after the indentation. Else stay at same point in text. | |
320 (if (> (- (point-max) pos) (point)) | |
321 (goto-char (- (point-max) pos)))) | |
322 shift-amt)) | |
323 | |
324 (defun calculate-icon-indent (&optional parse-start) | |
325 "Return appropriate indentation for current line as Icon code. | |
326 In usual case returns an integer: the column to indent to. | |
327 Returns nil if line starts inside a string, t if in a comment." | |
328 (save-excursion | |
329 (beginning-of-line) | |
330 (let ((indent-point (point)) | |
331 (case-fold-search nil) | |
332 state | |
333 containing-sexp | |
334 toplevel) | |
335 (if parse-start | |
336 (goto-char parse-start) | |
337 (setq toplevel (beginning-of-icon-defun))) | |
338 (while (< (point) indent-point) | |
339 (setq parse-start (point)) | |
340 (setq state (parse-partial-sexp (point) indent-point 0)) | |
341 (setq containing-sexp (car (cdr state)))) | |
342 (cond ((or (nth 3 state) (nth 4 state)) | |
343 ;; return nil or t if should not change this line | |
344 (nth 4 state)) | |
345 ((and containing-sexp | |
346 (/= (char-after containing-sexp) ?{)) | |
347 ;; line is expression, not statement: | |
348 ;; indent to just after the surrounding open. | |
349 (goto-char (1+ containing-sexp)) | |
350 (current-column)) | |
351 (t | |
352 (if toplevel | |
353 ;; Outside any procedures. | |
354 (progn (icon-backward-to-noncomment (point-min)) | |
355 (if (icon-is-continuation-line) | |
356 icon-continued-statement-offset 0)) | |
357 ;; Statement level. | |
358 (if (null containing-sexp) | |
359 (progn (beginning-of-icon-defun) | |
360 (setq containing-sexp (point)))) | |
361 (goto-char indent-point) | |
362 ;; Is it a continuation or a new statement? | |
363 ;; Find previous non-comment character. | |
364 (icon-backward-to-noncomment containing-sexp) | |
365 ;; Now we get the answer. | |
366 (if (icon-is-continuation-line) | |
367 ;; This line is continuation of preceding line's statement; | |
368 ;; indent icon-continued-statement-offset more than the | |
369 ;; first line of the statement. | |
370 (progn | |
371 (icon-backward-to-start-of-continued-exp containing-sexp) | |
372 (+ icon-continued-statement-offset (current-column) | |
373 (if (save-excursion (goto-char indent-point) | |
374 (skip-chars-forward " \t") | |
375 (eq (following-char) ?{)) | |
376 icon-continued-brace-offset 0))) | |
377 ;; This line starts a new statement. | |
378 ;; Position following last unclosed open. | |
379 (goto-char containing-sexp) | |
380 ;; Is line first statement after an open-brace? | |
381 (or | |
382 ;; If no, find that first statement and indent like it. | |
383 (save-excursion | |
384 (if (looking-at "procedure\\s ") | |
385 (forward-sexp 3) | |
386 (forward-char 1)) | |
387 (while (progn (skip-chars-forward " \t\n") | |
388 (looking-at "#")) | |
389 ;; Skip over comments following openbrace. | |
390 (forward-line 1)) | |
391 ;; The first following code counts | |
392 ;; if it is before the line we want to indent. | |
393 (and (< (point) indent-point) | |
394 (current-column))) | |
395 ;; If no previous statement, | |
396 ;; indent it relative to line brace is on. | |
397 ;; For open brace in column zero, don't let statement | |
398 ;; start there too. If icon-indent-level is zero, | |
399 ;; use icon-brace-offset + icon-continued-statement-offset | |
400 ;; instead. | |
401 ;; For open-braces not the first thing in a line, | |
402 ;; add in icon-brace-imaginary-offset. | |
403 (+ (if (and (bolp) (zerop icon-indent-level)) | |
404 (+ icon-brace-offset | |
405 icon-continued-statement-offset) | |
406 icon-indent-level) | |
407 ;; Move back over whitespace before the openbrace. | |
408 ;; If openbrace is not first nonwhite thing on the line, | |
409 ;; add the icon-brace-imaginary-offset. | |
410 (progn (skip-chars-backward " \t") | |
411 (if (bolp) 0 icon-brace-imaginary-offset)) | |
412 ;; Get initial indentation of the line we are on. | |
413 (current-indentation)))))))))) | |
414 | |
415 ;; List of words to check for as the last thing on a line. | |
416 ;; If cdr is t, next line is a continuation of the same statement, | |
417 ;; if cdr is nil, next line starts a new (possibly indented) statement. | |
418 | |
419 (defconst icon-resword-alist | |
420 '(("by" . t) ("case" . t) ("create") ("do") ("dynamic" . t) ("else") | |
421 ("every" . t) ("if" . t) ("global" . t) ("initial" . t) | |
422 ("link" . t) ("local" . t) ("of") ("record" . t) ("repeat" . t) | |
423 ("static" . t) ("then") ("to" . t) ("until" . t) ("while" . t))) | |
424 | |
425 (defun icon-is-continuation-line () | |
426 (let* ((ch (preceding-char)) | |
427 (ch-syntax (char-syntax ch))) | |
428 (if (eq ch-syntax ?w) | |
429 (assoc (buffer-substring | |
430 (progn (forward-word -1) (point)) | |
431 (progn (forward-word 1) (point))) | |
432 icon-resword-alist) | |
30947 | 433 (not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\# ?\, ?\. ?\n)))))) |
36 | 434 |
435 (defun icon-backward-to-noncomment (lim) | |
436 (let (opoint stop) | |
437 (while (not stop) | |
438 (skip-chars-backward " \t\n\f" lim) | |
439 (setq opoint (point)) | |
440 (beginning-of-line) | |
441 (if (and (nth 5 (parse-partial-sexp (point) opoint)) | |
442 (< lim (point))) | |
443 (search-backward "#") | |
444 (setq stop t))))) | |
445 | |
446 (defun icon-backward-to-start-of-continued-exp (lim) | |
447 (if (memq (preceding-char) '(?\) ?\])) | |
448 (forward-sexp -1)) | |
449 (beginning-of-line) | |
450 (skip-chars-forward " \t") | |
451 (cond | |
452 ((<= (point) lim) (goto-char (1+ lim))) | |
453 ((not (icon-is-continued-line)) 0) | |
454 ((and (eq (char-syntax (following-char)) ?w) | |
455 (cdr | |
456 (assoc (buffer-substring (point) | |
457 (save-excursion (forward-word 1) (point))) | |
458 icon-resword-alist))) 0) | |
459 (t (end-of-line 0) (icon-backward-to-start-of-continued-exp lim)))) | |
460 | |
461 (defun icon-is-continued-line () | |
462 (save-excursion | |
463 (end-of-line 0) | |
464 (icon-is-continuation-line))) | |
465 | |
466 (defun icon-backward-to-start-of-if (&optional limit) | |
210 | 467 "Move to the start of the last \"unbalanced\" if." |
36 | 468 (or limit (setq limit (save-excursion (beginning-of-icon-defun) (point)))) |
469 (let ((if-level 1) | |
470 (case-fold-search nil)) | |
471 (while (not (zerop if-level)) | |
472 (backward-sexp 1) | |
473 (cond ((looking-at "else\\b") | |
474 (setq if-level (1+ if-level))) | |
475 ((looking-at "if\\b") | |
476 (setq if-level (1- if-level))) | |
477 ((< (point) limit) | |
478 (setq if-level 0) | |
479 (goto-char limit)))))) | |
480 | |
481 (defun mark-icon-function () | |
482 "Put mark at end of Icon function, point at beginning." | |
483 (interactive) | |
484 (push-mark (point)) | |
485 (end-of-icon-defun) | |
486 (push-mark (point)) | |
487 (beginning-of-line 0) | |
488 (beginning-of-icon-defun)) | |
489 | |
490 (defun beginning-of-icon-defun () | |
491 "Go to the start of the enclosing procedure; return t if at top level." | |
492 (interactive) | |
493 (if (re-search-backward "^procedure\\s \\|^end[ \t\n]" (point-min) 'move) | |
494 (looking-at "e") | |
495 t)) | |
496 | |
497 (defun end-of-icon-defun () | |
498 (interactive) | |
499 (if (not (bobp)) (forward-char -1)) | |
500 (re-search-forward "\\(\\s \\|^\\)end\\(\\s \\|$\\)" (point-max) 'move) | |
501 (forward-word -1) | |
502 (forward-line 1)) | |
503 | |
504 (defun indent-icon-exp () | |
505 "Indent each line of the Icon grouping following point." | |
506 (interactive) | |
507 (let ((indent-stack (list nil)) | |
508 (contain-stack (list (point))) | |
509 (case-fold-search nil) | |
510 restart outer-loop-done inner-loop-done state ostate | |
17974
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
511 this-indent last-sexp last-depth |
36 | 512 at-else at-brace at-do |
513 (opoint (point)) | |
514 (next-depth 0)) | |
515 (save-excursion | |
516 (forward-sexp 1)) | |
517 (save-excursion | |
518 (setq outer-loop-done nil) | |
519 (while (and (not (eobp)) (not outer-loop-done)) | |
520 (setq last-depth next-depth) | |
521 ;; Compute how depth changes over this line | |
522 ;; plus enough other lines to get to one that | |
523 ;; does not end inside a comment or string. | |
524 ;; Meanwhile, do appropriate indentation on comment lines. | |
17974
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
525 (setq inner-loop-done nil) |
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
526 (while (and (not inner-loop-done) |
36 | 527 (not (and (eobp) (setq outer-loop-done t)))) |
528 (setq ostate state) | |
529 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point)) | |
530 nil nil state)) | |
531 (setq next-depth (car state)) | |
532 (if (and (car (cdr (cdr state))) | |
533 (>= (car (cdr (cdr state))) 0)) | |
534 (setq last-sexp (car (cdr (cdr state))))) | |
535 (if (or (nth 4 ostate)) | |
536 (icon-indent-line)) | |
537 (if (or (nth 3 state)) | |
538 (forward-line 1) | |
17974
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
539 (setq inner-loop-done t))) |
36 | 540 (if (<= next-depth 0) |
541 (setq outer-loop-done t)) | |
542 (if outer-loop-done | |
543 nil | |
544 (if (/= last-depth next-depth) | |
545 (setq last-sexp nil)) | |
546 (while (> last-depth next-depth) | |
547 (setq indent-stack (cdr indent-stack) | |
548 contain-stack (cdr contain-stack) | |
549 last-depth (1- last-depth))) | |
550 (while (< last-depth next-depth) | |
551 (setq indent-stack (cons nil indent-stack) | |
552 contain-stack (cons nil contain-stack) | |
553 last-depth (1+ last-depth))) | |
554 (if (null (car contain-stack)) | |
555 (setcar contain-stack (or (car (cdr state)) | |
556 (save-excursion (forward-sexp -1) | |
557 (point))))) | |
558 (forward-line 1) | |
559 (skip-chars-forward " \t") | |
560 (if (eolp) | |
561 nil | |
562 (if (and (car indent-stack) | |
563 (>= (car indent-stack) 0)) | |
564 ;; Line is on an existing nesting level. | |
565 ;; Lines inside parens are handled specially. | |
566 (if (/= (char-after (car contain-stack)) ?{) | |
567 (setq this-indent (car indent-stack)) | |
568 ;; Line is at statement level. | |
569 ;; Is it a new statement? Is it an else? | |
570 ;; Find last non-comment character before this line | |
571 (save-excursion | |
572 (setq at-else (looking-at "else\\W")) | |
573 (setq at-brace (= (following-char) ?{)) | |
574 (icon-backward-to-noncomment opoint) | |
575 (if (icon-is-continuation-line) | |
576 ;; Preceding line did not end in comma or semi; | |
577 ;; indent this line icon-continued-statement-offset | |
578 ;; more than previous. | |
579 (progn | |
580 (icon-backward-to-start-of-continued-exp (car contain-stack)) | |
581 (setq this-indent | |
582 (+ icon-continued-statement-offset (current-column) | |
583 (if at-brace icon-continued-brace-offset 0)))) | |
584 ;; Preceding line ended in comma or semi; | |
585 ;; use the standard indent for this level. | |
586 (if at-else | |
587 (progn (icon-backward-to-start-of-if opoint) | |
588 (setq this-indent (current-indentation))) | |
589 (setq this-indent (car indent-stack)))))) | |
590 ;; Just started a new nesting level. | |
591 ;; Compute the standard indent for this level. | |
592 (let ((val (calculate-icon-indent | |
593 (if (car indent-stack) | |
594 (- (car indent-stack)))))) | |
595 (setcar indent-stack | |
596 (setq this-indent val)))) | |
597 ;; Adjust line indentation according to its contents | |
598 (if (or (= (following-char) ?}) | |
599 (looking-at "end\\b")) | |
600 (setq this-indent (- this-indent icon-indent-level))) | |
601 (if (= (following-char) ?{) | |
602 (setq this-indent (+ this-indent icon-brace-offset))) | |
603 ;; Put chosen indentation into effect. | |
604 (or (= (current-column) this-indent) | |
605 (progn | |
606 (delete-region (point) (progn (beginning-of-line) (point))) | |
607 (indent-to this-indent))) | |
608 ;; Indent any comment following the text. | |
609 (or (looking-at comment-start-skip) | |
610 (if (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t) | |
611 (progn (indent-for-comment) (beginning-of-line)))))))))) | |
612 | |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
613 (defconst icon-font-lock-keywords-1 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
614 (eval-when-compile |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
615 (list |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
616 ;; Fontify procedure name definitions. |
18281
ffc2fda197bc
(icon-indent-line): A comment ends at the end of the
Richard M. Stallman <rms@gnu.org>
parents:
18272
diff
changeset
|
617 '("^[ \t]*\\(procedure\\)\\>[ \t]*\\(\\sw+\\)?" |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
618 (1 font-lock-builtin-face) (2 font-lock-function-name-face nil t)))) |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
619 "Subdued level highlighting for Icon mode.") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
620 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
621 (defconst icon-font-lock-keywords-2 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
622 (append |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
623 icon-font-lock-keywords-1 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
624 (eval-when-compile |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
625 (list |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
626 ;; Fontify all type specifiers. |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
627 (cons |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
628 (concat |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
629 "\\<" (regexp-opt '("null" "string" "co-expression" "table" "integer" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
630 "cset" "set" "real" "file" "list") t) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
631 "\\>") |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
632 'font-lock-type-face) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
633 ;; Fontify all keywords. |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
634 ;; |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
635 (cons |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
636 (concat |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
637 "\\<" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
638 (regexp-opt |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
639 '("break" "do" "next" "repeat" "to" "by" "else" "if" "not" "return" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
640 "until" "case" "of" "while" "create" "every" "suspend" "default" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
641 "fail" "record" "then") t) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
642 "\\>") |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
643 'font-lock-keyword-face) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
644 ;; "end" "initial" |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
645 (cons (concat "\\<" (regexp-opt '("end" "initial") t) "\\>") |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
646 'font-lock-builtin-face) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
647 ;; Fontify all system variables. |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
648 (cons |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
649 (regexp-opt |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
650 '("&allocated" "&ascii" "&clock" "&col" "&collections" "&column" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
651 "&control" "&cset" "¤t" "&date" "&dateline" "&digits" "&dump" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
652 "&e" "&error" "&errornumber" "&errortext" "&errorvalue" "&errout" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
653 "&eventcode" "&eventsource" "&eventvalue" "&fail" "&features" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
654 "&file" "&host" "&input" "&interval" "&lcase" "&ldrag" "&letters" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
655 "&level" "&line" "&lpress" "&lrelease" "&main" "&mdrag" "&meta" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
656 "&mpress" "&mrelease" "&null" "&output" "&phi" "&pi" "&pos" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
657 "&progname" "&random" "&rdrag" "®ions" "&resize" "&row" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
658 "&rpress" "&rrelease" "&shift" "&source" "&storage" "&subject" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
659 "&time" "&trace" "&ucase" "&version" "&window" "&x" "&y") t) |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
19834
diff
changeset
|
660 'font-lock-constant-face) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
661 (cons ;; global local static declarations and link files |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
662 (concat |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
663 "^[ \t]*" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
664 (regexp-opt '("global" "link" "local" "static") t) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
665 "\\(\\sw+\\>\\)*") |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
666 '((1 font-lock-builtin-face) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
667 (font-lock-match-c-style-declaration-item-and-skip-to-next |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
668 (goto-char (or (match-beginning 2) (match-end 1))) nil |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
669 (1 (if (match-beginning 2) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
670 font-lock-function-name-face |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
671 font-lock-variable-name-face))))) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
672 |
18281
ffc2fda197bc
(icon-indent-line): A comment ends at the end of the
Richard M. Stallman <rms@gnu.org>
parents:
18272
diff
changeset
|
673 (cons ;; $define $elif $ifdef $ifndef $undef |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
674 (concat "^" |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
675 (regexp-opt'("$define" "$elif" "$ifdef" "$ifndef" "$undef") t) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
676 "\\>[ \t]*\\([^ \t\n]+\\)?") |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
677 '((1 font-lock-builtin-face) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
678 (4 font-lock-variable-name-face nil t))) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
679 (cons ;; $dump $endif $else $include |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
680 (concat |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
681 "^" (regexp-opt'("$dump" "$endif" "$else" "$include") t) "\\>" ) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
682 'font-lock-builtin-face) |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
683 (cons ;; $warning $error |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
684 (concat "^" (regexp-opt '("$warning" "$error") t) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
685 "\\>[ \t]*\\(.+\\)?") |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
686 '((1 font-lock-builtin-face) (3 font-lock-warning-face nil t)))))) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
687 "Gaudy level highlighting for Icon mode.") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
688 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
689 (defvar icon-font-lock-keywords icon-font-lock-keywords-1 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
690 "Default expressions to highlight in `icon-mode'.") |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
691 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
692 ;;;used by hs-minor-mode |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
693 (defun icon-forward-sexp-function (arg) |
17969
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
694 (if (< arg 0) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
695 (beginning-of-icon-defun) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
696 (end-of-icon-defun) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
697 (forward-char -1))) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
698 |
18381 | 699 (provide 'icon) |
700 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
210
diff
changeset
|
701 ;;; icon.el ends here |