Mercurial > emacs
annotate lisp/progmodes/dcl-mode.el @ 68029:61a03413f18b
(Misc Network, Make Network): Minor cleanups.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 05 Jan 2006 03:33:17 +0000 |
parents | a11fdee52c05 |
children | dc49655f57ae 7beb78bc1f8e |
rev | line source |
---|---|
17246 | 1 ;;; dcl-mode.el --- major mode for editing DCL command files |
2 | |
64699
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
3 ;; Copyright (c) 1997, 2001, 2002, 2003, 2004, 2005 |
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
17252
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
5 |
17246 | 6 ;; Author: Odd Gripenstam <gripenstamol@decus.se> |
7 ;; Maintainer: Odd Gripenstam <gripenstamol@decus.se> | |
8 ;; Keywords: DCL editing major-mode languages | |
9 | |
17252
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
11 |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
15 ;; any later version. |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
16 |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
20 ;; GNU General Public License for more details. |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
21 |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
17252
fb59cd650fa1
Add copyright notice and distribution terms.
Richard M. Stallman <rms@gnu.org>
parents:
17246
diff
changeset
|
26 |
17246 | 27 ;;; Commentary: |
28 | |
29 ;; DCL mode is a package for editing DCL command files. It helps you | |
30 ;; indent lines, add leading `$' and trailing `-', move around in the | |
31 ;; code and insert lexical functions. | |
32 ;; | |
33 ;; Type `C-h m' when you are editing a .COM file to get more | |
34 ;; information about this mode. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
35 ;; |
17246 | 36 ;; To use templates you will need a version of tempo.el that is at |
37 ;; least later than the buggy 1.1.1, which was included with my versions of | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
38 ;; Emacs. I used version 1.2.4. |
17246 | 39 ;; The latest tempo.el distribution can be fetched from |
40 ;; ftp.lysator.liu.se in the directory /pub/emacs. | |
41 ;; I recommend setting (setq tempo-interactive t). This will make | |
42 ;; tempo prompt you for values to put in the blank spots in the templates. | |
43 ;; | |
44 ;; There is limited support for imenu. The limitation is that you need | |
45 ;; a version of imenu.el that uses imenu-generic-expression. I found | |
46 ;; the version I use in Emacs 19.30. (It was *so* much easier to hook | |
47 ;; into that version than the one in 19.27...) | |
48 ;; | |
49 ;; Any feedback will be welcomed. If you write functions for | |
50 ;; dcl-calc-command-indent-function or dcl-calc-cont-indent-function, | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
51 ;; please send them to the maintainer. |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
52 ;; |
17246 | 53 ;; |
54 ;; Ideas for improvement: | |
50044
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
55 ;; * Better font-lock support. |
17246 | 56 ;; * Change meaning of `left margin' when dcl-tab-always-indent is nil. |
57 ;; Consider the following line (`_' is the cursor): | |
58 ;; $ label: _ command | |
59 ;; Pressing tab with the cursor at the underline now inserts a tab. | |
60 ;; This should be part of the left margin and pressing tab should indent | |
61 ;; the line. | |
62 ;; * Make M-LFD work properly with comments in all cases. Now it only | |
63 ;; works on comment-only lines. But what is "properly"? New rules for | |
64 ;; indenting comments? | |
65 ;; * Even smarter indentation of continuation lines. | |
66 ;; * A delete-indentation function (M-^) that joins continued lines, | |
67 ;; including lines with end line comments? | |
68 ;; * Handle DECK/EOD. | |
69 ;; * `indent list' commands: C-M-q, C-u TAB. What is a list in DCL? One | |
70 ;; complete command line? A block? A subroutine? | |
71 | |
72 ;;; Code: | |
73 | |
74 ;;; *** Customization ***************************************************** | |
75 | |
50044
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
76 |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
77 ;; First, font lock. This is a minimal approach, please improve! |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
78 |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
79 (defvar dcl-font-lock-keywords |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
80 '(("\\<\\(if\\|then\\|else\\|endif\\)\\>" |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
81 1 font-lock-keyword-face) |
60767
66c8a6842570
(dcl-font-lock-keywords): Add underscore to "f$ lexicals" regexp.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60578
diff
changeset
|
82 ("\\<f[$][a-z_]+\\>" |
50044
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
83 0 font-lock-builtin-face) |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
84 ("[.]\\(eq\\|not\\|or\\|and\\|lt\\|gt\\|le\\|ge\\|eqs\\|nes\\)[.]" |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
85 0 font-lock-builtin-face)) |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
86 "Font lock keyword specification for DCL mode. |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
87 Presently this includes some syntax, .OP.erators, and \"f$\" lexicals.") |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
88 |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
89 (defvar dcl-font-lock-defaults |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
90 '(dcl-font-lock-keywords nil) |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
91 "Font lock specification for DCL mode.") |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
92 |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
93 |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
94 ;; Now the rest. |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
95 |
22511
f5b3f55fc25b
(dcl): Define as customize group, not
Karl Heuer <kwzh@gnu.org>
parents:
20781
diff
changeset
|
96 (defgroup dcl nil |
20781 | 97 "Major mode for editing DCL command files." |
66963
a11fdee52c05
Add :link (custom-group-link font-lock-faces) to defgroup.
Juri Linkov <juri@jurta.org>
parents:
64699
diff
changeset
|
98 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) |
20781 | 99 :group 'languages) |
17246 | 100 |
20781 | 101 (defcustom dcl-basic-offset 4 |
17246 | 102 "*Number of columns to indent a block in DCL. |
103 A block is the commands between THEN-ELSE-ENDIF and between the commands | |
104 dcl-block-begin-regexp and dcl-block-end-regexp. | |
105 | |
106 The meaning of this variable may be changed if | |
20781 | 107 dcl-calc-command-indent-function is set to a function." |
108 :type 'integer | |
109 :group 'dcl) | |
17246 | 110 |
111 | |
20781 | 112 (defcustom dcl-continuation-offset 6 |
17246 | 113 "*Number of columns to indent a continuation line in DCL. |
114 A continuation line is a line that follows a line ending with `-'. | |
115 | |
116 The meaning of this variable may be changed if | |
20781 | 117 dcl-calc-cont-indent-function is set to a function." |
118 :type 'integer | |
119 :group 'dcl) | |
17246 | 120 |
121 | |
20781 | 122 (defcustom dcl-margin-offset 8 |
17246 | 123 "*Indentation for the first command line in DCL. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
124 The first command line in a file or after a SUBROUTINE statement is indented |
17246 | 125 this much. Other command lines are indented the same number of columns as |
126 the preceding command line. | |
20781 | 127 A command line is a line that starts with `$'." |
128 :type 'integer | |
129 :group 'dcl) | |
17246 | 130 |
131 | |
20781 | 132 (defcustom dcl-margin-label-offset 2 |
17246 | 133 "*Number of columns to indent a margin label in DCL. |
134 A margin label is a label that doesn't begin or end a block, i.e. it | |
20781 | 135 doesn't match dcl-block-begin-regexp or dcl-block-end-regexp." |
136 :type 'integer | |
137 :group 'dcl) | |
17246 | 138 |
139 | |
20781 | 140 (defcustom dcl-comment-line-regexp "^\\$!" |
17246 | 141 "*Regexp describing the start of a comment line in DCL. |
20781 | 142 Comment lines are not indented." |
143 :type 'regexp | |
144 :group 'dcl) | |
17246 | 145 |
146 | |
20781 | 147 (defcustom dcl-block-begin-regexp "loop[0-9]*:" |
17246 | 148 "*Regexp describing a command that begins an indented block in DCL. |
20781 | 149 Set to nil to only indent at THEN-ELSE-ENDIF." |
150 :type 'regexp | |
151 :group 'dcl) | |
17246 | 152 |
153 | |
20781 | 154 (defcustom dcl-block-end-regexp "endloop[0-9]*:" |
17246 | 155 "*Regexp describing a command that ends an indented block in DCL. |
20781 | 156 Set to nil to only indent at THEN-ELSE-ENDIF." |
157 :type 'regexp | |
158 :group 'dcl) | |
17246 | 159 |
160 | |
20781 | 161 (defcustom dcl-calc-command-indent-function nil |
17246 | 162 "*Function to calculate indentation for a command line in DCL. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
163 If this variable is non-nil it is called as a function: |
17246 | 164 |
165 \(func INDENT-TYPE CUR-INDENT EXTRA-INDENT LAST-POINT THIS-POINT) | |
166 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
167 The function must return the number of columns to indent the current line or |
17246 | 168 nil to get the default indentation. |
169 | |
170 INDENT-TYPE is a symbol indicating what kind of indentation should be done. | |
171 It can have the following values: | |
172 indent the lines indentation should be increased, e.g. after THEN. | |
173 outdent the lines indentation should be decreased, e.g a line with ENDIF. | |
174 first-line indentation for the first line in a buffer or SUBROUTINE. | |
175 CUR-INDENT is the indentation of the preceding command line. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
176 EXTRA-INDENT is the default change in indentation for this line |
17246 | 177 \(a negative number for 'outdent). |
178 LAST-POINT is the buffer position of the first significant word on the | |
179 previous line or nil if the current line is the first line. | |
180 THIS-POINT is the buffer position of the first significant word on the | |
181 current line. | |
182 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
183 If this variable is nil, the indentation is calculated as |
17246 | 184 CUR-INDENT + EXTRA-INDENT. |
185 | |
186 This package includes two functions suitable for this: | |
187 dcl-calc-command-indent-multiple | |
20781 | 188 dcl-calc-command-indent-hang" |
35960
a21a0d45ea19
(dcl-calc-command-indent-function): Fix :type.
Dave Love <fx@gnu.org>
parents:
22511
diff
changeset
|
189 :type '(choice (const nil) function) |
20781 | 190 :group 'dcl) |
17246 | 191 |
192 | |
20781 | 193 (defcustom dcl-calc-cont-indent-function 'dcl-calc-cont-indent-relative |
17246 | 194 "*Function to calculate indentation for a continuation line. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
195 If this variable is non-nil it is called as a function: |
17246 | 196 |
197 \(func CUR-INDENT EXTRA-INDENT) | |
198 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
199 The function must return the number of columns to indent the current line or |
17246 | 200 nil to get the default indentation. |
201 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
202 If this variable is nil, the indentation is calculated as |
17246 | 203 CUR-INDENT + EXTRA-INDENT. |
204 | |
205 This package includes one function suitable for this: | |
20781 | 206 dcl-calc-cont-indent-relative" |
207 :type 'function | |
208 :group 'dcl) | |
17246 | 209 |
210 | |
20781 | 211 (defcustom dcl-tab-always-indent t |
17246 | 212 "*Controls the operation of the TAB key in DCL mode. |
213 If t, pressing TAB always indents the current line. | |
214 If nil, pressing TAB indents the current line if point is at the left margin. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
215 Data lines (i.e. lines not part of a command line or continuation line) are |
20781 | 216 never indented." |
217 :type 'boolean | |
218 :group 'dcl) | |
17246 | 219 |
220 | |
20781 | 221 (defcustom dcl-electric-characters t |
222 "*Non-nil means reindent immediately when a label, ELSE or ENDIF is inserted." | |
223 :type 'boolean | |
224 :group 'dcl) | |
17246 | 225 |
226 | |
20781 | 227 (defcustom dcl-tempo-comma ", " |
228 "*Text to insert when a comma is needed in a template, in DCL mode." | |
229 :type 'string | |
230 :group 'dcl) | |
17246 | 231 |
20781 | 232 (defcustom dcl-tempo-left-paren "(" |
233 "*Text to insert when a left parenthesis is needed in a template in DCL." | |
234 :type 'string | |
235 :group 'dcl) | |
17246 | 236 |
237 | |
20781 | 238 (defcustom dcl-tempo-right-paren ")" |
239 "*Text to insert when a right parenthesis is needed in a template in DCL." | |
240 :type 'string | |
241 :group 'dcl) | |
17246 | 242 |
243 ; I couldn't decide what looked best, so I'll let you decide... | |
244 ; Remember, you can also customize this with imenu-submenu-name-format. | |
20781 | 245 (defcustom dcl-imenu-label-labels "Labels" |
246 "*Imenu menu title for sub-listing with label names." | |
247 :type 'string | |
248 :group 'dcl) | |
249 (defcustom dcl-imenu-label-goto "GOTO" | |
250 "*Imenu menu title for sub-listing with GOTO statements." | |
251 :type 'string | |
252 :group 'dcl) | |
253 (defcustom dcl-imenu-label-gosub "GOSUB" | |
254 "*Imenu menu title for sub-listing with GOSUB statements." | |
255 :type 'string | |
256 :group 'dcl) | |
257 (defcustom dcl-imenu-label-call "CALL" | |
258 "*Imenu menu title for sub-listing with CALL statements." | |
259 :type 'string | |
260 :group 'dcl) | |
17246 | 261 |
20781 | 262 (defcustom dcl-imenu-generic-expression |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
35960
diff
changeset
|
263 `((nil "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):[ \t]+SUBROUTINE\\b" 1) |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
35960
diff
changeset
|
264 (,dcl-imenu-label-labels |
17246 | 265 "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):\\([ \t]\\|$\\)" 1) |
41608
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
35960
diff
changeset
|
266 (,dcl-imenu-label-goto "\\s-GOTO[ \t]+\\([A-Za-z0-9_\$]+\\)" 1) |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
35960
diff
changeset
|
267 (,dcl-imenu-label-gosub "\\s-GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)" 1) |
45db352a0971
Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents:
35960
diff
changeset
|
268 (,dcl-imenu-label-call "\\s-CALL[ \t]+\\([A-Za-z0-9_\$]+\\)" 1)) |
20781 | 269 "*Default imenu generic expression for DCL. |
17246 | 270 |
271 The default includes SUBROUTINE labels in the main listing and | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
272 sub-listings for other labels, CALL, GOTO and GOSUB statements. |
20781 | 273 See `imenu-generic-expression' for details." |
274 :type '(repeat (sexp :tag "Imenu Expression")) | |
275 :group 'dcl) | |
17246 | 276 |
277 | |
20781 | 278 (defcustom dcl-mode-hook nil |
279 "*Hook called by `dcl-mode'." | |
280 :type 'hook | |
281 :group 'dcl) | |
17246 | 282 |
283 | |
284 ;;; *** Global variables **************************************************** | |
285 | |
286 | |
287 (defvar dcl-mode-syntax-table nil | |
288 "Syntax table used in DCL-buffers.") | |
60578
634b2aa97a80
(dcl-mode-syntax-table): Add entry for backslash.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
289 (unless dcl-mode-syntax-table |
17246 | 290 (setq dcl-mode-syntax-table (make-syntax-table)) |
291 (modify-syntax-entry ?! "<" dcl-mode-syntax-table) ; comment start | |
292 (modify-syntax-entry ?\n ">" dcl-mode-syntax-table) ; comment end | |
293 (modify-syntax-entry ?< "(>" dcl-mode-syntax-table) ; < and ... | |
294 (modify-syntax-entry ?> ")<" dcl-mode-syntax-table) ; > is a matching pair | |
60578
634b2aa97a80
(dcl-mode-syntax-table): Add entry for backslash.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
295 (modify-syntax-entry ?\\ "_" dcl-mode-syntax-table) ; not an escape |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
296 ) |
17246 | 297 |
298 | |
299 (defvar dcl-mode-map () | |
300 "Keymap used in DCL-mode buffers.") | |
301 (if dcl-mode-map | |
302 () | |
303 (setq dcl-mode-map (make-sparse-keymap)) | |
304 (define-key dcl-mode-map "\e\n" 'dcl-split-line) | |
305 (define-key dcl-mode-map "\e\t" 'tempo-complete-tag) | |
306 (define-key dcl-mode-map "\e^" 'dcl-delete-indentation) | |
307 (define-key dcl-mode-map "\em" 'dcl-back-to-indentation) | |
308 (define-key dcl-mode-map "\ee" 'dcl-forward-command) | |
309 (define-key dcl-mode-map "\ea" 'dcl-backward-command) | |
310 (define-key dcl-mode-map "\e\C-q" 'dcl-indent-command) | |
311 (define-key dcl-mode-map "\t" 'dcl-tab) | |
312 (define-key dcl-mode-map ":" 'dcl-electric-character) | |
313 (define-key dcl-mode-map "F" 'dcl-electric-character) | |
314 (define-key dcl-mode-map "f" 'dcl-electric-character) | |
315 (define-key dcl-mode-map "E" 'dcl-electric-character) | |
316 (define-key dcl-mode-map "e" 'dcl-electric-character) | |
317 (define-key dcl-mode-map "\C-c\C-o" 'dcl-set-option) | |
318 (define-key dcl-mode-map "\C-c\C-f" 'tempo-forward-mark) | |
319 (define-key dcl-mode-map "\C-c\C-b" 'tempo-backward-mark) | |
320 | |
321 (define-key dcl-mode-map [menu-bar] (make-sparse-keymap)) | |
322 (define-key dcl-mode-map [menu-bar dcl] | |
323 (cons "DCL" (make-sparse-keymap "DCL"))) | |
324 | |
325 ;; Define these in bottom-up order | |
326 (define-key dcl-mode-map [menu-bar dcl tempo-backward-mark] | |
327 '("Previous template mark" . tempo-backward-mark)) | |
328 (define-key dcl-mode-map [menu-bar dcl tempo-forward-mark] | |
329 '("Next template mark" . tempo-forward-mark)) | |
330 (define-key dcl-mode-map [menu-bar dcl tempo-complete-tag] | |
331 '("Complete template tag" . tempo-complete-tag)) | |
332 (define-key dcl-mode-map [menu-bar dcl dcl-separator-tempo] | |
333 '("--")) | |
334 (define-key dcl-mode-map [menu-bar dcl dcl-save-all-options] | |
335 '("Save all options" . dcl-save-all-options)) | |
336 (define-key dcl-mode-map [menu-bar dcl dcl-save-nondefault-options] | |
337 '("Save changed options" . dcl-save-nondefault-options)) | |
338 (define-key dcl-mode-map [menu-bar dcl dcl-set-option] | |
339 '("Set option" . dcl-set-option)) | |
340 (define-key dcl-mode-map [menu-bar dcl dcl-separator-option] | |
341 '("--")) | |
342 (define-key dcl-mode-map [menu-bar dcl dcl-delete-indentation] | |
343 '("Delete indentation" . dcl-delete-indentation)) | |
344 (define-key dcl-mode-map [menu-bar dcl dcl-split-line] | |
345 '("Split line" . dcl-split-line)) | |
346 (define-key dcl-mode-map [menu-bar dcl dcl-indent-command] | |
347 '("Indent command" . dcl-indent-command)) | |
348 (define-key dcl-mode-map [menu-bar dcl dcl-tab] | |
349 '("Indent line/insert tab" . dcl-tab)) | |
350 (define-key dcl-mode-map [menu-bar dcl dcl-back-to-indentation] | |
351 '("Back to indentation" . dcl-back-to-indentation)) | |
352 (define-key dcl-mode-map [menu-bar dcl dcl-forward-command] | |
353 '("End of statement" . dcl-forward-command)) | |
354 (define-key dcl-mode-map [menu-bar dcl dcl-backward-command] | |
355 '("Beginning of statement" . dcl-backward-command)) | |
356 ;; imenu is only supported for versions with imenu-generic-expression | |
357 (if (boundp 'imenu-generic-expression) | |
358 (progn | |
359 (define-key dcl-mode-map [menu-bar dcl dcl-separator-movement] | |
360 '("--")) | |
361 (define-key dcl-mode-map [menu-bar dcl imenu] | |
362 '("Buffer index menu" . imenu)))) | |
363 ) | |
364 | |
365 | |
20781 | 366 (defcustom dcl-ws-r |
17246 | 367 "\\([ \t]*-[ \t]*\\(!.*\\)*\n\\)*[ \t]*" |
368 "Regular expression describing white space in a DCL command line. | |
369 White space is any number of continued lines with only space,tab,endcomment | |
20781 | 370 followed by space or tab." |
371 :type 'regexp | |
372 :group 'dcl) | |
17246 | 373 |
374 | |
20781 | 375 (defcustom dcl-label-r |
17246 | 376 "[a-zA-Z0-9_\$]*:\\([ \t!]\\|$\\)" |
377 "Regular expression describing a label. | |
20781 | 378 A label is a name followed by a colon followed by white-space or end-of-line." |
379 :type 'regexp | |
380 :group 'dcl) | |
17246 | 381 |
382 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
383 (defcustom dcl-cmd-r |
17246 | 384 "^\\$\\(.*-[ \t]*\\(!.*\\)*\n\\)*[^!\"\n]*\\(\".*\\(\"\".*\\)*\"\\)*[^!\"\n]*" |
385 "Regular expression describing a DCL command line up to a trailing comment. | |
386 A line starting with $, optionally followed by continuation lines, | |
387 followed by the end of the command line. | |
388 A continuation line is any characters followed by `-', | |
20781 | 389 optionally followed by a comment, followed by a newline." |
390 :type 'regexp | |
391 :group 'dcl) | |
17246 | 392 |
393 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
394 (defcustom dcl-command-regexp |
17246 | 395 "^\\$\\(.*-[ \t]*\\(!.*\\)*\n\\)*.*\\(\".*\\(\"\".*\\)*\"\\)*" |
396 "Regular expression describing a DCL command line. | |
397 A line starting with $, optionally followed by continuation lines, | |
398 followed by the end of the command line. | |
399 A continuation line is any characters followed by `-', | |
20781 | 400 optionally followed by a comment, followed by a newline." |
401 :type 'regexp | |
402 :group 'dcl) | |
17246 | 403 |
404 | |
20781 | 405 (defcustom dcl-electric-reindent-regexps |
17246 | 406 (list "endif" "else" dcl-label-r) |
407 "*Regexps that can trigger an electric reindent. | |
408 A list of regexps that will trigger a reindent if the last letter | |
409 is defined as dcl-electric-character. | |
410 | |
411 E.g.: if this list contains `endif', the key `f' is defined as | |
412 dcl-electric-character and the you have just typed the `f' in | |
20781 | 413 `endif', the line will be reindented." |
414 :type '(repeat regexp) | |
415 :group 'dcl) | |
17246 | 416 |
417 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
418 (defvar dcl-option-alist |
17246 | 419 '((dcl-basic-offset dcl-option-value-basic) |
420 (dcl-continuation-offset curval) | |
421 (dcl-margin-offset dcl-option-value-margin-offset) | |
422 (dcl-margin-label-offset dcl-option-value-offset) | |
423 (dcl-comment-line-regexp dcl-option-value-comment-line) | |
424 (dcl-block-begin-regexp curval) | |
425 (dcl-block-end-regexp curval) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
426 (dcl-tab-always-indent toggle) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
427 (dcl-electric-characters toggle) |
17246 | 428 (dcl-electric-reindent-regexps curval) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
429 (dcl-tempo-comma curval) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
430 (dcl-tempo-left-paren curval) |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
431 (dcl-tempo-right-paren curval) |
17246 | 432 (dcl-calc-command-indent-function curval) |
433 (dcl-calc-cont-indent-function curval) | |
434 (comment-start curval) | |
435 (comment-start-skip curval) | |
436 ) | |
437 "Options and default values for dcl-set-option. | |
438 | |
439 An alist with option variables and functions or keywords to get a | |
440 default value for the option. | |
441 | |
442 The keywords are: | |
443 curval the current value | |
444 toggle the opposite of the current value (for t/nil)") | |
445 | |
446 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
447 (defvar dcl-option-history |
17246 | 448 (mapcar (lambda (option-assoc) |
449 (format "%s" (car option-assoc))) | |
450 dcl-option-alist) | |
451 "The history list for dcl-set-option. | |
452 Preloaded with all known option names from dcl-option-alist") | |
453 | |
454 | |
455 ;; Must be defined after dcl-cmd-r | |
456 ;; This version is more correct but much slower than the one | |
457 ;; above. This version won't find GOTOs in comments or text strings. | |
458 ;(defvar dcl-imenu-generic-expression | |
459 ; (` | |
460 ; ((nil "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):[ \t]+SUBROUTINE\\b" 1) | |
461 ; ("Labels" "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):\\([ \t]\\|$\\)" 1) | |
462 ; ("GOTO" (, (concat dcl-cmd-r "GOTO[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5) | |
463 ; ("GOSUB" (, (concat dcl-cmd-r | |
464 ; "GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5) | |
465 ; ("CALL" (, (concat dcl-cmd-r "CALL[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5))) | |
466 ; "*Default imenu generic expression for DCL. | |
467 | |
468 ;The default includes SUBROUTINE labels in the main listing and | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
469 ;sub-listings for other labels, CALL, GOTO and GOSUB statements. |
17246 | 470 ;See `imenu-generic-expression' in a recent (e.g. Emacs 19.30) imenu.el |
471 ;for details.") | |
472 | |
473 | |
474 ;;; *** Mode initialization ************************************************* | |
475 | |
476 | |
477 ;;;###autoload | |
478 (defun dcl-mode () | |
479 "Major mode for editing DCL-files. | |
480 | |
481 This mode indents command lines in blocks. (A block is commands between | |
482 THEN-ELSE-ENDIF and between lines matching dcl-block-begin-regexp and | |
483 dcl-block-end-regexp.) | |
484 | |
485 Labels are indented to a fixed position unless they begin or end a block. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
486 Whole-line comments (matching dcl-comment-line-regexp) are not indented. |
17246 | 487 Data lines are not indented. |
488 | |
489 Key bindings: | |
490 | |
491 \\{dcl-mode-map} | |
492 Commands not usually bound to keys: | |
493 | |
494 \\[dcl-save-nondefault-options]\t\tSave changed options | |
495 \\[dcl-save-all-options]\t\tSave all options | |
496 \\[dcl-save-option]\t\t\tSave any option | |
497 \\[dcl-save-mode]\t\t\tSave buffer mode | |
498 | |
499 Variables controlling indentation style and extra features: | |
500 | |
501 dcl-basic-offset | |
502 Extra indentation within blocks. | |
503 | |
504 dcl-continuation-offset | |
505 Extra indentation for continued lines. | |
506 | |
507 dcl-margin-offset | |
508 Indentation for the first command line in a file or SUBROUTINE. | |
509 | |
510 dcl-margin-label-offset | |
511 Indentation for a label. | |
512 | |
513 dcl-comment-line-regexp | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
514 Lines matching this regexp will not be indented. |
17246 | 515 |
516 dcl-block-begin-regexp | |
517 dcl-block-end-regexp | |
518 Regexps that match command lines that begin and end, respectively, | |
519 a block of commmand lines that will be given extra indentation. | |
520 Command lines between THEN-ELSE-ENDIF are always indented; these variables | |
521 make it possible to define other places to indent. | |
522 Set to nil to disable this feature. | |
523 | |
524 dcl-calc-command-indent-function | |
525 Can be set to a function that customizes indentation for command lines. | |
526 Two such functions are included in the package: | |
527 dcl-calc-command-indent-multiple | |
528 dcl-calc-command-indent-hang | |
529 | |
530 dcl-calc-cont-indent-function | |
531 Can be set to a function that customizes indentation for continued lines. | |
532 One such function is included in the package: | |
533 dcl-calc-cont-indent-relative (set by default) | |
534 | |
535 dcl-tab-always-indent | |
536 If t, pressing TAB always indents the current line. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
537 If nil, pressing TAB indents the current line if point is at the left |
17246 | 538 margin. |
539 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
540 dcl-electric-characters |
17246 | 541 Non-nil causes lines to be indented at once when a label, ELSE or ENDIF is |
542 typed. | |
543 | |
544 dcl-electric-reindent-regexps | |
545 Use this variable and function dcl-electric-character to customize | |
546 which words trigger electric indentation. | |
547 | |
548 dcl-tempo-comma | |
549 dcl-tempo-left-paren | |
550 dcl-tempo-right-paren | |
551 These variables control the look of expanded templates. | |
552 | |
553 dcl-imenu-generic-expression | |
554 Default value for imenu-generic-expression. The default includes | |
555 SUBROUTINE labels in the main listing and sub-listings for | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
556 other labels, CALL, GOTO and GOSUB statements. |
17246 | 557 |
558 dcl-imenu-label-labels | |
559 dcl-imenu-label-goto | |
560 dcl-imenu-label-gosub | |
561 dcl-imenu-label-call | |
562 Change the text that is used as sub-listing labels in imenu. | |
563 | |
564 Loading this package calls the value of the variable | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
565 `dcl-mode-load-hook' with no args, if that value is non-nil. |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
566 Turning on DCL mode calls the value of the variable `dcl-mode-hook' |
17246 | 567 with no args, if that value is non-nil. |
568 | |
569 | |
570 The following example uses the default values for all variables: | |
571 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
572 $! This is a comment line that is not indented (it matches |
17246 | 573 $! dcl-comment-line-regexp) |
574 $! Next follows the first command line. It is indented dcl-margin-offset. | |
575 $ i = 1 | |
576 $ ! Other comments are indented like command lines. | |
577 $ ! A margin label indented dcl-margin-label-offset: | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
578 $ label: |
17246 | 579 $ if i.eq.1 |
580 $ then | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
581 $ ! Lines between THEN-ELSE and ELSE-ENDIF are |
17246 | 582 $ ! indented dcl-basic-offset |
583 $ loop1: ! This matches dcl-block-begin-regexp... | |
584 $ ! ...so this line is indented dcl-basic-offset | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
585 $ text = \"This \" + - ! is a continued line |
17246 | 586 \"lined up with the command line\" |
587 $ type sys$input | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
588 Data lines are not indented at all. |
17246 | 589 $ endloop1: ! This matches dcl-block-end-regexp |
590 $ endif | |
591 $ | |
50044
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
592 |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
593 |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
594 There is some minimal font-lock support (see vars |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
595 `dcl-font-lock-defaults' and `dcl-font-lock-keywords')." |
17246 | 596 (interactive) |
597 (kill-all-local-variables) | |
598 (set-syntax-table dcl-mode-syntax-table) | |
599 | |
600 (make-local-variable 'indent-line-function) | |
601 (setq indent-line-function 'dcl-indent-line) | |
602 | |
603 (make-local-variable 'comment-start) | |
604 (setq comment-start "!") | |
605 | |
606 (make-local-variable 'comment-end) | |
607 (setq comment-end "") | |
608 | |
609 (make-local-variable 'comment-multi-line) | |
610 (setq comment-multi-line nil) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
611 |
17246 | 612 ;; This used to be "^\\$[ \t]*![ \t]*" which looks more correct. |
613 ;; The drawback was that you couldn't make empty comment lines by pressing | |
614 ;; C-M-j repeatedly - only the first line became a comment line. | |
615 ;; This version has the drawback that the "$" can be anywhere in the line, | |
616 ;; and something inappropriate might be interpreted as a comment. | |
617 (make-local-variable 'comment-start-skip) | |
618 (setq comment-start-skip "\\$[ \t]*![ \t]*") | |
619 | |
620 (if (boundp 'imenu-generic-expression) | |
20459 | 621 (progn (setq imenu-generic-expression dcl-imenu-generic-expression) |
622 (setq imenu-case-fold-search t))) | |
17246 | 623 (setq imenu-create-index-function 'dcl-imenu-create-index-function) |
624 | |
625 (make-local-variable 'dcl-comment-line-regexp) | |
626 (make-local-variable 'dcl-block-begin-regexp) | |
627 (make-local-variable 'dcl-block-end-regexp) | |
628 (make-local-variable 'dcl-basic-offset) | |
629 (make-local-variable 'dcl-continuation-offset) | |
630 (make-local-variable 'dcl-margin-label-offset) | |
631 (make-local-variable 'dcl-margin-offset) | |
632 (make-local-variable 'dcl-tab-always-indent) | |
633 (make-local-variable 'dcl-electric-characters) | |
634 (make-local-variable 'dcl-calc-command-indent-function) | |
635 (make-local-variable 'dcl-calc-cont-indent-function) | |
636 (make-local-variable 'dcl-electric-reindent-regexps) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
637 |
50044
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
638 ;; font lock |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
639 (make-local-variable 'font-lock-defaults) |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
640 (setq font-lock-defaults dcl-font-lock-defaults) |
534fbe8d6c4b
(dcl-font-lock-keywords, dcl-font-lock-defaults): New vars.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
49598
diff
changeset
|
641 |
17246 | 642 (setq major-mode 'dcl-mode) |
643 (setq mode-name "DCL") | |
644 (use-local-map dcl-mode-map) | |
645 (tempo-use-tag-list 'dcl-tempo-tags) | |
62772
f2892faa87d4
* progmodes/ada-mode.el (ada-mode):
Lute Kamstra <lute@gnu.org>
parents:
60767
diff
changeset
|
646 (run-mode-hooks 'dcl-mode-hook)) |
17246 | 647 |
648 | |
649 ;;; *** Movement commands *************************************************** | |
650 | |
651 | |
652 ;;;------------------------------------------------------------------------- | |
653 (defun dcl-beginning-of-statement () | |
654 "Go to the beginning of the preceding or current command line." | |
655 (interactive) | |
656 (re-search-backward dcl-command-regexp nil t)) | |
657 | |
658 | |
659 ;;;------------------------------------------------------------------------- | |
660 (defun dcl-end-of-statement () | |
661 "Go to the end of the next or current command line." | |
662 (interactive) | |
663 (if (or (dcl-end-of-command-p) | |
664 (dcl-beginning-of-command-p) | |
665 (not (dcl-command-p))) | |
666 () | |
667 (dcl-beginning-of-statement)) | |
668 (re-search-forward dcl-command-regexp nil t)) | |
669 | |
670 | |
671 ;;;------------------------------------------------------------------------- | |
672 (defun dcl-beginning-of-command () | |
673 "Move point to beginning of current command." | |
674 (interactive) | |
675 (let ((type (dcl-get-line-type))) | |
676 (if (and (eq type '$) | |
677 (bolp)) | |
678 () ; already in the correct position | |
679 (dcl-beginning-of-statement)))) | |
680 | |
681 | |
682 ;;;------------------------------------------------------------------------- | |
683 (defun dcl-end-of-command () | |
684 "Move point to end of current command or next command if not on a command." | |
685 (interactive) | |
686 (let ((type (dcl-get-line-type)) | |
687 (start (point))) | |
688 (if (or (eq type '$) | |
689 (eq type '-)) | |
690 (progn | |
691 (dcl-beginning-of-command) | |
692 (dcl-end-of-statement)) | |
693 (dcl-end-of-statement)))) | |
694 | |
695 | |
696 ;;;------------------------------------------------------------------------- | |
697 (defun dcl-backward-command (&optional incl-comment-commands) | |
698 "Move backward to a command. | |
699 Move point to the preceding command line that is not a comment line, | |
700 a command line with only a comment, only contains a `$' or only | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
701 contains a label. |
17246 | 702 |
703 Returns point of the found command line or nil if not able to move." | |
704 (interactive) | |
705 (let ((start (point)) | |
706 done | |
707 retval) | |
708 ;; Find first non-empty command line | |
709 (while (not done) | |
710 ;; back up one statement and look at the command | |
711 (if (dcl-beginning-of-statement) | |
712 (cond | |
713 ((and dcl-block-begin-regexp ; might be nil | |
714 (looking-at (concat "^\\$" dcl-ws-r | |
715 dcl-block-begin-regexp))) | |
716 (setq done t retval (point))) | |
717 ((and dcl-block-end-regexp ; might be nil | |
718 (looking-at (concat "^\\$" dcl-ws-r | |
719 dcl-block-end-regexp))) | |
720 (setq done t retval (point))) | |
721 ((looking-at dcl-comment-line-regexp) | |
722 t) ; comment line, one more loop | |
723 ((and (not incl-comment-commands) | |
724 (looking-at "\\$[ \t]*!")) | |
725 t) ; comment only command, loop... | |
726 ((looking-at "^\\$[ \t]*$") | |
727 t) ; empty line, one more loop | |
728 ((not (looking-at | |
729 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r "$"))) | |
730 (setq done t) ; not a label-only line, exit the loop | |
731 (setq retval (point)))) | |
732 ;; We couldn't go further back, and we haven't found a command yet. | |
733 ;; Return to the start positionn | |
734 (goto-char start) | |
735 (setq done t) | |
736 (setq retval nil))) | |
737 retval)) | |
738 | |
739 | |
740 ;;;------------------------------------------------------------------------- | |
741 (defun dcl-forward-command (&optional incl-comment-commands) | |
742 "Move forward to a command. | |
743 Move point to the end of the next command line that is not a comment line, | |
744 a command line with only a comment, only contains a `$' or only | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
745 contains a label. |
17246 | 746 |
747 Returns point of the found command line or nil if not able to move." | |
748 (interactive) | |
749 (let ((start (point)) | |
750 done | |
751 retval) | |
752 ;; Find first non-empty command line | |
753 (while (not done) | |
754 ;; go forward one statement and look at the command | |
755 (if (dcl-end-of-statement) | |
756 (save-excursion | |
757 (dcl-beginning-of-statement) | |
758 (cond | |
759 ((and dcl-block-begin-regexp ; might be nil | |
760 (looking-at (concat "^\\$" dcl-ws-r | |
761 dcl-block-begin-regexp))) | |
762 (setq done t) | |
763 (setq retval (point))) | |
764 ((and dcl-block-end-regexp ; might be nil | |
765 (looking-at (concat "^\\$" dcl-ws-r | |
766 dcl-block-end-regexp))) | |
767 (setq done t) | |
768 (setq retval (point))) | |
769 ((looking-at dcl-comment-line-regexp) | |
770 t) ; comment line, one more loop | |
771 ((and (not incl-comment-commands) | |
772 (looking-at "\\$[ \t]*!")) | |
773 t) ; comment only command, loop... | |
774 ((looking-at "^\\$[ \t]*$") | |
775 t) ; empty line, one more loop | |
776 ((not (looking-at | |
777 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r "$"))) | |
778 (setq done t) ; not a label-only line, exit the loop | |
779 (setq retval (point))))) | |
780 ;; We couldn't go further back, and we haven't found a command yet. | |
781 ;; Return to the start positionn | |
782 (goto-char start) | |
783 (setq done t) | |
784 (setq retval nil))) | |
785 retval)) | |
786 | |
787 | |
788 ;;;------------------------------------------------------------------------- | |
789 (defun dcl-back-to-indentation () | |
790 "Move point to the first non-whitespace character on this line. | |
791 Leading $ and labels counts as whitespace in this case. | |
792 If this is a comment line then move to the first non-whitespace character | |
793 in the comment. | |
794 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
795 Typing \\[dcl-back-to-indentation] several times in a row will move point to other |
17246 | 796 `interesting' points closer to the left margin, and then back to the |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
797 rightmost point again. |
17246 | 798 |
799 E.g. on the following line, point would go to the positions indicated | |
800 by the numbers in order 1-2-3-1-... : | |
801 | |
802 $ label: command | |
803 3 2 1" | |
804 (interactive) | |
805 (if (eq last-command 'dcl-back-to-indentation) | |
806 (dcl-back-to-indentation-1 (point)) | |
807 (dcl-back-to-indentation-1))) | |
808 (defun dcl-back-to-indentation-1 (&optional limit) | |
809 "Helper function for dcl-back-to-indentation" | |
810 | |
811 ;; "Indentation points" that we will travel to | |
812 ;; $ l: ! comment | |
813 ;; 4 3 2 1 | |
814 ;; | |
815 ;; $ ! text | |
816 ;; 3 2 1 | |
817 ;; | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
818 ;; $ l: command ! |
17246 | 819 ;; 3 2 1 |
820 ;; | |
821 ;; text | |
822 ;; 1 | |
823 | |
824 (let* ((default-limit (save-excursion (end-of-line) (1+ (point)))) | |
825 (limit (or limit default-limit)) | |
826 (last-good-point (point)) | |
827 (opoint (point))) | |
828 ;; Move over blanks | |
829 (back-to-indentation) | |
830 | |
831 ;; If we already were at the outermost indentation point then we | |
832 ;; start searching for the innermost point again. | |
833 (if (= (point) opoint) | |
834 (setq limit default-limit)) | |
835 | |
836 (if (< (point) limit) | |
837 (setq last-good-point (point))) | |
838 | |
839 (cond | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
840 ;; Special treatment for comment lines. We are trying to allow |
17246 | 841 ;; things like "$ !*" as comment lines. |
842 ((looking-at dcl-comment-line-regexp) | |
843 (re-search-forward (concat dcl-comment-line-regexp "[ \t]*") limit t) | |
844 (if (< (point) limit) | |
845 (setq last-good-point (point)))) | |
846 | |
847 ;; Normal command line | |
848 ((looking-at "^\\$[ \t]*") | |
849 ;; Move over leading "$" and blanks | |
850 (re-search-forward "^\\$[ \t]*" limit t) | |
851 (if (< (point) limit) | |
852 (setq last-good-point (point))) | |
853 | |
854 ;; Move over a label (if it isn't a block begin/end) | |
855 ;; We must treat block begin/end labels as commands because | |
856 ;; dcl-set-option relies on it. | |
857 (if (and (looking-at dcl-label-r) | |
858 (not (or (and dcl-block-begin-regexp | |
859 (looking-at dcl-block-begin-regexp)) | |
860 (and dcl-block-end-regexp | |
861 (looking-at dcl-block-end-regexp))))) | |
862 (re-search-forward (concat dcl-label-r "[ \t]*") limit t)) | |
863 (if (< (point) limit) | |
864 (setq last-good-point (point))) | |
865 | |
866 ;; Move over the beginning of a comment | |
867 (if (looking-at "![ \t]*") | |
868 (re-search-forward "![ \t]*" limit t)) | |
869 (if (< (point) limit) | |
870 (setq last-good-point (point))))) | |
871 (goto-char last-good-point))) | |
872 | |
873 | |
874 ;;; *** Support for indentation ********************************************* | |
875 | |
876 | |
877 (defun dcl-get-line-type () | |
878 "Determine the type of the current line. | |
879 Returns one of the following symbols: | |
880 $ for a complete command line or the beginning of a command line. | |
881 - for a continuation line | |
882 $! for a comment line | |
883 data for a data line | |
884 empty-data for an empty line following a data line | |
885 empty-$ for an empty line following a command line" | |
886 (or | |
887 ;; Check if it's a comment line. | |
888 ;; A comment line starts with $! | |
889 (save-excursion | |
890 (beginning-of-line) | |
891 (if (looking-at dcl-comment-line-regexp) | |
892 '$!)) | |
893 ;; Check if it's a command line. | |
894 ;; A command line starts with $ | |
895 (save-excursion | |
896 (beginning-of-line) | |
897 (if (looking-at "^\\$") | |
898 '$)) | |
899 ;; Check if it's a continuation line | |
900 (save-excursion | |
901 (beginning-of-line) | |
902 ;; If we're at the beginning of the buffer it can't be a continuation | |
903 (if (bobp) | |
904 () | |
905 (let ((opoint (point))) | |
906 (dcl-beginning-of-statement) | |
907 (re-search-forward dcl-command-regexp opoint t) | |
908 (if (>= (point) opoint) | |
909 '-)))) | |
910 ;; Empty lines might be different things | |
911 (save-excursion | |
912 (if (and (bolp) (eolp)) | |
913 (if (bobp) | |
914 'empty-$ | |
915 (forward-line -1) | |
916 (let ((type (dcl-get-line-type))) | |
917 (cond | |
918 ((or (equal type '$) (equal type '$!) (equal type '-)) | |
919 'empty-$) | |
920 ((equal type 'data) | |
921 'empty-data)))))) | |
922 ;; Anything else must be a data line | |
923 (progn 'data) | |
924 )) | |
925 | |
926 | |
927 ;;;------------------------------------------------------------------------- | |
928 (defun dcl-indentation-point () | |
929 "Return point of first non-`whitespace' on this line." | |
930 (save-excursion | |
931 (dcl-back-to-indentation) | |
932 (point))) | |
933 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
934 |
17246 | 935 ;;;--------------------------------------------------------------------------- |
936 (defun dcl-show-line-type () | |
937 "Test dcl-get-line-type." | |
938 (interactive) | |
939 (let ((type (dcl-get-line-type))) | |
940 (cond | |
941 ((equal type '$) | |
942 (message "command line")) | |
943 ((equal type '\?) | |
944 (message "?")) | |
945 ((equal type '$!) | |
946 (message "comment line")) | |
947 ((equal type '-) | |
948 (message "continuation line")) | |
949 ((equal type 'data) | |
950 (message "data")) | |
951 ((equal type 'empty-data) | |
952 (message "empty-data")) | |
953 ((equal type 'empty-$) | |
954 (message "empty-$")) | |
955 (t | |
956 (message "hupp")) | |
957 ))) | |
958 | |
959 | |
960 ;;; *** Perform indentation ************************************************* | |
961 | |
962 | |
963 ;;;--------------------------------------------------------------------------- | |
964 (defun dcl-calc-command-indent-multiple | |
965 (indent-type cur-indent extra-indent last-point this-point) | |
966 "Indent lines to a multiple of dcl-basic-offset. | |
967 | |
968 Set dcl-calc-command-indent-function to this function to customize | |
969 indentation of command lines. | |
970 | |
971 Command lines that need to be indented beyond the left margin are | |
972 always indented to a column that is a multiple of dcl-basic-offset, as | |
973 if tab stops were set at 4, 8, 12, etc. | |
974 | |
975 This supports a formatting style like this (dcl-margin offset = 2, | |
976 dcl-basic-offset = 4): | |
977 | |
978 $ if cond | |
979 $ then | |
980 $ if cond | |
981 $ then | |
982 $ ! etc | |
983 " | |
984 ;; calculate indentation if it's an interesting indent-type, | |
985 ;; otherwise return nil to get the default indentation | |
986 (let ((indent)) | |
987 (cond | |
988 ((equal indent-type 'indent) | |
989 (setq indent (- cur-indent (% cur-indent dcl-basic-offset))) | |
990 (setq indent (+ indent extra-indent)))))) | |
991 | |
992 | |
993 ;;;--------------------------------------------------------------------------- | |
994 ;; Some people actually writes likes this. To each his own... | |
995 (defun dcl-calc-command-indent-hang | |
996 (indent-type cur-indent extra-indent last-point this-point) | |
997 "Indent lines as default, but indent THEN, ELSE and ENDIF extra. | |
998 | |
999 Set dcl-calc-command-indent-function to this function to customize | |
1000 indentation of command lines. | |
1001 | |
1002 This function supports a formatting style like this: | |
1003 | |
1004 $ if cond | |
1005 $ then | |
1006 $ xxx | |
1007 $ endif | |
1008 $ xxx | |
1009 | |
1010 If you use this function you will probably want to add \"then\" to | |
1011 dcl-electric-reindent-regexps and define the key \"n\" as | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1012 dcl-electric-character. |
17246 | 1013 " |
1014 (let ((case-fold-search t)) | |
1015 (save-excursion | |
1016 (cond | |
1017 ;; No indentation, this word is `then': +2 | |
1018 ;; last word was endif: -2 | |
1019 ((null indent-type) | |
1020 (or (progn | |
1021 (goto-char this-point) | |
1022 (if (looking-at "\\bthen\\b") | |
1023 (+ cur-indent extra-indent 2))) | |
1024 (progn | |
1025 (goto-char last-point) | |
1026 (if (looking-at "\\bendif\\b") | |
1027 (- (+ cur-indent extra-indent) 2))))) | |
1028 ;; Indentation, last word was `then' or `else': -2 | |
1029 ((equal indent-type 'indent) | |
1030 (goto-char last-point) | |
1031 (cond | |
1032 ((looking-at "\\bthen\\b") | |
1033 (- (+ cur-indent extra-indent) 2)) | |
1034 ((looking-at "\\belse\\b") | |
1035 (- (+ cur-indent extra-indent) 2)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1036 ;; Outdent, this word is `endif' or `else': + 2 |
17246 | 1037 ((equal indent-type 'outdent) |
1038 (goto-char this-point) | |
1039 (cond | |
1040 ((looking-at "\\bendif\\b") | |
1041 (+ cur-indent extra-indent 2)) | |
1042 ((looking-at "\\belse\\b") | |
1043 (+ cur-indent extra-indent 2)))))))) | |
1044 | |
1045 | |
1046 ;;;--------------------------------------------------------------------------- | |
1047 (defun dcl-calc-command-indent () | |
1048 "Calculate how much the current line shall be indented. | |
1049 The line is known to be a command line. | |
1050 | |
1051 Find the indentation of the preceding line and analyze its contents to | |
1052 see if the current lines should be indented. | |
1053 Analyze the current line to see if it should be `outdented'. | |
1054 | |
1055 Calculate the indentation of the current line, either with the default | |
1056 method or by calling dcl-calc-command-indent-function if it is | |
1057 non-nil. | |
1058 | |
1059 If the current line should be outdented, calculate its indentation, | |
1060 either with the default method or by calling | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1061 dcl-calc-command-indent-function if it is non-nil. |
17246 | 1062 |
1063 | |
1064 Rules for default indentation: | |
1065 | |
1066 If it is the first line in the buffer, indent dcl-margin-offset. | |
1067 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1068 Go to the previous command line with a command on it. |
17246 | 1069 Find out how much it is indented (cur-indent). |
1070 Look at the first word on the line to see if the indentation should be | |
1071 adjusted. Skip margin-label, continuations and comments while looking for | |
1072 the first word. Save this buffer position as `last-point'. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1073 If the first word after a label is SUBROUTINE, set extra-indent to |
17246 | 1074 dcl-margin-offset. |
1075 | |
1076 First word extra-indent | |
1077 THEN +dcl-basic-offset | |
1078 ELSE +dcl-basic-offset | |
1079 block-begin +dcl-basic-offset | |
1080 | |
1081 Then return to the current line and look at the first word to see if the | |
1082 indentation should be adjusted again. Save this buffer position as | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1083 `this-point'. |
17246 | 1084 |
1085 First word extra-indent | |
1086 ELSE -dcl-basic-offset | |
1087 ENDIF -dcl-basic-offset | |
1088 block-end -dcl-basic-offset | |
1089 | |
1090 | |
1091 If dcl-calc-command-indent-function is nil or returns nil set | |
1092 cur-indent to cur-indent+extra-indent. | |
1093 | |
1094 If an extra adjustment is necessary and if | |
1095 dcl-calc-command-indent-function is nil or returns nil set cur-indent | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1096 to cur-indent+extra-indent. |
17246 | 1097 |
1098 See also documentation for dcl-calc-command-indent-function. | |
1099 The indent-type classification could probably be expanded upon. | |
1100 " | |
1101 () | |
1102 (save-excursion | |
1103 (beginning-of-line) | |
1104 (let ((is-block nil) | |
1105 (case-fold-search t) | |
1106 cur-indent | |
1107 (extra-indent 0) | |
1108 indent-type last-point this-point extra-indent2 cur-indent2 | |
1109 indent-type2) | |
1110 (if (bobp) ; first line in buffer | |
1111 (setq cur-indent 0 extra-indent dcl-margin-offset | |
1112 indent-type 'first-line | |
1113 this-point (dcl-indentation-point)) | |
1114 (save-excursion | |
1115 (let (done) | |
1116 ;; Find first non-empty command line | |
1117 (while (not done) | |
1118 ;; back up one statement and look at the command | |
1119 (if (dcl-beginning-of-statement) | |
1120 (cond | |
1121 ((and dcl-block-begin-regexp ; might be nil | |
1122 (looking-at (concat "^\\$" dcl-ws-r | |
1123 dcl-block-begin-regexp))) | |
1124 (setq done t) (setq is-block t)) | |
1125 ((and dcl-block-end-regexp ; might be nil | |
1126 (looking-at (concat "^\\$" dcl-ws-r | |
1127 dcl-block-end-regexp))) | |
1128 (setq done t) (setq is-block t)) | |
1129 ((looking-at dcl-comment-line-regexp) | |
1130 t) ; comment line, one more loop | |
1131 ((looking-at "^\\$[ \t]*$") | |
1132 t) ; empty line, one more loop | |
1133 ((not (looking-at | |
1134 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r "$"))) | |
1135 (setq done t))) ; not a label-only line, exit the loop | |
1136 ;; We couldn't go further back, so this must have been the | |
1137 ;; first line. | |
1138 (setq cur-indent dcl-margin-offset | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1139 last-point (dcl-indentation-point)) |
17246 | 1140 (setq done t))) |
1141 ;; Examine the line to get current indentation and possibly a | |
1142 ;; reason to indent. | |
1143 (cond | |
1144 (cur-indent) | |
1145 ((looking-at (concat "^\\$[ \t]*" dcl-label-r dcl-ws-r | |
1146 "\\(subroutine\\b\\)")) | |
1147 (setq cur-indent dcl-margin-offset | |
1148 last-point (1+ (match-beginning 1)))) | |
1149 (t | |
1150 ;; Find out how much this line is indented. | |
1151 ;; Look at comment, continuation character, command but not label | |
1152 ;; unless it's a block. | |
1153 (if is-block | |
1154 (re-search-forward "^\\$[ \t]*") | |
1155 (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r | |
1156 "\\)*[ \t]*"))) | |
1157 (setq cur-indent (current-column)) | |
1158 ;; Look for a reason to indent: Find first word on this line | |
1159 (re-search-forward dcl-ws-r) | |
1160 (setq last-point (point)) | |
1161 (cond | |
1162 ((looking-at "\\bthen\\b") | |
1163 (setq extra-indent dcl-basic-offset indent-type 'indent)) | |
1164 ((looking-at "\\belse\\b") | |
1165 (setq extra-indent dcl-basic-offset indent-type 'indent)) | |
1166 ((and dcl-block-begin-regexp ; might be nil | |
1167 (looking-at dcl-block-begin-regexp)) | |
1168 (setq extra-indent dcl-basic-offset indent-type 'indent)) | |
1169 )))))) | |
1170 (setq extra-indent2 0) | |
1171 ;; We're back at the beginning of the original line. | |
1172 ;; Look for a reason to outdent: Find first word on this line | |
1173 (re-search-forward (concat "^\\$" dcl-ws-r)) | |
1174 (setq this-point (dcl-indentation-point)) | |
1175 (cond | |
1176 ((looking-at "\\belse\\b") | |
1177 (setq extra-indent2 (- dcl-basic-offset) indent-type2 'outdent)) | |
1178 ((looking-at "\\bendif\\b") | |
1179 (setq extra-indent2 (- dcl-basic-offset) indent-type2 'outdent)) | |
1180 ((and dcl-block-end-regexp ; might be nil | |
1181 (looking-at dcl-block-end-regexp)) | |
1182 (setq extra-indent2 (- dcl-basic-offset) indent-type2 'outdent)) | |
1183 ((looking-at (concat dcl-label-r dcl-ws-r "\\(subroutine\\b\\)")) | |
1184 (setq cur-indent2 0 extra-indent2 dcl-margin-offset | |
1185 indent-type2 'first-line | |
1186 this-point (1+ (match-beginning 1))))) | |
1187 ;; Calculate indent | |
1188 (setq cur-indent | |
1189 (or (and dcl-calc-command-indent-function | |
1190 (funcall dcl-calc-command-indent-function | |
1191 indent-type cur-indent extra-indent | |
1192 last-point this-point)) | |
1193 (+ cur-indent extra-indent))) | |
1194 ;; Calculate outdent | |
1195 (if indent-type2 | |
1196 (progn | |
1197 (or cur-indent2 (setq cur-indent2 cur-indent)) | |
1198 (setq cur-indent | |
1199 (or (and dcl-calc-command-indent-function | |
1200 (funcall dcl-calc-command-indent-function | |
1201 indent-type2 cur-indent2 extra-indent2 | |
1202 last-point this-point)) | |
1203 (+ cur-indent2 extra-indent2))))) | |
1204 cur-indent | |
1205 ))) | |
1206 | |
1207 | |
1208 ;;;--------------------------------------------------------------------------- | |
1209 (defun dcl-calc-cont-indent-relative (cur-indent extra-indent) | |
1210 "Indent continuation lines to align with words on previous line. | |
1211 | |
1212 Indent continuation lines to a position relative to preceding | |
1213 significant command line elements. | |
1214 | |
1215 Set `dcl-calc-cont-indent-function' to this function to customize | |
1216 indentation of continuation lines. | |
1217 | |
1218 Indented lines will align with either: | |
1219 | |
1220 * the second word on the command line | |
1221 $ set default - | |
1222 [-] | |
47126
5a5a4566e9f7
(dcl-calc-cont-indent-relative): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
41608
diff
changeset
|
1223 * the word after an assignment |
17246 | 1224 $ a = b + - |
1225 d | |
1226 * the third word if it's a qualifier | |
1227 $ set terminal/width=80 - | |
1228 /page=24 | |
1229 * the innermost nonclosed parenthesis | |
1230 $ if ((a.eq.b .and. - | |
1231 d.eq.c .or. f$function(xxxx, - | |
1232 yyy))) | |
1233 " | |
1234 (let ((case-fold-search t) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1235 indent) |
17246 | 1236 (save-excursion |
1237 (dcl-beginning-of-statement) | |
1238 (let ((end (save-excursion (forward-line 1) (point)))) | |
1239 ;; Move over blanks and label | |
1240 (if (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r | |
1241 "\\)*[ \t]*") end t) | |
1242 (progn | |
1243 ;; Move over the first word (might be `@filespec') | |
1244 (if (> (skip-chars-forward "@:[]<>$\\-a-zA-Z0-9_.;" end) 0) | |
1245 (let (was-assignment) | |
1246 (skip-chars-forward " \t" end) | |
1247 ;; skip over assignment if there is one | |
1248 (if (looking-at ":?==?") | |
1249 (progn | |
1250 (setq was-assignment t) | |
1251 (skip-chars-forward " \t:=" end))) | |
1252 ;; This could be the position to indent to | |
1253 (setq indent (current-column)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1254 |
17246 | 1255 ;; Move to the next word unless we have seen an |
1256 ;; assignment. If it starts with `/' it's a | |
1257 ;; qualifier and we will indent to that position | |
1258 (if (and (not was-assignment) | |
1259 (> (skip-chars-forward "a-zA-Z0-9_" end) 0)) | |
1260 (progn | |
1261 (skip-chars-forward " \t" end) | |
1262 (if (= (char-after (point)) ?/) | |
1263 (setq indent (current-column))))) | |
1264 )))))) | |
1265 ;; Now check if there are any parenthesis to adjust to. | |
1266 ;; If there is, we will indent to the position after the last non-closed | |
1267 ;; opening parenthesis. | |
1268 (save-excursion | |
1269 (beginning-of-line) | |
1270 (let* ((start (save-excursion (dcl-beginning-of-statement) (point))) | |
1271 (parse-sexp-ignore-comments t) ; for parse-partial | |
1272 (par-pos (nth 1 (parse-partial-sexp start (point))))) | |
1273 (if par-pos ; is nil if no parenthesis was found | |
1274 (setq indent (save-excursion | |
1275 (goto-char par-pos) | |
1276 (1+ (current-column))))))) | |
1277 indent)) | |
1278 | |
1279 | |
1280 ;;;--------------------------------------------------------------------------- | |
1281 (defun dcl-calc-continuation-indent () | |
1282 "Calculate how much the current line shall be indented. | |
1283 The line is known to be a continuation line. | |
1284 | |
1285 Go to the previous command line. | |
1286 Find out how much it is indented." | |
1287 ;; This was copied without much thought from dcl-calc-command-indent, so | |
1288 ;; it's a bit clumsy. | |
1289 () | |
1290 (save-excursion | |
1291 (beginning-of-line) | |
1292 (if (bobp) | |
1293 ;; Huh? a continuation line first in the buffer?? | |
1294 dcl-margin-offset | |
1295 (let ((is-block nil) | |
1296 (indent)) | |
1297 (save-excursion | |
1298 ;; Find first non-empty command line | |
1299 (let ((done)) | |
1300 (while (not done) | |
1301 (if (dcl-beginning-of-statement) | |
1302 (cond | |
1303 ((and dcl-block-begin-regexp | |
1304 (looking-at (concat "^\\$" dcl-ws-r | |
1305 dcl-block-begin-regexp))) | |
1306 (setq done t) (setq is-block t)) | |
1307 ((and dcl-block-end-regexp | |
1308 (looking-at (concat "^\\$" dcl-ws-r | |
1309 dcl-block-end-regexp))) | |
1310 (setq done t) (setq is-block t)) | |
1311 ((looking-at dcl-comment-line-regexp) | |
1312 t) | |
1313 ((looking-at "^\\$[ \t]*$") | |
1314 t) | |
1315 ((not (looking-at | |
1316 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r "$"))) | |
1317 (setq done t))) | |
1318 ;; This must have been the first line. | |
1319 (setq indent dcl-margin-offset) | |
1320 (setq done t))) | |
1321 (if indent | |
1322 () | |
1323 ;; Find out how much this line is indented. | |
1324 ;; Look at comment, continuation character, command but not label | |
1325 ;; unless it's a block. | |
1326 (if is-block | |
1327 (re-search-forward "^\\$[ \t]*") | |
1328 (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r | |
1329 "\\)*[ \t]*"))) | |
1330 (setq indent (current-column)) | |
1331 ))) | |
1332 ;; We're back at the beginning of the original line. | |
1333 (or (and dcl-calc-cont-indent-function | |
1334 (funcall dcl-calc-cont-indent-function indent | |
1335 dcl-continuation-offset)) | |
1336 (+ indent dcl-continuation-offset)) | |
1337 )))) | |
1338 | |
1339 | |
1340 ;;;--------------------------------------------------------------------------- | |
1341 (defun dcl-indent-command-line () | |
1342 "Indent a line known to be a command line." | |
1343 (let ((indent (dcl-calc-command-indent)) | |
1344 (pos (- (point-max) (point)))) | |
1345 (save-excursion | |
1346 (beginning-of-line) | |
1347 (re-search-forward "^\\$[ \t]*") | |
1348 ;; Indent any margin-label if the offset is set | |
1349 ;; (Don't look at block labels) | |
1350 (if (and dcl-margin-label-offset | |
1351 (looking-at dcl-label-r) | |
1352 (not (and dcl-block-begin-regexp | |
1353 (looking-at dcl-block-begin-regexp))) | |
1354 (not (and dcl-block-end-regexp | |
1355 (looking-at dcl-block-end-regexp)))) | |
1356 (progn | |
1357 (dcl-indent-to dcl-margin-label-offset) | |
1358 (re-search-forward dcl-label-r))) | |
1359 (dcl-indent-to indent 1) | |
1360 ) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1361 ;; |
17246 | 1362 (if (> (- (point-max) pos) (point)) |
1363 (goto-char (- (point-max) pos))) | |
1364 )) | |
1365 | |
1366 | |
1367 ;;;------------------------------------------------------------------------- | |
1368 (defun dcl-indent-continuation-line () | |
1369 "Indent a line known to be a continuation line. | |
1370 | |
1371 Notice that no special treatment is made for labels. They have to be | |
1372 on the first part on a command line to be taken into consideration." | |
1373 (let ((indent (dcl-calc-continuation-indent))) | |
1374 (save-excursion | |
1375 (beginning-of-line) | |
1376 (re-search-forward "^[ \t]*") | |
1377 (dcl-indent-to indent)) | |
1378 (skip-chars-forward " \t"))) | |
1379 | |
1380 | |
1381 ;;;--------------------------------------------------------------------------- | |
1382 (defun dcl-delete-chars (chars) | |
1383 "Delete all characters in the set CHARS around point." | |
1384 (skip-chars-backward chars) | |
1385 (delete-region (point) (progn (skip-chars-forward chars) (point)))) | |
1386 | |
1387 | |
1388 ;;;--------------------------------------------------------------------------- | |
1389 (defun dcl-indent-line () | |
1390 "The DCL version of `indent-line-function'. | |
1391 Adjusts indentation on the current line. Data lines are not indented." | |
1392 (let ((type (dcl-get-line-type))) | |
1393 (cond | |
1394 ((equal type '$) | |
1395 (dcl-indent-command-line)) | |
1396 ((equal type '\?) | |
1397 (message "Unknown line type!")) | |
1398 ((equal type '$!)) | |
1399 ((equal type 'data)) | |
1400 ((equal type 'empty-data)) | |
1401 ((equal type '-) | |
1402 (dcl-indent-continuation-line)) | |
1403 ((equal type 'empty-$) | |
1404 (insert "$" ) | |
1405 (dcl-indent-command-line)) | |
1406 (t | |
1407 (message "dcl-indent-line: unknown type")) | |
1408 ))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1409 |
17246 | 1410 |
1411 ;;;------------------------------------------------------------------------- | |
1412 (defun dcl-indent-command () | |
1413 "Indents the complete command line that point is on. | |
1414 This includes continuation lines." | |
1415 (interactive "*") | |
1416 (let ((type (dcl-get-line-type))) | |
1417 (if (or (equal type '$) | |
1418 (equal type '-) | |
1419 (equal type 'empty-$)) | |
1420 (save-excursion | |
1421 (indent-region (progn (or (looking-at "^\\$") | |
1422 (dcl-beginning-of-statement)) | |
1423 (point)) | |
1424 (progn (dcl-end-of-statement) (point)) | |
1425 nil))))) | |
1426 | |
1427 | |
1428 ;;;------------------------------------------------------------------------- | |
1429 (defun dcl-tab () | |
1430 "Insert tab in data lines or indent code. | |
1431 If `dcl-tab-always-indent' is t, code lines are always indented. | |
1432 If nil, indent the current line only if point is at the left margin or in | |
1433 the lines indentation; otherwise insert a tab." | |
1434 (interactive "*") | |
1435 (let ((type (dcl-get-line-type)) | |
1436 (start-point (point))) | |
1437 (cond | |
1438 ;; Data line : always insert tab | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1439 ((or (equal type 'data) (equal type 'empty-data)) |
17246 | 1440 (tab-to-tab-stop)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1441 ;; Indent only at start of line |
17246 | 1442 ((not dcl-tab-always-indent) ; nil |
1443 (let ((search-end-point | |
1444 (save-excursion | |
1445 (beginning-of-line) | |
1446 (re-search-forward "^\\$?[ \t]*" start-point t)))) | |
1447 (if (or (bolp) | |
1448 (and search-end-point | |
1449 (>= search-end-point start-point))) | |
1450 (dcl-indent-line) | |
1451 (tab-to-tab-stop)))) | |
1452 ;; Always indent | |
1453 ((eq dcl-tab-always-indent t) ; t | |
1454 (dcl-indent-line)) | |
1455 ))) | |
1456 | |
1457 | |
1458 ;;;------------------------------------------------------------------------- | |
1459 (defun dcl-electric-character (arg) | |
1460 "Inserts a character and indents if necessary. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1461 Insert a character if the user gave a numeric argument or the flag |
17246 | 1462 `dcl-electric-characters' is not set. If an argument was given, |
1463 insert that many characters. | |
1464 | |
1465 The line is only reindented if the word just typed matches any of the | |
1466 regexps in `dcl-electric-reindent-regexps'." | |
1467 (interactive "*P") | |
1468 (if (or arg (not dcl-electric-characters)) | |
1469 (if arg | |
1470 (self-insert-command (prefix-numeric-value arg)) | |
1471 (self-insert-command 1)) | |
1472 ;; Insert the character and indent | |
1473 (self-insert-command 1) | |
1474 (let ((case-fold-search t)) | |
1475 ;; There must be a better way than (memq t ...). | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1476 ;; (apply 'or ...) didn't work |
17246 | 1477 (if (memq t (mapcar 'dcl-was-looking-at dcl-electric-reindent-regexps)) |
1478 (dcl-indent-line))))) | |
1479 | |
1480 | |
1481 ;;;------------------------------------------------------------------------- | |
1482 (defun dcl-indent-to (col &optional minimum) | |
1483 "Like indent-to, but only indents if indentation would change" | |
1484 (interactive) | |
1485 (let (cur-indent collapsed indent) | |
1486 (save-excursion | |
1487 (skip-chars-forward " \t") | |
1488 (setq cur-indent (current-column)) | |
1489 (skip-chars-backward " \t") | |
1490 (setq collapsed (current-column))) | |
1491 (setq indent (max col (+ collapsed (or minimum 0)))) | |
1492 (if (/= indent cur-indent) | |
1493 (progn | |
1494 (dcl-delete-chars " \t") | |
1495 (indent-to col minimum))))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1496 |
17246 | 1497 |
1498 ;;;------------------------------------------------------------------------- | |
1499 (defun dcl-split-line () | |
1500 "Break line at point and insert text to keep the syntax valid. | |
1501 | |
1502 Inserts continuation marks and splits character strings." | |
1503 ;; Still don't know what to do with comments at the end of a command line. | |
1504 (interactive "*") | |
1505 (let (done | |
1506 (type (dcl-get-line-type))) | |
1507 (cond | |
1508 ((or (equal type '$) (equal type '-)) | |
1509 (let ((info (parse-partial-sexp | |
1510 (save-excursion (dcl-beginning-of-statement) (point)) | |
1511 (point)))) | |
1512 ;; handle some special cases | |
1513 (cond | |
1514 ((nth 3 info) ; in text constant | |
1515 (insert "\" + -\n\"") | |
1516 (indent-according-to-mode) | |
1517 (setq done t)) | |
1518 ((not (nth 4 info)) ; not in comment | |
1519 (cond | |
1520 ((and (not (eolp)) | |
1521 (= (char-after (point)) ?\") | |
1522 (= (char-after (1- (point))) ?\")) | |
1523 (progn ; a " "" " situation | |
1524 (forward-char -1) | |
1525 (insert "\" + -\n\"") | |
1526 (forward-char 1) | |
1527 (indent-according-to-mode) | |
1528 (setq done t))) | |
1529 ((and (dcl-was-looking-at "[ \t]*-[ \t]*") ; after cont mark | |
1530 (looking-at "[ \t]*\\(!.*\\)?$")) | |
1531 ;; Do default below. This might considered wrong if we're | |
1532 ;; after a subtraction: $ x = 3 - <M-LFD> | |
1533 ) | |
1534 (t | |
1535 (delete-horizontal-space) | |
1536 (insert " -") | |
1537 (insert "\n") (indent-according-to-mode) | |
1538 (setq done t)))) | |
1539 )))) | |
1540 ;; use the normal function for other cases | |
1541 (if (not done) ; normal M-LFD action | |
1542 (indent-new-comment-line)))) | |
1543 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1544 |
17246 | 1545 ;;;------------------------------------------------------------------------- |
1546 (defun dcl-delete-indentation (&optional arg) | |
1547 "Join this line to previous like delete-indentation. | |
1548 Also remove the continuation mark if easily detected." | |
1549 (interactive "*P") | |
1550 (delete-indentation arg) | |
1551 (let ((type (dcl-get-line-type))) | |
1552 (if (and (or (equal type '$) | |
1553 (equal type '-) | |
1554 (equal type 'empty-$)) | |
1555 (not (bobp)) | |
1556 (= (char-after (1- (point))) ?-)) | |
1557 (progn | |
1558 (delete-backward-char 1) | |
1559 (fixup-whitespace))))) | |
1560 | |
1561 | |
1562 ;;; *** Set options ********************************************************* | |
1563 | |
1564 | |
1565 ;;;------------------------------------------------------------------------- | |
1566 (defun dcl-option-value-basic (option-assoc) | |
1567 "Guess a value for basic-offset." | |
1568 (save-excursion | |
1569 (dcl-beginning-of-command) | |
1570 (let* (;; current lines indentation | |
1571 (this-indent (save-excursion | |
1572 (dcl-back-to-indentation) | |
1573 (current-column))) | |
1574 ;; previous lines indentation | |
1575 (prev-indent (save-excursion | |
1576 (if (dcl-backward-command) | |
1577 (progn | |
1578 (dcl-back-to-indentation) | |
1579 (current-column))))) | |
1580 (next-indent (save-excursion | |
1581 (dcl-end-of-command) | |
1582 (if (dcl-forward-command) | |
1583 (progn | |
1584 (dcl-beginning-of-command) | |
1585 (dcl-back-to-indentation) | |
1586 (current-column))))) | |
1587 (diff (if prev-indent | |
1588 (abs (- this-indent prev-indent))))) | |
1589 (cond | |
1590 ((and diff | |
1591 (/= diff 0)) | |
1592 diff) | |
1593 ((and next-indent | |
1594 (/= (- this-indent next-indent) 0)) | |
1595 (abs (- this-indent next-indent))) | |
1596 (t | |
1597 dcl-basic-offset))))) | |
1598 | |
1599 | |
1600 ;;;------------------------------------------------------------------------- | |
1601 (defun dcl-option-value-offset (option-assoc) | |
1602 "Guess a value for an offset. | |
1603 Find the column of the first non-blank character on the line. | |
17261 | 1604 Returns the column offset." |
17246 | 1605 (save-excursion |
1606 (beginning-of-line) | |
1607 (re-search-forward "^$[ \t]*" nil t) | |
1608 (current-column))) | |
1609 | |
1610 | |
1611 ;;;------------------------------------------------------------------------- | |
1612 (defun dcl-option-value-margin-offset (option-assoc) | |
1613 "Guess a value for margin offset. | |
1614 Find the column of the first non-blank character on the line, not | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1615 counting labels. |
17246 | 1616 Returns a number as a string." |
1617 (save-excursion | |
1618 (beginning-of-line) | |
1619 (dcl-back-to-indentation) | |
1620 (current-column))) | |
1621 | |
1622 | |
1623 ;;;------------------------------------------------------------------------- | |
1624 (defun dcl-option-value-comment-line (option-assoc) | |
1625 "Guess a value for `dcl-comment-line-regexp'. | |
1626 Must return a string." | |
1627 ;; Should we set comment-start and comment-start-skip as well? | |
1628 ;; If someone wants `$!&' as a comment line, C-M-j won't work well if | |
1629 ;; they aren't set. | |
1630 ;; This must be done after the user has given the real value in | |
1631 ;; dcl-set-option. | |
1632 (format | |
1633 "%S" | |
1634 (save-excursion | |
1635 (beginning-of-line) | |
1636 ;; We could search for "^\\$.*!+[^ \t]*", but, as noted above, we | |
1637 ;; can't handle that case very good, so there is no point in | |
1638 ;; suggesting it. | |
1639 (if (looking-at "^\\$[^!\n]*!") | |
1640 (let ((regexp (buffer-substring (match-beginning 0) (match-end 0)))) | |
1641 (concat "^" (regexp-quote regexp))) | |
1642 dcl-comment-line-regexp)))) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1643 |
17246 | 1644 |
1645 ;;;------------------------------------------------------------------------- | |
1646 (defun dcl-guess-option-value (option) | |
1647 "Guess what value the user would like to give the symbol option." | |
1648 (let* ((option-assoc (assoc option dcl-option-alist)) | |
1649 (option (car option-assoc)) | |
1650 (action (car (cdr option-assoc))) | |
1651 (value (cond | |
1652 ((fboundp action) | |
1653 (funcall action option-assoc)) | |
1654 ((eq action 'toggle) | |
1655 (not (eval option))) | |
1656 ((eq action 'curval) | |
1657 (cond ((or (stringp (symbol-value option)) | |
1658 (numberp (symbol-value option))) | |
1659 (format "%S" (symbol-value option))) | |
1660 (t | |
1661 (format "'%S" (symbol-value option)))))))) | |
1662 ;; format the value as a string if not already done | |
1663 (if (stringp value) | |
1664 value | |
1665 (format "%S" value)))) | |
1666 | |
1667 | |
1668 ;;;------------------------------------------------------------------------- | |
1669 (defun dcl-guess-option () | |
1670 "Guess what option the user wants to set by looking around in the code. | |
1671 Returns the name of the option variable as a string." | |
1672 (let ((case-fold-search t)) | |
1673 (cond | |
1674 ;; Continued line | |
1675 ((eq (dcl-get-line-type) '-) | |
1676 "dcl-calc-cont-indent-function") | |
1677 ;; Comment line | |
1678 ((save-excursion | |
1679 (beginning-of-line) | |
1680 (looking-at "^\\$[ \t]*!")) | |
1681 "dcl-comment-line-regexp") | |
1682 ;; Margin offset: subroutine statement or first line in buffer | |
1683 ;; Test this before label indentation to detect a subroutine | |
1684 ((save-excursion | |
1685 (beginning-of-line) | |
1686 (or (looking-at (concat "^\\$[ \t]*" dcl-label-r dcl-ws-r | |
1687 "subroutine")) | |
1688 (save-excursion | |
1689 (not (dcl-backward-command t))))) | |
1690 "dcl-margin-offset") | |
1691 ;; Margin offset: on command line after subroutine statement | |
1692 ((save-excursion | |
1693 (beginning-of-line) | |
1694 (and (eq (dcl-get-line-type) '$) | |
1695 (dcl-backward-command) | |
1696 (looking-at (concat "^\\$[ \t]*" dcl-label-r dcl-ws-r | |
1697 "subroutine")))) | |
1698 "dcl-margin-offset") | |
1699 ;; Label indentation | |
1700 ((save-excursion | |
1701 (beginning-of-line) | |
1702 (and (looking-at (concat "^\\$[ \t]*" dcl-label-r)) | |
1703 (not (and dcl-block-begin-regexp | |
1704 (looking-at (concat "^\\$[ \t]*" | |
1705 dcl-block-begin-regexp)))) | |
1706 (not (and dcl-block-end-regexp | |
1707 (looking-at (concat "^\\$[ \t]*" | |
1708 dcl-block-end-regexp)))))) | |
1709 "dcl-margin-label-offset") | |
1710 ;; Basic offset | |
1711 ((and (eq (dcl-get-line-type) '$) ; beginning of command | |
1712 (save-excursion | |
1713 (beginning-of-line) | |
1714 (let* ((this-indent (save-excursion | |
1715 (dcl-back-to-indentation) | |
1716 (current-column))) | |
1717 (prev-indent (save-excursion | |
1718 (if (dcl-backward-command) | |
1719 (progn | |
1720 (dcl-back-to-indentation) | |
1721 (current-column))))) | |
1722 (next-indent (save-excursion | |
1723 (dcl-end-of-command) | |
1724 (if (dcl-forward-command) | |
1725 (progn | |
1726 (dcl-beginning-of-command) | |
1727 (dcl-back-to-indentation) | |
1728 (current-column)))))) | |
1729 (or (and prev-indent ; last cmd is indented differently | |
1730 (/= (- this-indent prev-indent) 0)) | |
1731 (and next-indent | |
1732 (/= (- this-indent next-indent) 0)))))) | |
1733 "dcl-basic-offset") | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1734 ;; No more guesses. |
17246 | 1735 (t |
1736 "")))) | |
1737 | |
1738 | |
1739 ;;;------------------------------------------------------------------------- | |
1740 (defun dcl-set-option (option-sym option-value) | |
1741 "Set a value for one of the dcl customization variables. | |
1742 The function tries to guess which variable should be set and to what value. | |
1743 All variable names are available as completions and in the history list." | |
1744 (interactive | |
1745 (let* ((option-sym | |
1746 (intern (completing-read | |
1747 "Set DCL option: " ; prompt | |
1748 (mapcar (function ; alist of valid values | |
1749 (lambda (option-assoc) | |
1750 (cons (format "%s" (car option-assoc)) nil))) | |
1751 dcl-option-alist) | |
1752 nil ; no predicate | |
1753 t ; only value from the list OK | |
1754 (dcl-guess-option) ; initial (default) value | |
1755 'dcl-option-history))) ; history list | |
1756 (option-value | |
1757 (eval-minibuffer | |
1758 (format "Set DCL option %s to: " option-sym) | |
1759 (dcl-guess-option-value option-sym)))) | |
1760 (list option-sym option-value))) | |
1761 ;; Should make a sanity check on the symbol/value pair. | |
1762 ;; `set' instead of `setq' because we want option-sym to be evaluated. | |
1763 (set option-sym option-value)) | |
1764 | |
1765 | |
1766 ;;; *** Save options ******************************************************** | |
1767 | |
1768 | |
1769 ;;;------------------------------------------------------------------------- | |
1770 (defun dcl-save-local-variable (var &optional def-prefix def-suffix) | |
1771 "Save a variable in a `Local Variables' list. | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1772 Set or update the value of VAR in the current buffers |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1773 `Local Variables:' list." |
17246 | 1774 ;; Look for "Local variables:" line in last page. |
1775 (save-excursion | |
1776 (goto-char (point-max)) | |
1777 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) | |
1778 (if (let ((case-fold-search t)) | |
1779 (search-forward "Local Variables:" nil t)) | |
1780 (let ((continue t) | |
1781 prefix prefixlen suffix beg | |
1782 prefix-string suffix-string) | |
1783 ;; The prefix is what comes before "local variables:" in its line. | |
1784 ;; The suffix is what comes after "local variables:" in its line. | |
1785 (skip-chars-forward " \t") | |
1786 (or (eolp) | |
1787 (setq suffix-string (buffer-substring (point) | |
1788 (progn (end-of-line) (point))))) | |
1789 (goto-char (match-beginning 0)) | |
1790 (or (bolp) | |
1791 (setq prefix-string | |
1792 (buffer-substring (point) | |
1793 (progn (beginning-of-line) (point))))) | |
1794 | |
1795 (if prefix-string (setq prefixlen (length prefix-string) | |
1796 prefix (regexp-quote prefix-string))) | |
1797 (if suffix-string (setq suffix (concat (regexp-quote suffix-string) | |
1798 "$"))) | |
1799 (while continue | |
1800 ;; Look at next local variable spec. | |
1801 (if selective-display (re-search-forward "[\n\C-m]") | |
1802 (forward-line 1)) | |
1803 ;; Skip the prefix, if any. | |
1804 (if prefix | |
1805 (if (looking-at prefix) | |
1806 (forward-char prefixlen) | |
1807 (error "Local variables entry is missing the prefix"))) | |
1808 ;; Find the variable name; strip whitespace. | |
1809 (skip-chars-forward " \t") | |
1810 (setq beg (point)) | |
1811 (skip-chars-forward "^:\n") | |
1812 (if (eolp) (error "Missing colon in local variables entry")) | |
1813 (skip-chars-backward " \t") | |
1814 (let* ((str (buffer-substring beg (point))) | |
1815 (found-var (read str)) | |
1816 val) | |
1817 ;; Setting variable named "end" means end of list. | |
1818 (if (string-equal (downcase str) "end") | |
1819 (progn | |
1820 ;; Not found. Insert a new entry before this line | |
1821 (setq continue nil) | |
1822 (beginning-of-line) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1823 (insert (concat prefix-string (symbol-name var) ": " |
17246 | 1824 (prin1-to-string (eval var)) " " |
1825 suffix-string "\n"))) | |
1826 ;; Is it the variable we are looking for? | |
1827 (if (eq var found-var) | |
1828 (progn | |
1829 ;; Found it: delete the variable value and insert the | |
1830 ;; new value. | |
1831 (setq continue nil) | |
1832 (skip-chars-forward "^:") | |
1833 (forward-char 1) | |
1834 (delete-region (point) (progn (read (current-buffer)) | |
1835 (point))) | |
1836 (insert " ") | |
1837 (prin1 (eval var) (current-buffer)) | |
1838 (skip-chars-backward "\n") | |
1839 (skip-chars-forward " \t") | |
1840 (or (if suffix (looking-at suffix) (eolp)) | |
1841 (error | |
1842 "Local variables entry is terminated incorrectly"))) | |
1843 (end-of-line)))))) | |
1844 ;; Did not find "Local variables:" | |
1845 (goto-char (point-max)) | |
1846 (if (not (bolp)) | |
1847 (insert "\n")) | |
1848 ;; If def- parameter not set, use comment- if set. In that case, make | |
1849 ;; sure there is a space in a suitable position | |
1850 (let ((def-prefix | |
1851 (cond | |
1852 (def-prefix | |
1853 def-prefix) | |
1854 (comment-start | |
1855 (if (or (equal comment-start "") | |
1856 (string-match "[ \t]$" comment-start)) | |
1857 comment-start | |
1858 (concat comment-start " "))))) | |
1859 (def-suffix | |
1860 (cond | |
1861 (def-suffix | |
1862 def-suffix) | |
1863 (comment-end | |
1864 (if (or (equal comment-end "") | |
1865 (string-match "^[ \t]" comment-end)) | |
1866 comment-end | |
1867 (concat " " comment-end)))))) | |
1868 (insert (concat def-prefix "Local variables:" def-suffix "\n")) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1869 (insert (concat def-prefix (symbol-name var) ": " |
17246 | 1870 (prin1-to-string (eval var)) def-suffix "\n")) |
1871 (insert (concat def-prefix "end:" def-suffix))) | |
1872 ))) | |
1873 | |
1874 | |
1875 ;;;------------------------------------------------------------------------- | |
1876 (defun dcl-save-all-options () | |
1877 "Save all dcl-mode options for this buffer. | |
1878 Saves or updates all dcl-mode related options in a `Local Variables:' | |
1879 section at the end of the current buffer." | |
1880 (interactive "*") | |
1881 (mapcar (lambda (option-assoc) | |
1882 (let* ((option (car option-assoc))) | |
1883 (dcl-save-local-variable option "$! "))) | |
1884 dcl-option-alist)) | |
1885 | |
1886 | |
1887 ;;;------------------------------------------------------------------------- | |
1888 (defun dcl-save-nondefault-options () | |
1889 "Save changed DCL mode options for this buffer. | |
1890 Saves or updates all DCL mode related options that don't have their | |
1891 default values in a `Local Variables:' section at the end of the | |
1892 current buffer. | |
1893 | |
1894 No entries are removed from the `Local Variables:' section. This means | |
1895 that if a variable is given a non-default value in the section and | |
1896 later is manually reset to its default value, the variable's entry will | |
1897 still be present in the `Local Variables:' section with its old value." | |
1898 (interactive "*") | |
1899 (mapcar (lambda (option-assoc) | |
1900 (let* ((option (car option-assoc)) | |
1901 (option-name (symbol-name option))) | |
1902 (if (and (string-equal "dcl-" | |
1903 (substring option-name 0 4)) | |
1904 (not (equal (default-value option) (eval option)))) | |
1905 (dcl-save-local-variable option "$! ")))) | |
1906 dcl-option-alist)) | |
1907 | |
1908 | |
1909 ;;;------------------------------------------------------------------------- | |
1910 (defun dcl-save-option (option) | |
1911 "Save a DCL mode option for this buffer. | |
1912 Saves or updates an option in a `Local Variables:' | |
1913 section at the end of the current buffer." | |
1914 (interactive | |
1915 (let ((option (intern (completing-read "Option: " obarray)))) | |
1916 (list option))) | |
1917 (dcl-save-local-variable option)) | |
1918 | |
1919 | |
1920 ;;;------------------------------------------------------------------------- | |
1921 (defun dcl-save-mode () | |
1922 "Save the current mode for this buffer. | |
1923 Save the current mode in a `Local Variables:' | |
1924 section at the end of the current buffer." | |
1925 (interactive) | |
1926 (let ((mode (prin1-to-string major-mode))) | |
1927 (if (string-match "-mode$" mode) | |
1928 (let ((mode (intern (substring mode 0 (match-beginning 0))))) | |
1929 (dcl-save-option 'mode)) | |
1930 (message "Strange mode: %s" mode)))) | |
1931 | |
1932 | |
1933 ;;; *** Templates *********************************************************** | |
1934 ;; tempo seems to be the only suitable package among those included in | |
1935 ;; standard Emacs. I would have liked something closer to the functionality | |
1936 ;; of LSE templates... | |
1937 | |
1938 | |
1939 (require 'tempo) | |
1940 (defvar dcl-tempo-tags nil | |
1941 "Tempo tags for DCL mode.") | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1942 |
17246 | 1943 (tempo-define-template "dcl-f$context" |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1944 '("f$context" dcl-tempo-left-paren |
17246 | 1945 (p "context-type: ") dcl-tempo-comma |
1946 (p "context-symbol: ") dcl-tempo-comma | |
1947 (p "selection-item: ") dcl-tempo-comma | |
1948 (p "selection-value: ") dcl-tempo-comma | |
1949 (p "value-qualifier: ") dcl-tempo-right-paren) | |
1950 "f$context" "" 'dcl-tempo-tags) | |
1951 | |
1952 (tempo-define-template "dcl-f$csid" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1953 '("f$csid" dcl-tempo-left-paren |
17246 | 1954 (p "context-symbol: ") dcl-tempo-right-paren) |
1955 "f$csid" "" 'dcl-tempo-tags) | |
1956 | |
1957 (tempo-define-template "dcl-f$cvsi" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1958 '("f$cvsi" dcl-tempo-left-paren |
17246 | 1959 (p "start-bit: ") dcl-tempo-comma |
1960 (p "number-of-bits: ") dcl-tempo-comma | |
1961 (p "string: ") dcl-tempo-right-paren) | |
1962 "f$cvsi" "" 'dcl-tempo-tags) | |
1963 | |
1964 (tempo-define-template "dcl-f$cvtime" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1965 '("f$cvtime" dcl-tempo-left-paren |
17246 | 1966 (p "[input_time]: ") dcl-tempo-comma |
1967 (p "[output_time_format]: ") dcl-tempo-comma | |
1968 (p "[output_field]: ") dcl-tempo-right-paren) | |
1969 "f$cvtime" "" 'dcl-tempo-tags) | |
1970 | |
1971 (tempo-define-template "dcl-f$cvui" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1972 '("f$cvui" dcl-tempo-left-paren |
17246 | 1973 (p "start-bit: ") dcl-tempo-comma |
1974 (p "number-of-bits: ") dcl-tempo-comma | |
1975 (p "string") dcl-tempo-right-paren) | |
1976 "f$cvui" "" 'dcl-tempo-tags) | |
1977 | |
1978 (tempo-define-template "dcl-f$device" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1979 '("f$device" dcl-tempo-left-paren |
17246 | 1980 (p "[search_devnam]: ") dcl-tempo-comma |
1981 (p "[devclass]: ") dcl-tempo-comma | |
1982 (p "[devtype]: ") dcl-tempo-comma | |
1983 (p "[stream-id]: ") dcl-tempo-right-paren) | |
1984 "f$device" "" 'dcl-tempo-tags) | |
1985 | |
1986 (tempo-define-template "dcl-f$directory" | |
1987 '("f$directory" dcl-tempo-left-paren | |
1988 dcl-tempo-right-paren) | |
1989 "f$directory" "" 'dcl-tempo-tags) | |
1990 | |
1991 (tempo-define-template "dcl-f$edit" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1992 '("f$edit" dcl-tempo-left-paren |
17246 | 1993 (p "string: ") dcl-tempo-comma |
1994 (p "edit-list: ") dcl-tempo-right-paren) | |
1995 "f$edit" "" 'dcl-tempo-tags) | |
1996 | |
1997 (tempo-define-template "dcl-f$element" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
1998 '("f$element" dcl-tempo-left-paren |
17246 | 1999 (p "element-number: ") dcl-tempo-comma |
2000 (p "delimiter: ") dcl-tempo-comma | |
2001 (p "string: ") dcl-tempo-right-paren) | |
2002 "f$element" "" 'dcl-tempo-tags) | |
2003 | |
2004 (tempo-define-template "dcl-f$environment" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2005 '("f$environment" dcl-tempo-left-paren |
17246 | 2006 (p "item: ") dcl-tempo-right-paren) |
2007 "f$environment" "" 'dcl-tempo-tags) | |
2008 | |
2009 (tempo-define-template "dcl-f$extract" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2010 '("f$extract" dcl-tempo-left-paren |
17246 | 2011 (p "start: ") dcl-tempo-comma |
2012 (p "length: ") dcl-tempo-comma | |
2013 (p "string: ") dcl-tempo-right-paren) | |
2014 "f$extract" "" 'dcl-tempo-tags) | |
2015 | |
2016 (tempo-define-template "dcl-f$fao" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2017 '("f$fao" dcl-tempo-left-paren |
17246 | 2018 (p "control-string: ") dcl-tempo-comma |
2019 ("argument[,...]: ") dcl-tempo-right-paren) | |
2020 "f$fao" "" 'dcl-tempo-tags) | |
2021 | |
2022 (tempo-define-template "dcl-f$file_attributes" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2023 '("f$file_attributes" dcl-tempo-left-paren |
17246 | 2024 (p "filespec: ") dcl-tempo-comma |
2025 (p "item: ") dcl-tempo-right-paren) | |
2026 "f$file_attributes" "" 'dcl-tempo-tags) | |
2027 | |
2028 (tempo-define-template "dcl-f$getdvi" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2029 '("f$getdvi" dcl-tempo-left-paren |
17246 | 2030 (p "device-name: ") dcl-tempo-comma |
2031 (p "item: ") dcl-tempo-right-paren) | |
2032 "f$getdvi" "" 'dcl-tempo-tags) | |
2033 | |
2034 (tempo-define-template "dcl-f$getjpi" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2035 '("f$getjpi" dcl-tempo-left-paren |
17246 | 2036 (p "pid: ") dcl-tempo-comma |
2037 (p "item: ") dcl-tempo-right-paren ) | |
2038 "f$getjpi" "" 'dcl-tempo-tags) | |
2039 | |
2040 (tempo-define-template "dcl-f$getqui" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2041 '("f$getqui" dcl-tempo-left-paren |
17246 | 2042 (p "function: ") dcl-tempo-comma |
2043 (p "[item]: ") dcl-tempo-comma | |
2044 (p "[object-id]: ") dcl-tempo-comma | |
2045 (p "[flags]: ") dcl-tempo-right-paren) | |
2046 "f$getqui" "" 'dcl-tempo-tags) | |
2047 | |
2048 (tempo-define-template "dcl-f$getsyi" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2049 '("f$getsyi" dcl-tempo-left-paren |
17246 | 2050 (p "item: ") dcl-tempo-comma |
2051 (p "[node-name]: ") dcl-tempo-comma | |
2052 (p "[cluster-id]: ") dcl-tempo-right-paren) | |
2053 "f$getsyi" "" 'dcl-tempo-tags) | |
2054 | |
2055 (tempo-define-template "dcl-f$identifier" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2056 '("f$identifier" dcl-tempo-left-paren |
17246 | 2057 (p "identifier: ") dcl-tempo-comma |
2058 (p "conversion-type: ") dcl-tempo-right-paren) | |
2059 "f$identifier" "" 'dcl-tempo-tags) | |
2060 | |
2061 (tempo-define-template "dcl-f$integer" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2062 '("f$integer" dcl-tempo-left-paren |
17246 | 2063 (p "expression: ") dcl-tempo-right-paren) |
2064 "f$integer" "" 'dcl-tempo-tags) | |
2065 | |
2066 (tempo-define-template "dcl-f$length" | |
2067 '("f$length" dcl-tempo-left-paren | |
2068 (p "string: ") dcl-tempo-right-paren ) | |
2069 "f$length" "" 'dcl-tempo-tags) | |
2070 | |
2071 (tempo-define-template "dcl-f$locate" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2072 '("f$locate" dcl-tempo-left-paren |
17246 | 2073 (p "substring: ") dcl-tempo-comma |
2074 (p "string: ") dcl-tempo-right-paren) | |
2075 "f$locate" "" 'dcl-tempo-tags) | |
2076 | |
2077 (tempo-define-template "dcl-f$message" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2078 '("f$message" dcl-tempo-left-paren |
17246 | 2079 (p "status-code: ") dcl-tempo-right-paren ) |
2080 "f$message" "" 'dcl-tempo-tags) | |
2081 | |
2082 (tempo-define-template "dcl-f$mode" | |
2083 '("f$mode" dcl-tempo-left-paren dcl-tempo-right-paren) | |
2084 "f$mode" "" 'dcl-tempo-tags) | |
2085 | |
2086 (tempo-define-template "dcl-f$parse" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2087 '("f$parse" dcl-tempo-left-paren |
17246 | 2088 (p "filespec: ") dcl-tempo-comma |
2089 (p "[default-spec]: ") dcl-tempo-comma | |
2090 (p "[related-spec]: ") dcl-tempo-comma | |
2091 (p "[field]: ") dcl-tempo-comma | |
2092 (p "[parse-type]: ") dcl-tempo-right-paren) | |
2093 "f$parse" "" 'dcl-tempo-tags) | |
2094 | |
2095 (tempo-define-template "dcl-f$pid" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2096 '("f$pid" dcl-tempo-left-paren |
17246 | 2097 (p "context-symbol: ") dcl-tempo-right-paren) |
2098 "f$pid" "" 'dcl-tempo-tags) | |
2099 | |
2100 (tempo-define-template "dcl-f$privilege" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2101 '("f$privilege" dcl-tempo-left-paren |
17246 | 2102 (p "priv-states: ") dcl-tempo-right-paren) |
2103 "f$privilege" "" 'dcl-tempo-tags) | |
2104 | |
2105 (tempo-define-template "dcl-f$process" | |
2106 '("f$process()") | |
2107 "f$process" "" 'dcl-tempo-tags) | |
2108 | |
2109 (tempo-define-template "dcl-f$search" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2110 '("f$search" dcl-tempo-left-paren |
17246 | 2111 (p "filespec: ") dcl-tempo-comma |
2112 (p "[stream-id]: ") dcl-tempo-right-paren) | |
2113 "f$search" "" 'dcl-tempo-tags) | |
2114 | |
2115 (tempo-define-template "dcl-f$setprv" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2116 '("f$setprv" dcl-tempo-left-paren |
17246 | 2117 (p "priv-states: ") dcl-tempo-right-paren) |
2118 "f$setprv" "" 'dcl-tempo-tags) | |
2119 | |
2120 (tempo-define-template "dcl-f$string" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2121 '("f$string" dcl-tempo-left-paren |
17246 | 2122 (p "expression: ") dcl-tempo-right-paren) |
2123 "f$string" "" 'dcl-tempo-tags) | |
2124 | |
2125 (tempo-define-template "dcl-f$time" | |
2126 '("f$time" dcl-tempo-left-paren dcl-tempo-right-paren) | |
2127 "f$time" "" 'dcl-tempo-tags) | |
2128 | |
2129 (tempo-define-template "dcl-f$trnlnm" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2130 '("f$trnlnm" dcl-tempo-left-paren |
17246 | 2131 (p "logical-name: ") dcl-tempo-comma |
2132 (p "[table]: ") dcl-tempo-comma | |
2133 (p "[index]: ") dcl-tempo-comma | |
2134 (p "[mode]: ") dcl-tempo-comma | |
2135 (p "[case]: ") dcl-tempo-comma | |
2136 (p "[item]: ") dcl-tempo-right-paren) | |
2137 "f$trnlnm" "" 'dcl-tempo-tags) | |
2138 | |
2139 (tempo-define-template "dcl-f$type" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2140 '("f$type" dcl-tempo-left-paren |
17246 | 2141 (p "symbol-name: ") dcl-tempo-right-paren) |
2142 "f$type" "" 'dcl-tempo-tags) | |
2143 | |
2144 (tempo-define-template "dcl-f$user" | |
2145 '("f$user" dcl-tempo-left-paren dcl-tempo-right-paren) | |
2146 "f$user" "" 'dcl-tempo-tags) | |
2147 | |
2148 (tempo-define-template "dcl-f$verify" | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2149 '("f$verify" dcl-tempo-left-paren |
17246 | 2150 (p "[procedure-value]: ") dcl-tempo-comma |
2151 (p "[image-value]: ") dcl-tempo-right-paren) | |
2152 "f$verify" "" 'dcl-tempo-tags) | |
2153 | |
2154 | |
2155 | |
2156 | |
2157 ;;; *** Unsorted stuff ***************************************************** | |
2158 | |
2159 | |
2160 ;;;------------------------------------------------------------------------- | |
2161 (defun dcl-beginning-of-command-p () | |
2162 "Return t if point is at the beginning of a command. | |
2163 Otherwise return nil." | |
2164 (and (bolp) | |
2165 (eq (dcl-get-line-type) '$))) | |
2166 | |
2167 | |
2168 ;;;------------------------------------------------------------------------- | |
2169 (defun dcl-end-of-command-p () | |
2170 "Check if point is at the end of a command. | |
2171 Return t if point is at the end of a command, either the end of an | |
2172 only line or at the end of the last continuation line. | |
2173 Otherwise return nil." | |
2174 ;; Must be at end-of-line on a command line or a continuation line | |
2175 (let ((type (dcl-get-line-type))) | |
2176 (if (and (eolp) | |
2177 (or (eq type '$) | |
2178 (eq type '-))) | |
2179 ;; Next line must not be a continuation line | |
2180 (save-excursion | |
2181 (forward-line) | |
2182 (not (eq (dcl-get-line-type) '-)))))) | |
2183 | |
2184 | |
2185 ;;;------------------------------------------------------------------------- | |
2186 (defun dcl-command-p () | |
2187 "Check if point is on a command line. | |
2188 Return t if point is on a command line or a continuation line, | |
2189 otherwise return nil." | |
2190 (let ((type (dcl-get-line-type))) | |
2191 (or (eq type '$) | |
2192 (eq type '-)))) | |
2193 | |
2194 | |
2195 ;;;------------------------------------------------------------------------- | |
2196 (defun dcl-was-looking-at (regexp) | |
2197 (save-excursion | |
2198 (let ((start (point)) | |
2199 (found (re-search-backward regexp 0 t))) | |
2200 (if (not found) | |
2201 () | |
2202 (equal start (match-end 0)))))) | |
2203 | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47126
diff
changeset
|
2204 |
17246 | 2205 ;;;------------------------------------------------------------------------- |
2206 (defun dcl-imenu-create-index-function () | |
2207 "Jacket routine to make imenu searches non case sensitive." | |
2208 (let ((case-fold-search t)) | |
2209 (imenu-default-create-index-function))) | |
2210 | |
2211 | |
2212 | |
2213 ;;; *** Epilogue ************************************************************ | |
2214 | |
2215 | |
2216 (provide 'dcl-mode) | |
2217 | |
2218 (run-hooks 'dcl-mode-load-hook) ; for your customizations | |
2219 | |
52401 | 2220 ;;; arch-tag: e00d421b-f26c-483e-a8bd-af412ea7764a |
17246 | 2221 ;;; dcl-mode.el ends here |