annotate lisp/progmodes/icon.el @ 112408:04c350138c72

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