Mercurial > emacs
annotate lisp/progmodes/icon.el @ 66324:3ef412c92565
*** empty log message ***
author | Andreas Schwab <schwab@suse.de> |
---|---|
date | Sun, 23 Oct 2005 09:45:44 +0000 |
parents | 629afbe74e61 |
children | a11fdee52c05 edf295560b5a |
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 |
64699
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005 |
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
845 | 5 |
12910
8aa95606db04
Define user options with defvar, not defconst.
Richard M. Stallman <rms@gnu.org>
parents:
10874
diff
changeset
|
6 ;; Author: Chris Smith <csmith@convex.com> |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
7 ;; Created: 15 Feb 89 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
8 ;; Keywords: languages |
36 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; 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
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 15 ;; any later version. |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
36 | 26 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
27 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
28 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
29 ;; 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
|
30 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
660
diff
changeset
|
31 ;;; Code: |
36 | 32 |
33 (defvar icon-mode-abbrev-table nil | |
34 "Abbrev table in use in Icon-mode buffers.") | |
35 (define-abbrev-table 'icon-mode-abbrev-table ()) | |
36 | |
37 (defvar icon-mode-map () | |
38 "Keymap used in Icon mode.") | |
39 (if icon-mode-map | |
40 () | |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
41 (let ((map (make-sparse-keymap "Icon"))) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
42 (setq icon-mode-map (make-sparse-keymap)) |
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 "}" 'electric-icon-brace) |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
45 (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
|
46 (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
|
47 (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
|
48 (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
|
49 (define-key icon-mode-map "\177" 'backward-delete-char-untabify) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
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) | |
59245
11d2d878c92f
(icon-mode): Use mode-require-final-newline.
Richard M. Stallman <rms@gnu.org>
parents:
54014
diff
changeset
|
181 (setq require-final-newline mode-require-final-newline) |
36 | 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) |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
190 (set (make-local-variable 'indent-line-function) 'icon-indent-line) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
191 ;; font-lock support |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
192 (setq font-lock-defaults |
17266
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 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
206 (cons '(icon-mode "\\<procedure\\>" "\\<end\\>" nil |
18272
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))) |
62772
f2892faa87d4
* progmodes/ada-mode.el (ada-mode):
Lute Kamstra <lute@gnu.org>
parents:
59245
diff
changeset
|
209 (run-mode-hooks 'icon-mode-hook)) |
36 | 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 () |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
214 (if (looking-at "^#") 0 comment-column)) |
36 | 215 |
216 (defun electric-icon-brace (arg) | |
217 "Insert character and correct line's indentation." | |
218 (interactive "P") | |
219 (let (insertpos) | |
220 (if (and (not arg) | |
221 (eolp) | |
222 (or (save-excursion | |
223 (skip-chars-backward " \t") | |
224 (bolp)) | |
225 (if icon-auto-newline | |
226 (progn (icon-indent-line) (newline) t) | |
227 nil))) | |
228 (progn | |
229 (insert last-command-char) | |
230 (icon-indent-line) | |
231 (if icon-auto-newline | |
232 (progn | |
233 (newline) | |
234 ;; (newline) may have done auto-fill | |
235 (setq insertpos (- (point) 2)) | |
236 (icon-indent-line))) | |
237 (save-excursion | |
238 (if insertpos (goto-char (1+ insertpos))) | |
239 (delete-char -1)))) | |
240 (if insertpos | |
241 (save-excursion | |
242 (goto-char insertpos) | |
243 (self-insert-command (prefix-numeric-value arg))) | |
244 (self-insert-command (prefix-numeric-value arg))))) | |
245 | |
246 (defun icon-indent-command (&optional whole-exp) | |
247 "Indent current line as Icon code, or in some cases insert a tab character. | |
210 | 248 If `icon-tab-always-indent' is non-nil (the default), always indent current |
249 line. Otherwise, indent the current line only if point is at the left margin | |
36 | 250 or in the line's indentation; otherwise insert a tab. |
251 | |
210 | 252 A numeric argument, regardless of its value, means indent rigidly all the |
253 lines of the expression starting after point so that this line becomes | |
254 properly indented. The relative indentation among the lines of the | |
255 expression are preserved." | |
54014
6296b1d1ae51
* net/telnet.el (telnet-interrupt-subjob): Move doc string to the correct place.
Eli Zaretskii <eliz@is.elta.co.il>
parents:
52401
diff
changeset
|
256 (interactive "P") |
36 | 257 (if whole-exp |
258 ;; If arg, always indent this line as Icon | |
259 ;; and shift remaining lines of expression the same amount. | |
260 (let ((shift-amt (icon-indent-line)) | |
261 beg end) | |
262 (save-excursion | |
263 (if icon-tab-always-indent | |
264 (beginning-of-line)) | |
265 (setq beg (point)) | |
266 (forward-sexp 1) | |
267 (setq end (point)) | |
268 (goto-char beg) | |
269 (forward-line 1) | |
270 (setq beg (point))) | |
271 (if (> end beg) | |
272 (indent-code-rigidly beg end shift-amt "#"))) | |
273 (if (and (not icon-tab-always-indent) | |
274 (save-excursion | |
275 (skip-chars-backward " \t") | |
276 (not (bolp)))) | |
277 (insert-tab) | |
278 (icon-indent-line)))) | |
279 | |
280 (defun icon-indent-line () | |
281 "Indent current line as Icon code. | |
282 Return the amount the indentation changed by." | |
283 (let ((indent (calculate-icon-indent nil)) | |
284 beg shift-amt | |
285 (case-fold-search nil) | |
286 (pos (- (point-max) (point)))) | |
287 (beginning-of-line) | |
288 (setq beg (point)) | |
289 (cond ((eq indent nil) | |
290 (setq indent (current-indentation))) | |
30947 | 291 ((looking-at "^#") |
36 | 292 (setq indent 0)) |
293 (t | |
294 (skip-chars-forward " \t") | |
295 (if (listp indent) (setq indent (car indent))) | |
296 (cond ((and (looking-at "else\\b") | |
297 (not (looking-at "else\\s_"))) | |
298 (setq indent (save-excursion | |
299 (icon-backward-to-start-of-if) | |
300 (current-indentation)))) | |
301 ((or (= (following-char) ?}) | |
302 (looking-at "end\\b")) | |
303 (setq indent (- indent icon-indent-level))) | |
304 ((= (following-char) ?{) | |
305 (setq indent (+ indent icon-brace-offset)))))) | |
306 (skip-chars-forward " \t") | |
307 (setq shift-amt (- indent (current-column))) | |
308 (if (zerop shift-amt) | |
309 (if (> (- (point-max) pos) (point)) | |
310 (goto-char (- (point-max) pos))) | |
311 (delete-region beg (point)) | |
312 (indent-to indent) | |
313 ;; If initial point was within line's indentation, | |
314 ;; position after the indentation. Else stay at same point in text. | |
315 (if (> (- (point-max) pos) (point)) | |
316 (goto-char (- (point-max) pos)))) | |
317 shift-amt)) | |
318 | |
319 (defun calculate-icon-indent (&optional parse-start) | |
320 "Return appropriate indentation for current line as Icon code. | |
321 In usual case returns an integer: the column to indent to. | |
322 Returns nil if line starts inside a string, t if in a comment." | |
323 (save-excursion | |
324 (beginning-of-line) | |
325 (let ((indent-point (point)) | |
326 (case-fold-search nil) | |
327 state | |
328 containing-sexp | |
329 toplevel) | |
330 (if parse-start | |
331 (goto-char parse-start) | |
332 (setq toplevel (beginning-of-icon-defun))) | |
333 (while (< (point) indent-point) | |
334 (setq parse-start (point)) | |
335 (setq state (parse-partial-sexp (point) indent-point 0)) | |
336 (setq containing-sexp (car (cdr state)))) | |
337 (cond ((or (nth 3 state) (nth 4 state)) | |
338 ;; return nil or t if should not change this line | |
339 (nth 4 state)) | |
340 ((and containing-sexp | |
341 (/= (char-after containing-sexp) ?{)) | |
342 ;; line is expression, not statement: | |
343 ;; indent to just after the surrounding open. | |
344 (goto-char (1+ containing-sexp)) | |
345 (current-column)) | |
346 (t | |
347 (if toplevel | |
348 ;; Outside any procedures. | |
349 (progn (icon-backward-to-noncomment (point-min)) | |
350 (if (icon-is-continuation-line) | |
351 icon-continued-statement-offset 0)) | |
352 ;; Statement level. | |
353 (if (null containing-sexp) | |
354 (progn (beginning-of-icon-defun) | |
355 (setq containing-sexp (point)))) | |
356 (goto-char indent-point) | |
357 ;; Is it a continuation or a new statement? | |
358 ;; Find previous non-comment character. | |
359 (icon-backward-to-noncomment containing-sexp) | |
360 ;; Now we get the answer. | |
361 (if (icon-is-continuation-line) | |
362 ;; This line is continuation of preceding line's statement; | |
363 ;; indent icon-continued-statement-offset more than the | |
364 ;; first line of the statement. | |
365 (progn | |
366 (icon-backward-to-start-of-continued-exp containing-sexp) | |
367 (+ icon-continued-statement-offset (current-column) | |
368 (if (save-excursion (goto-char indent-point) | |
369 (skip-chars-forward " \t") | |
370 (eq (following-char) ?{)) | |
371 icon-continued-brace-offset 0))) | |
372 ;; This line starts a new statement. | |
373 ;; Position following last unclosed open. | |
374 (goto-char containing-sexp) | |
375 ;; Is line first statement after an open-brace? | |
376 (or | |
377 ;; If no, find that first statement and indent like it. | |
378 (save-excursion | |
379 (if (looking-at "procedure\\s ") | |
380 (forward-sexp 3) | |
381 (forward-char 1)) | |
382 (while (progn (skip-chars-forward " \t\n") | |
383 (looking-at "#")) | |
384 ;; Skip over comments following openbrace. | |
385 (forward-line 1)) | |
386 ;; The first following code counts | |
387 ;; if it is before the line we want to indent. | |
388 (and (< (point) indent-point) | |
389 (current-column))) | |
390 ;; If no previous statement, | |
391 ;; indent it relative to line brace is on. | |
392 ;; For open brace in column zero, don't let statement | |
393 ;; start there too. If icon-indent-level is zero, | |
394 ;; use icon-brace-offset + icon-continued-statement-offset | |
395 ;; instead. | |
396 ;; For open-braces not the first thing in a line, | |
397 ;; add in icon-brace-imaginary-offset. | |
398 (+ (if (and (bolp) (zerop icon-indent-level)) | |
399 (+ icon-brace-offset | |
400 icon-continued-statement-offset) | |
401 icon-indent-level) | |
402 ;; Move back over whitespace before the openbrace. | |
403 ;; If openbrace is not first nonwhite thing on the line, | |
404 ;; add the icon-brace-imaginary-offset. | |
405 (progn (skip-chars-backward " \t") | |
406 (if (bolp) 0 icon-brace-imaginary-offset)) | |
407 ;; Get initial indentation of the line we are on. | |
408 (current-indentation)))))))))) | |
409 | |
410 ;; List of words to check for as the last thing on a line. | |
411 ;; If cdr is t, next line is a continuation of the same statement, | |
412 ;; if cdr is nil, next line starts a new (possibly indented) statement. | |
413 | |
414 (defconst icon-resword-alist | |
415 '(("by" . t) ("case" . t) ("create") ("do") ("dynamic" . t) ("else") | |
416 ("every" . t) ("if" . t) ("global" . t) ("initial" . t) | |
417 ("link" . t) ("local" . t) ("of") ("record" . t) ("repeat" . t) | |
418 ("static" . t) ("then") ("to" . t) ("until" . t) ("while" . t))) | |
419 | |
420 (defun icon-is-continuation-line () | |
421 (let* ((ch (preceding-char)) | |
422 (ch-syntax (char-syntax ch))) | |
423 (if (eq ch-syntax ?w) | |
424 (assoc (buffer-substring | |
425 (progn (forward-word -1) (point)) | |
426 (progn (forward-word 1) (point))) | |
427 icon-resword-alist) | |
30947 | 428 (not (memq ch '(0 ?\; ?\} ?\{ ?\) ?\] ?\" ?\' ?\# ?\, ?\. ?\n)))))) |
36 | 429 |
430 (defun icon-backward-to-noncomment (lim) | |
431 (let (opoint stop) | |
432 (while (not stop) | |
433 (skip-chars-backward " \t\n\f" lim) | |
434 (setq opoint (point)) | |
435 (beginning-of-line) | |
436 (if (and (nth 5 (parse-partial-sexp (point) opoint)) | |
437 (< lim (point))) | |
438 (search-backward "#") | |
439 (setq stop t))))) | |
440 | |
441 (defun icon-backward-to-start-of-continued-exp (lim) | |
442 (if (memq (preceding-char) '(?\) ?\])) | |
443 (forward-sexp -1)) | |
444 (beginning-of-line) | |
445 (skip-chars-forward " \t") | |
446 (cond | |
447 ((<= (point) lim) (goto-char (1+ lim))) | |
448 ((not (icon-is-continued-line)) 0) | |
449 ((and (eq (char-syntax (following-char)) ?w) | |
450 (cdr | |
451 (assoc (buffer-substring (point) | |
452 (save-excursion (forward-word 1) (point))) | |
453 icon-resword-alist))) 0) | |
454 (t (end-of-line 0) (icon-backward-to-start-of-continued-exp lim)))) | |
455 | |
456 (defun icon-is-continued-line () | |
457 (save-excursion | |
458 (end-of-line 0) | |
459 (icon-is-continuation-line))) | |
460 | |
461 (defun icon-backward-to-start-of-if (&optional limit) | |
210 | 462 "Move to the start of the last \"unbalanced\" if." |
36 | 463 (or limit (setq limit (save-excursion (beginning-of-icon-defun) (point)))) |
464 (let ((if-level 1) | |
465 (case-fold-search nil)) | |
466 (while (not (zerop if-level)) | |
467 (backward-sexp 1) | |
468 (cond ((looking-at "else\\b") | |
469 (setq if-level (1+ if-level))) | |
470 ((looking-at "if\\b") | |
471 (setq if-level (1- if-level))) | |
472 ((< (point) limit) | |
473 (setq if-level 0) | |
474 (goto-char limit)))))) | |
475 | |
476 (defun mark-icon-function () | |
477 "Put mark at end of Icon function, point at beginning." | |
478 (interactive) | |
479 (push-mark (point)) | |
480 (end-of-icon-defun) | |
481 (push-mark (point)) | |
482 (beginning-of-line 0) | |
483 (beginning-of-icon-defun)) | |
484 | |
485 (defun beginning-of-icon-defun () | |
486 "Go to the start of the enclosing procedure; return t if at top level." | |
487 (interactive) | |
488 (if (re-search-backward "^procedure\\s \\|^end[ \t\n]" (point-min) 'move) | |
489 (looking-at "e") | |
490 t)) | |
491 | |
492 (defun end-of-icon-defun () | |
493 (interactive) | |
494 (if (not (bobp)) (forward-char -1)) | |
495 (re-search-forward "\\(\\s \\|^\\)end\\(\\s \\|$\\)" (point-max) 'move) | |
496 (forward-word -1) | |
497 (forward-line 1)) | |
498 | |
499 (defun indent-icon-exp () | |
500 "Indent each line of the Icon grouping following point." | |
501 (interactive) | |
502 (let ((indent-stack (list nil)) | |
503 (contain-stack (list (point))) | |
504 (case-fold-search nil) | |
505 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
|
506 this-indent last-sexp last-depth |
36 | 507 at-else at-brace at-do |
508 (opoint (point)) | |
509 (next-depth 0)) | |
510 (save-excursion | |
511 (forward-sexp 1)) | |
512 (save-excursion | |
513 (setq outer-loop-done nil) | |
514 (while (and (not (eobp)) (not outer-loop-done)) | |
515 (setq last-depth next-depth) | |
516 ;; Compute how depth changes over this line | |
517 ;; plus enough other lines to get to one that | |
518 ;; does not end inside a comment or string. | |
519 ;; 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
|
520 (setq inner-loop-done nil) |
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
521 (while (and (not inner-loop-done) |
36 | 522 (not (and (eobp) (setq outer-loop-done t)))) |
523 (setq ostate state) | |
524 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point)) | |
525 nil nil state)) | |
526 (setq next-depth (car state)) | |
527 (if (and (car (cdr (cdr state))) | |
528 (>= (car (cdr (cdr state))) 0)) | |
529 (setq last-sexp (car (cdr (cdr state))))) | |
530 (if (or (nth 4 ostate)) | |
531 (icon-indent-line)) | |
532 (if (or (nth 3 state)) | |
533 (forward-line 1) | |
17974
b7df247f7487
(indent-icon-exp): Bind last-depth.
Richard M. Stallman <rms@gnu.org>
parents:
17969
diff
changeset
|
534 (setq inner-loop-done t))) |
36 | 535 (if (<= next-depth 0) |
536 (setq outer-loop-done t)) | |
537 (if outer-loop-done | |
538 nil | |
539 (if (/= last-depth next-depth) | |
540 (setq last-sexp nil)) | |
541 (while (> last-depth next-depth) | |
542 (setq indent-stack (cdr indent-stack) | |
543 contain-stack (cdr contain-stack) | |
544 last-depth (1- last-depth))) | |
545 (while (< last-depth next-depth) | |
546 (setq indent-stack (cons nil indent-stack) | |
547 contain-stack (cons nil contain-stack) | |
548 last-depth (1+ last-depth))) | |
549 (if (null (car contain-stack)) | |
550 (setcar contain-stack (or (car (cdr state)) | |
551 (save-excursion (forward-sexp -1) | |
552 (point))))) | |
553 (forward-line 1) | |
554 (skip-chars-forward " \t") | |
555 (if (eolp) | |
556 nil | |
557 (if (and (car indent-stack) | |
558 (>= (car indent-stack) 0)) | |
559 ;; Line is on an existing nesting level. | |
560 ;; Lines inside parens are handled specially. | |
561 (if (/= (char-after (car contain-stack)) ?{) | |
562 (setq this-indent (car indent-stack)) | |
563 ;; Line is at statement level. | |
564 ;; Is it a new statement? Is it an else? | |
565 ;; Find last non-comment character before this line | |
566 (save-excursion | |
567 (setq at-else (looking-at "else\\W")) | |
568 (setq at-brace (= (following-char) ?{)) | |
569 (icon-backward-to-noncomment opoint) | |
570 (if (icon-is-continuation-line) | |
571 ;; Preceding line did not end in comma or semi; | |
572 ;; indent this line icon-continued-statement-offset | |
573 ;; more than previous. | |
574 (progn | |
575 (icon-backward-to-start-of-continued-exp (car contain-stack)) | |
576 (setq this-indent | |
577 (+ icon-continued-statement-offset (current-column) | |
578 (if at-brace icon-continued-brace-offset 0)))) | |
579 ;; Preceding line ended in comma or semi; | |
580 ;; use the standard indent for this level. | |
581 (if at-else | |
582 (progn (icon-backward-to-start-of-if opoint) | |
583 (setq this-indent (current-indentation))) | |
584 (setq this-indent (car indent-stack)))))) | |
585 ;; Just started a new nesting level. | |
586 ;; Compute the standard indent for this level. | |
587 (let ((val (calculate-icon-indent | |
588 (if (car indent-stack) | |
589 (- (car indent-stack)))))) | |
590 (setcar indent-stack | |
591 (setq this-indent val)))) | |
592 ;; Adjust line indentation according to its contents | |
593 (if (or (= (following-char) ?}) | |
594 (looking-at "end\\b")) | |
595 (setq this-indent (- this-indent icon-indent-level))) | |
596 (if (= (following-char) ?{) | |
597 (setq this-indent (+ this-indent icon-brace-offset))) | |
598 ;; Put chosen indentation into effect. | |
599 (or (= (current-column) this-indent) | |
600 (progn | |
601 (delete-region (point) (progn (beginning-of-line) (point))) | |
602 (indent-to this-indent))) | |
603 ;; Indent any comment following the text. | |
604 (or (looking-at comment-start-skip) | |
605 (if (re-search-forward comment-start-skip (save-excursion (end-of-line) (point)) t) | |
606 (progn (indent-for-comment) (beginning-of-line)))))))))) | |
607 | |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
608 (defconst icon-font-lock-keywords-1 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
609 (eval-when-compile |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
610 (list |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
611 ;; 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
|
612 '("^[ \t]*\\(procedure\\)\\>[ \t]*\\(\\sw+\\)?" |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
613 (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
|
614 "Subdued level highlighting for Icon mode.") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
615 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
616 (defconst icon-font-lock-keywords-2 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
617 (append |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
618 icon-font-lock-keywords-1 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
619 (eval-when-compile |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
620 (list |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
621 ;; Fontify all type specifiers. |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
622 (cons |
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
623 (regexp-opt '("null" "string" "co-expression" "table" "integer" |
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
624 "cset" "set" "real" "file" "list") 'words) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
625 'font-lock-type-face) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
626 ;; 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
|
627 ;; |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
628 (cons |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
629 (regexp-opt |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
630 '("break" "do" "next" "repeat" "to" "by" "else" "if" "not" "return" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
631 "until" "case" "of" "while" "create" "every" "suspend" "default" |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
632 "fail" "record" "then") 'words) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
633 'font-lock-keyword-face) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
634 ;; "end" "initial" |
33200
5323492591dd
(icon-mode-map): Don't rebind \t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32299
diff
changeset
|
635 (cons (regexp-opt '("end" "initial") 'words) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
636 'font-lock-builtin-face) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
637 ;; Fontify all system variables. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
638 (cons |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
639 (regexp-opt |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
640 '("&allocated" "&ascii" "&clock" "&col" "&collections" "&column" |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
641 "&control" "&cset" "¤t" "&date" "&dateline" "&digits" "&dump" |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
642 "&e" "&error" "&errornumber" "&errortext" "&errorvalue" "&errout" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
643 "&eventcode" "&eventsource" "&eventvalue" "&fail" "&features" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
644 "&file" "&host" "&input" "&interval" "&lcase" "&ldrag" "&letters" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
645 "&level" "&line" "&lpress" "&lrelease" "&main" "&mdrag" "&meta" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
646 "&mpress" "&mrelease" "&null" "&output" "&phi" "&pi" "&pos" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
647 "&progname" "&random" "&rdrag" "®ions" "&resize" "&row" |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
648 "&rpress" "&rrelease" "&shift" "&source" "&storage" "&subject" |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
649 "&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
|
650 '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
|
651 (cons ;; global local static declarations and link files |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
652 (concat |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
653 "^[ \t]*" |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
654 (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
|
655 "\\(\\sw+\\>\\)*") |
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
656 '((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
|
657 (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
|
658 (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
|
659 (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
|
660 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
|
661 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
|
662 |
18281
ffc2fda197bc
(icon-indent-line): A comment ends at the end of the
Richard M. Stallman <rms@gnu.org>
parents:
18272
diff
changeset
|
663 (cons ;; $define $elif $ifdef $ifndef $undef |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
664 (concat "^" |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
665 (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
|
666 "\\>[ \t]*\\([^ \t\n]+\\)?") |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
667 '((1 font-lock-builtin-face) |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
668 (4 font-lock-variable-name-face nil t))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
669 (cons ;; $dump $endif $else $include |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
33200
diff
changeset
|
670 (concat |
18167
6da1b5250673
(icon-font-lock-keywords-2): Use regexp-opt for the regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17974
diff
changeset
|
671 "^" (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
|
672 '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
|
673 (cons ;; $warning $error |
18272
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
674 (concat "^" (regexp-opt '("$warning" "$error") t) |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
675 "\\>[ \t]*\\(.+\\)?") |
aea95178357e
(icon-imenu-generic-expression): Improved regexp.
Richard M. Stallman <rms@gnu.org>
parents:
18167
diff
changeset
|
676 '((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
|
677 "Gaudy level highlighting for Icon mode.") |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
678 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
679 (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
|
680 "Default expressions to highlight in `icon-mode'.") |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
681 |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
682 ;;;used by hs-minor-mode |
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
683 (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
|
684 (if (< arg 0) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
685 (beginning-of-icon-defun) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
686 (end-of-icon-defun) |
fa550516120f
(icon-mode): Adapt to new hideshow and improve regexps.
Richard M. Stallman <rms@gnu.org>
parents:
17633
diff
changeset
|
687 (forward-char -1))) |
17266
9ef8bf76c3c2
(icon-mode-map): Added menus.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
688 |
18381 | 689 (provide 'icon) |
690 | |
52401 | 691 ;;; arch-tag: 8abf8c99-e7df-44af-a58f-ef5ed2ee52cb |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
210
diff
changeset
|
692 ;;; icon.el ends here |