annotate lisp/progmodes/icon.el @ 17286:4ee0f02eff87

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