Mercurial > emacs
comparison lisp/progmodes/dcl-mode.el @ 49598:0d8b17d428b5
Trailing whitepace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 13:24:35 +0000 |
parents | 5a5a4566e9f7 |
children | 534fbe8d6c4b d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49597:e88404e8f2cf | 49598:0d8b17d428b5 |
---|---|
29 ;; indent lines, add leading `$' and trailing `-', move around in the | 29 ;; indent lines, add leading `$' and trailing `-', move around in the |
30 ;; code and insert lexical functions. | 30 ;; code and insert lexical functions. |
31 ;; | 31 ;; |
32 ;; Type `C-h m' when you are editing a .COM file to get more | 32 ;; Type `C-h m' when you are editing a .COM file to get more |
33 ;; information about this mode. | 33 ;; information about this mode. |
34 ;; | 34 ;; |
35 ;; To use templates you will need a version of tempo.el that is at | 35 ;; To use templates you will need a version of tempo.el that is at |
36 ;; least later than the buggy 1.1.1, which was included with my versions of | 36 ;; least later than the buggy 1.1.1, which was included with my versions of |
37 ;; Emacs. I used version 1.2.4. | 37 ;; Emacs. I used version 1.2.4. |
38 ;; The latest tempo.el distribution can be fetched from | 38 ;; The latest tempo.el distribution can be fetched from |
39 ;; ftp.lysator.liu.se in the directory /pub/emacs. | 39 ;; ftp.lysator.liu.se in the directory /pub/emacs. |
40 ;; I recommend setting (setq tempo-interactive t). This will make | 40 ;; I recommend setting (setq tempo-interactive t). This will make |
41 ;; tempo prompt you for values to put in the blank spots in the templates. | 41 ;; tempo prompt you for values to put in the blank spots in the templates. |
42 ;; | 42 ;; |
45 ;; the version I use in Emacs 19.30. (It was *so* much easier to hook | 45 ;; the version I use in Emacs 19.30. (It was *so* much easier to hook |
46 ;; into that version than the one in 19.27...) | 46 ;; into that version than the one in 19.27...) |
47 ;; | 47 ;; |
48 ;; Any feedback will be welcomed. If you write functions for | 48 ;; Any feedback will be welcomed. If you write functions for |
49 ;; dcl-calc-command-indent-function or dcl-calc-cont-indent-function, | 49 ;; dcl-calc-command-indent-function or dcl-calc-cont-indent-function, |
50 ;; please send them to the maintainer. | 50 ;; please send them to the maintainer. |
51 ;; | 51 ;; |
52 ;; | 52 ;; |
53 ;; Ideas for improvement: | 53 ;; Ideas for improvement: |
54 ;; * Change meaning of `left margin' when dcl-tab-always-indent is nil. | 54 ;; * Change meaning of `left margin' when dcl-tab-always-indent is nil. |
55 ;; Consider the following line (`_' is the cursor): | 55 ;; Consider the following line (`_' is the cursor): |
56 ;; $ label: _ command | 56 ;; $ label: _ command |
96 :group 'dcl) | 96 :group 'dcl) |
97 | 97 |
98 | 98 |
99 (defcustom dcl-margin-offset 8 | 99 (defcustom dcl-margin-offset 8 |
100 "*Indentation for the first command line in DCL. | 100 "*Indentation for the first command line in DCL. |
101 The first command line in a file or after a SUBROUTINE statement is indented | 101 The first command line in a file or after a SUBROUTINE statement is indented |
102 this much. Other command lines are indented the same number of columns as | 102 this much. Other command lines are indented the same number of columns as |
103 the preceding command line. | 103 the preceding command line. |
104 A command line is a line that starts with `$'." | 104 A command line is a line that starts with `$'." |
105 :type 'integer | 105 :type 'integer |
106 :group 'dcl) | 106 :group 'dcl) |
135 :group 'dcl) | 135 :group 'dcl) |
136 | 136 |
137 | 137 |
138 (defcustom dcl-calc-command-indent-function nil | 138 (defcustom dcl-calc-command-indent-function nil |
139 "*Function to calculate indentation for a command line in DCL. | 139 "*Function to calculate indentation for a command line in DCL. |
140 If this variable is non-nil it is called as a function: | 140 If this variable is non-nil it is called as a function: |
141 | 141 |
142 \(func INDENT-TYPE CUR-INDENT EXTRA-INDENT LAST-POINT THIS-POINT) | 142 \(func INDENT-TYPE CUR-INDENT EXTRA-INDENT LAST-POINT THIS-POINT) |
143 | 143 |
144 The function must return the number of columns to indent the current line or | 144 The function must return the number of columns to indent the current line or |
145 nil to get the default indentation. | 145 nil to get the default indentation. |
146 | 146 |
147 INDENT-TYPE is a symbol indicating what kind of indentation should be done. | 147 INDENT-TYPE is a symbol indicating what kind of indentation should be done. |
148 It can have the following values: | 148 It can have the following values: |
149 indent the lines indentation should be increased, e.g. after THEN. | 149 indent the lines indentation should be increased, e.g. after THEN. |
150 outdent the lines indentation should be decreased, e.g a line with ENDIF. | 150 outdent the lines indentation should be decreased, e.g a line with ENDIF. |
151 first-line indentation for the first line in a buffer or SUBROUTINE. | 151 first-line indentation for the first line in a buffer or SUBROUTINE. |
152 CUR-INDENT is the indentation of the preceding command line. | 152 CUR-INDENT is the indentation of the preceding command line. |
153 EXTRA-INDENT is the default change in indentation for this line | 153 EXTRA-INDENT is the default change in indentation for this line |
154 \(a negative number for 'outdent). | 154 \(a negative number for 'outdent). |
155 LAST-POINT is the buffer position of the first significant word on the | 155 LAST-POINT is the buffer position of the first significant word on the |
156 previous line or nil if the current line is the first line. | 156 previous line or nil if the current line is the first line. |
157 THIS-POINT is the buffer position of the first significant word on the | 157 THIS-POINT is the buffer position of the first significant word on the |
158 current line. | 158 current line. |
159 | 159 |
160 If this variable is nil, the indentation is calculated as | 160 If this variable is nil, the indentation is calculated as |
161 CUR-INDENT + EXTRA-INDENT. | 161 CUR-INDENT + EXTRA-INDENT. |
162 | 162 |
163 This package includes two functions suitable for this: | 163 This package includes two functions suitable for this: |
164 dcl-calc-command-indent-multiple | 164 dcl-calc-command-indent-multiple |
165 dcl-calc-command-indent-hang" | 165 dcl-calc-command-indent-hang" |
167 :group 'dcl) | 167 :group 'dcl) |
168 | 168 |
169 | 169 |
170 (defcustom dcl-calc-cont-indent-function 'dcl-calc-cont-indent-relative | 170 (defcustom dcl-calc-cont-indent-function 'dcl-calc-cont-indent-relative |
171 "*Function to calculate indentation for a continuation line. | 171 "*Function to calculate indentation for a continuation line. |
172 If this variable is non-nil it is called as a function: | 172 If this variable is non-nil it is called as a function: |
173 | 173 |
174 \(func CUR-INDENT EXTRA-INDENT) | 174 \(func CUR-INDENT EXTRA-INDENT) |
175 | 175 |
176 The function must return the number of columns to indent the current line or | 176 The function must return the number of columns to indent the current line or |
177 nil to get the default indentation. | 177 nil to get the default indentation. |
178 | 178 |
179 If this variable is nil, the indentation is calculated as | 179 If this variable is nil, the indentation is calculated as |
180 CUR-INDENT + EXTRA-INDENT. | 180 CUR-INDENT + EXTRA-INDENT. |
181 | 181 |
182 This package includes one function suitable for this: | 182 This package includes one function suitable for this: |
183 dcl-calc-cont-indent-relative" | 183 dcl-calc-cont-indent-relative" |
184 :type 'function | 184 :type 'function |
187 | 187 |
188 (defcustom dcl-tab-always-indent t | 188 (defcustom dcl-tab-always-indent t |
189 "*Controls the operation of the TAB key in DCL mode. | 189 "*Controls the operation of the TAB key in DCL mode. |
190 If t, pressing TAB always indents the current line. | 190 If t, pressing TAB always indents the current line. |
191 If nil, pressing TAB indents the current line if point is at the left margin. | 191 If nil, pressing TAB indents the current line if point is at the left margin. |
192 Data lines (i.e. lines not part of a command line or continuation line) are | 192 Data lines (i.e. lines not part of a command line or continuation line) are |
193 never indented." | 193 never indented." |
194 :type 'boolean | 194 :type 'boolean |
195 :group 'dcl) | 195 :group 'dcl) |
196 | 196 |
197 | 197 |
244 (,dcl-imenu-label-gosub "\\s-GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)" 1) | 244 (,dcl-imenu-label-gosub "\\s-GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)" 1) |
245 (,dcl-imenu-label-call "\\s-CALL[ \t]+\\([A-Za-z0-9_\$]+\\)" 1)) | 245 (,dcl-imenu-label-call "\\s-CALL[ \t]+\\([A-Za-z0-9_\$]+\\)" 1)) |
246 "*Default imenu generic expression for DCL. | 246 "*Default imenu generic expression for DCL. |
247 | 247 |
248 The default includes SUBROUTINE labels in the main listing and | 248 The default includes SUBROUTINE labels in the main listing and |
249 sub-listings for other labels, CALL, GOTO and GOSUB statements. | 249 sub-listings for other labels, CALL, GOTO and GOSUB statements. |
250 See `imenu-generic-expression' for details." | 250 See `imenu-generic-expression' for details." |
251 :type '(repeat (sexp :tag "Imenu Expression")) | 251 :type '(repeat (sexp :tag "Imenu Expression")) |
252 :group 'dcl) | 252 :group 'dcl) |
253 | 253 |
254 | 254 |
268 (setq dcl-mode-syntax-table (make-syntax-table)) | 268 (setq dcl-mode-syntax-table (make-syntax-table)) |
269 (modify-syntax-entry ?! "<" dcl-mode-syntax-table) ; comment start | 269 (modify-syntax-entry ?! "<" dcl-mode-syntax-table) ; comment start |
270 (modify-syntax-entry ?\n ">" dcl-mode-syntax-table) ; comment end | 270 (modify-syntax-entry ?\n ">" dcl-mode-syntax-table) ; comment end |
271 (modify-syntax-entry ?< "(>" dcl-mode-syntax-table) ; < and ... | 271 (modify-syntax-entry ?< "(>" dcl-mode-syntax-table) ; < and ... |
272 (modify-syntax-entry ?> ")<" dcl-mode-syntax-table) ; > is a matching pair | 272 (modify-syntax-entry ?> ")<" dcl-mode-syntax-table) ; > is a matching pair |
273 ) | 273 ) |
274 | 274 |
275 | 275 |
276 (defvar dcl-mode-map () | 276 (defvar dcl-mode-map () |
277 "Keymap used in DCL-mode buffers.") | 277 "Keymap used in DCL-mode buffers.") |
278 (if dcl-mode-map | 278 (if dcl-mode-map |
355 A label is a name followed by a colon followed by white-space or end-of-line." | 355 A label is a name followed by a colon followed by white-space or end-of-line." |
356 :type 'regexp | 356 :type 'regexp |
357 :group 'dcl) | 357 :group 'dcl) |
358 | 358 |
359 | 359 |
360 (defcustom dcl-cmd-r | 360 (defcustom dcl-cmd-r |
361 "^\\$\\(.*-[ \t]*\\(!.*\\)*\n\\)*[^!\"\n]*\\(\".*\\(\"\".*\\)*\"\\)*[^!\"\n]*" | 361 "^\\$\\(.*-[ \t]*\\(!.*\\)*\n\\)*[^!\"\n]*\\(\".*\\(\"\".*\\)*\"\\)*[^!\"\n]*" |
362 "Regular expression describing a DCL command line up to a trailing comment. | 362 "Regular expression describing a DCL command line up to a trailing comment. |
363 A line starting with $, optionally followed by continuation lines, | 363 A line starting with $, optionally followed by continuation lines, |
364 followed by the end of the command line. | 364 followed by the end of the command line. |
365 A continuation line is any characters followed by `-', | 365 A continuation line is any characters followed by `-', |
366 optionally followed by a comment, followed by a newline." | 366 optionally followed by a comment, followed by a newline." |
367 :type 'regexp | 367 :type 'regexp |
368 :group 'dcl) | 368 :group 'dcl) |
369 | 369 |
370 | 370 |
371 (defcustom dcl-command-regexp | 371 (defcustom dcl-command-regexp |
372 "^\\$\\(.*-[ \t]*\\(!.*\\)*\n\\)*.*\\(\".*\\(\"\".*\\)*\"\\)*" | 372 "^\\$\\(.*-[ \t]*\\(!.*\\)*\n\\)*.*\\(\".*\\(\"\".*\\)*\"\\)*" |
373 "Regular expression describing a DCL command line. | 373 "Regular expression describing a DCL command line. |
374 A line starting with $, optionally followed by continuation lines, | 374 A line starting with $, optionally followed by continuation lines, |
375 followed by the end of the command line. | 375 followed by the end of the command line. |
376 A continuation line is any characters followed by `-', | 376 A continuation line is any characters followed by `-', |
390 `endif', the line will be reindented." | 390 `endif', the line will be reindented." |
391 :type '(repeat regexp) | 391 :type '(repeat regexp) |
392 :group 'dcl) | 392 :group 'dcl) |
393 | 393 |
394 | 394 |
395 (defvar dcl-option-alist | 395 (defvar dcl-option-alist |
396 '((dcl-basic-offset dcl-option-value-basic) | 396 '((dcl-basic-offset dcl-option-value-basic) |
397 (dcl-continuation-offset curval) | 397 (dcl-continuation-offset curval) |
398 (dcl-margin-offset dcl-option-value-margin-offset) | 398 (dcl-margin-offset dcl-option-value-margin-offset) |
399 (dcl-margin-label-offset dcl-option-value-offset) | 399 (dcl-margin-label-offset dcl-option-value-offset) |
400 (dcl-comment-line-regexp dcl-option-value-comment-line) | 400 (dcl-comment-line-regexp dcl-option-value-comment-line) |
401 (dcl-block-begin-regexp curval) | 401 (dcl-block-begin-regexp curval) |
402 (dcl-block-end-regexp curval) | 402 (dcl-block-end-regexp curval) |
403 (dcl-tab-always-indent toggle) | 403 (dcl-tab-always-indent toggle) |
404 (dcl-electric-characters toggle) | 404 (dcl-electric-characters toggle) |
405 (dcl-electric-reindent-regexps curval) | 405 (dcl-electric-reindent-regexps curval) |
406 (dcl-tempo-comma curval) | 406 (dcl-tempo-comma curval) |
407 (dcl-tempo-left-paren curval) | 407 (dcl-tempo-left-paren curval) |
408 (dcl-tempo-right-paren curval) | 408 (dcl-tempo-right-paren curval) |
409 (dcl-calc-command-indent-function curval) | 409 (dcl-calc-command-indent-function curval) |
410 (dcl-calc-cont-indent-function curval) | 410 (dcl-calc-cont-indent-function curval) |
411 (comment-start curval) | 411 (comment-start curval) |
412 (comment-start-skip curval) | 412 (comment-start-skip curval) |
413 ) | 413 ) |
419 The keywords are: | 419 The keywords are: |
420 curval the current value | 420 curval the current value |
421 toggle the opposite of the current value (for t/nil)") | 421 toggle the opposite of the current value (for t/nil)") |
422 | 422 |
423 | 423 |
424 (defvar dcl-option-history | 424 (defvar dcl-option-history |
425 (mapcar (lambda (option-assoc) | 425 (mapcar (lambda (option-assoc) |
426 (format "%s" (car option-assoc))) | 426 (format "%s" (car option-assoc))) |
427 dcl-option-alist) | 427 dcl-option-alist) |
428 "The history list for dcl-set-option. | 428 "The history list for dcl-set-option. |
429 Preloaded with all known option names from dcl-option-alist") | 429 Preloaded with all known option names from dcl-option-alist") |
441 ; "GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5) | 441 ; "GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5) |
442 ; ("CALL" (, (concat dcl-cmd-r "CALL[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5))) | 442 ; ("CALL" (, (concat dcl-cmd-r "CALL[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5))) |
443 ; "*Default imenu generic expression for DCL. | 443 ; "*Default imenu generic expression for DCL. |
444 | 444 |
445 ;The default includes SUBROUTINE labels in the main listing and | 445 ;The default includes SUBROUTINE labels in the main listing and |
446 ;sub-listings for other labels, CALL, GOTO and GOSUB statements. | 446 ;sub-listings for other labels, CALL, GOTO and GOSUB statements. |
447 ;See `imenu-generic-expression' in a recent (e.g. Emacs 19.30) imenu.el | 447 ;See `imenu-generic-expression' in a recent (e.g. Emacs 19.30) imenu.el |
448 ;for details.") | 448 ;for details.") |
449 | 449 |
450 | 450 |
451 ;;; *** Mode initialization ************************************************* | 451 ;;; *** Mode initialization ************************************************* |
458 This mode indents command lines in blocks. (A block is commands between | 458 This mode indents command lines in blocks. (A block is commands between |
459 THEN-ELSE-ENDIF and between lines matching dcl-block-begin-regexp and | 459 THEN-ELSE-ENDIF and between lines matching dcl-block-begin-regexp and |
460 dcl-block-end-regexp.) | 460 dcl-block-end-regexp.) |
461 | 461 |
462 Labels are indented to a fixed position unless they begin or end a block. | 462 Labels are indented to a fixed position unless they begin or end a block. |
463 Whole-line comments (matching dcl-comment-line-regexp) are not indented. | 463 Whole-line comments (matching dcl-comment-line-regexp) are not indented. |
464 Data lines are not indented. | 464 Data lines are not indented. |
465 | 465 |
466 Key bindings: | 466 Key bindings: |
467 | 467 |
468 \\{dcl-mode-map} | 468 \\{dcl-mode-map} |
486 | 486 |
487 dcl-margin-label-offset | 487 dcl-margin-label-offset |
488 Indentation for a label. | 488 Indentation for a label. |
489 | 489 |
490 dcl-comment-line-regexp | 490 dcl-comment-line-regexp |
491 Lines matching this regexp will not be indented. | 491 Lines matching this regexp will not be indented. |
492 | 492 |
493 dcl-block-begin-regexp | 493 dcl-block-begin-regexp |
494 dcl-block-end-regexp | 494 dcl-block-end-regexp |
495 Regexps that match command lines that begin and end, respectively, | 495 Regexps that match command lines that begin and end, respectively, |
496 a block of commmand lines that will be given extra indentation. | 496 a block of commmand lines that will be given extra indentation. |
509 One such function is included in the package: | 509 One such function is included in the package: |
510 dcl-calc-cont-indent-relative (set by default) | 510 dcl-calc-cont-indent-relative (set by default) |
511 | 511 |
512 dcl-tab-always-indent | 512 dcl-tab-always-indent |
513 If t, pressing TAB always indents the current line. | 513 If t, pressing TAB always indents the current line. |
514 If nil, pressing TAB indents the current line if point is at the left | 514 If nil, pressing TAB indents the current line if point is at the left |
515 margin. | 515 margin. |
516 | 516 |
517 dcl-electric-characters | 517 dcl-electric-characters |
518 Non-nil causes lines to be indented at once when a label, ELSE or ENDIF is | 518 Non-nil causes lines to be indented at once when a label, ELSE or ENDIF is |
519 typed. | 519 typed. |
520 | 520 |
521 dcl-electric-reindent-regexps | 521 dcl-electric-reindent-regexps |
522 Use this variable and function dcl-electric-character to customize | 522 Use this variable and function dcl-electric-character to customize |
528 These variables control the look of expanded templates. | 528 These variables control the look of expanded templates. |
529 | 529 |
530 dcl-imenu-generic-expression | 530 dcl-imenu-generic-expression |
531 Default value for imenu-generic-expression. The default includes | 531 Default value for imenu-generic-expression. The default includes |
532 SUBROUTINE labels in the main listing and sub-listings for | 532 SUBROUTINE labels in the main listing and sub-listings for |
533 other labels, CALL, GOTO and GOSUB statements. | 533 other labels, CALL, GOTO and GOSUB statements. |
534 | 534 |
535 dcl-imenu-label-labels | 535 dcl-imenu-label-labels |
536 dcl-imenu-label-goto | 536 dcl-imenu-label-goto |
537 dcl-imenu-label-gosub | 537 dcl-imenu-label-gosub |
538 dcl-imenu-label-call | 538 dcl-imenu-label-call |
539 Change the text that is used as sub-listing labels in imenu. | 539 Change the text that is used as sub-listing labels in imenu. |
540 | 540 |
541 Loading this package calls the value of the variable | 541 Loading this package calls the value of the variable |
542 `dcl-mode-load-hook' with no args, if that value is non-nil. | 542 `dcl-mode-load-hook' with no args, if that value is non-nil. |
543 Turning on DCL mode calls the value of the variable `dcl-mode-hook' | 543 Turning on DCL mode calls the value of the variable `dcl-mode-hook' |
544 with no args, if that value is non-nil. | 544 with no args, if that value is non-nil. |
545 | 545 |
546 | 546 |
547 The following example uses the default values for all variables: | 547 The following example uses the default values for all variables: |
548 | 548 |
549 $! This is a comment line that is not indented (it matches | 549 $! This is a comment line that is not indented (it matches |
550 $! dcl-comment-line-regexp) | 550 $! dcl-comment-line-regexp) |
551 $! Next follows the first command line. It is indented dcl-margin-offset. | 551 $! Next follows the first command line. It is indented dcl-margin-offset. |
552 $ i = 1 | 552 $ i = 1 |
553 $ ! Other comments are indented like command lines. | 553 $ ! Other comments are indented like command lines. |
554 $ ! A margin label indented dcl-margin-label-offset: | 554 $ ! A margin label indented dcl-margin-label-offset: |
555 $ label: | 555 $ label: |
556 $ if i.eq.1 | 556 $ if i.eq.1 |
557 $ then | 557 $ then |
558 $ ! Lines between THEN-ELSE and ELSE-ENDIF are | 558 $ ! Lines between THEN-ELSE and ELSE-ENDIF are |
559 $ ! indented dcl-basic-offset | 559 $ ! indented dcl-basic-offset |
560 $ loop1: ! This matches dcl-block-begin-regexp... | 560 $ loop1: ! This matches dcl-block-begin-regexp... |
561 $ ! ...so this line is indented dcl-basic-offset | 561 $ ! ...so this line is indented dcl-basic-offset |
562 $ text = \"This \" + - ! is a continued line | 562 $ text = \"This \" + - ! is a continued line |
563 \"lined up with the command line\" | 563 \"lined up with the command line\" |
564 $ type sys$input | 564 $ type sys$input |
565 Data lines are not indented at all. | 565 Data lines are not indented at all. |
566 $ endloop1: ! This matches dcl-block-end-regexp | 566 $ endloop1: ! This matches dcl-block-end-regexp |
567 $ endif | 567 $ endif |
568 $ | 568 $ |
569 " | 569 " |
570 (interactive) | 570 (interactive) |
580 (make-local-variable 'comment-end) | 580 (make-local-variable 'comment-end) |
581 (setq comment-end "") | 581 (setq comment-end "") |
582 | 582 |
583 (make-local-variable 'comment-multi-line) | 583 (make-local-variable 'comment-multi-line) |
584 (setq comment-multi-line nil) | 584 (setq comment-multi-line nil) |
585 | 585 |
586 ;; This used to be "^\\$[ \t]*![ \t]*" which looks more correct. | 586 ;; This used to be "^\\$[ \t]*![ \t]*" which looks more correct. |
587 ;; The drawback was that you couldn't make empty comment lines by pressing | 587 ;; The drawback was that you couldn't make empty comment lines by pressing |
588 ;; C-M-j repeatedly - only the first line became a comment line. | 588 ;; C-M-j repeatedly - only the first line became a comment line. |
589 ;; This version has the drawback that the "$" can be anywhere in the line, | 589 ;; This version has the drawback that the "$" can be anywhere in the line, |
590 ;; and something inappropriate might be interpreted as a comment. | 590 ;; and something inappropriate might be interpreted as a comment. |
606 (make-local-variable 'dcl-tab-always-indent) | 606 (make-local-variable 'dcl-tab-always-indent) |
607 (make-local-variable 'dcl-electric-characters) | 607 (make-local-variable 'dcl-electric-characters) |
608 (make-local-variable 'dcl-calc-command-indent-function) | 608 (make-local-variable 'dcl-calc-command-indent-function) |
609 (make-local-variable 'dcl-calc-cont-indent-function) | 609 (make-local-variable 'dcl-calc-cont-indent-function) |
610 (make-local-variable 'dcl-electric-reindent-regexps) | 610 (make-local-variable 'dcl-electric-reindent-regexps) |
611 | 611 |
612 (setq major-mode 'dcl-mode) | 612 (setq major-mode 'dcl-mode) |
613 (setq mode-name "DCL") | 613 (setq mode-name "DCL") |
614 (use-local-map dcl-mode-map) | 614 (use-local-map dcl-mode-map) |
615 (tempo-use-tag-list 'dcl-tempo-tags) | 615 (tempo-use-tag-list 'dcl-tempo-tags) |
616 (run-hooks 'dcl-mode-hook)) | 616 (run-hooks 'dcl-mode-hook)) |
666 ;;;------------------------------------------------------------------------- | 666 ;;;------------------------------------------------------------------------- |
667 (defun dcl-backward-command (&optional incl-comment-commands) | 667 (defun dcl-backward-command (&optional incl-comment-commands) |
668 "Move backward to a command. | 668 "Move backward to a command. |
669 Move point to the preceding command line that is not a comment line, | 669 Move point to the preceding command line that is not a comment line, |
670 a command line with only a comment, only contains a `$' or only | 670 a command line with only a comment, only contains a `$' or only |
671 contains a label. | 671 contains a label. |
672 | 672 |
673 Returns point of the found command line or nil if not able to move." | 673 Returns point of the found command line or nil if not able to move." |
674 (interactive) | 674 (interactive) |
675 (let ((start (point)) | 675 (let ((start (point)) |
676 done | 676 done |
710 ;;;------------------------------------------------------------------------- | 710 ;;;------------------------------------------------------------------------- |
711 (defun dcl-forward-command (&optional incl-comment-commands) | 711 (defun dcl-forward-command (&optional incl-comment-commands) |
712 "Move forward to a command. | 712 "Move forward to a command. |
713 Move point to the end of the next command line that is not a comment line, | 713 Move point to the end of the next command line that is not a comment line, |
714 a command line with only a comment, only contains a `$' or only | 714 a command line with only a comment, only contains a `$' or only |
715 contains a label. | 715 contains a label. |
716 | 716 |
717 Returns point of the found command line or nil if not able to move." | 717 Returns point of the found command line or nil if not able to move." |
718 (interactive) | 718 (interactive) |
719 (let ((start (point)) | 719 (let ((start (point)) |
720 done | 720 done |
760 "Move point to the first non-whitespace character on this line. | 760 "Move point to the first non-whitespace character on this line. |
761 Leading $ and labels counts as whitespace in this case. | 761 Leading $ and labels counts as whitespace in this case. |
762 If this is a comment line then move to the first non-whitespace character | 762 If this is a comment line then move to the first non-whitespace character |
763 in the comment. | 763 in the comment. |
764 | 764 |
765 Typing \\[dcl-back-to-indentation] several times in a row will move point to other | 765 Typing \\[dcl-back-to-indentation] several times in a row will move point to other |
766 `interesting' points closer to the left margin, and then back to the | 766 `interesting' points closer to the left margin, and then back to the |
767 rightmost point again. | 767 rightmost point again. |
768 | 768 |
769 E.g. on the following line, point would go to the positions indicated | 769 E.g. on the following line, point would go to the positions indicated |
770 by the numbers in order 1-2-3-1-... : | 770 by the numbers in order 1-2-3-1-... : |
771 | 771 |
772 $ label: command | 772 $ label: command |
783 ;; 4 3 2 1 | 783 ;; 4 3 2 1 |
784 ;; | 784 ;; |
785 ;; $ ! text | 785 ;; $ ! text |
786 ;; 3 2 1 | 786 ;; 3 2 1 |
787 ;; | 787 ;; |
788 ;; $ l: command ! | 788 ;; $ l: command ! |
789 ;; 3 2 1 | 789 ;; 3 2 1 |
790 ;; | 790 ;; |
791 ;; text | 791 ;; text |
792 ;; 1 | 792 ;; 1 |
793 | 793 |
805 | 805 |
806 (if (< (point) limit) | 806 (if (< (point) limit) |
807 (setq last-good-point (point))) | 807 (setq last-good-point (point))) |
808 | 808 |
809 (cond | 809 (cond |
810 ;; Special treatment for comment lines. We are trying to allow | 810 ;; Special treatment for comment lines. We are trying to allow |
811 ;; things like "$ !*" as comment lines. | 811 ;; things like "$ !*" as comment lines. |
812 ((looking-at dcl-comment-line-regexp) | 812 ((looking-at dcl-comment-line-regexp) |
813 (re-search-forward (concat dcl-comment-line-regexp "[ \t]*") limit t) | 813 (re-search-forward (concat dcl-comment-line-regexp "[ \t]*") limit t) |
814 (if (< (point) limit) | 814 (if (< (point) limit) |
815 (setq last-good-point (point)))) | 815 (setq last-good-point (point)))) |
899 "Return point of first non-`whitespace' on this line." | 899 "Return point of first non-`whitespace' on this line." |
900 (save-excursion | 900 (save-excursion |
901 (dcl-back-to-indentation) | 901 (dcl-back-to-indentation) |
902 (point))) | 902 (point))) |
903 | 903 |
904 | 904 |
905 ;;;--------------------------------------------------------------------------- | 905 ;;;--------------------------------------------------------------------------- |
906 (defun dcl-show-line-type () | 906 (defun dcl-show-line-type () |
907 "Test dcl-get-line-type." | 907 "Test dcl-get-line-type." |
908 (interactive) | 908 (interactive) |
909 (let ((type (dcl-get-line-type))) | 909 (let ((type (dcl-get-line-type))) |
977 $ endif | 977 $ endif |
978 $ xxx | 978 $ xxx |
979 | 979 |
980 If you use this function you will probably want to add \"then\" to | 980 If you use this function you will probably want to add \"then\" to |
981 dcl-electric-reindent-regexps and define the key \"n\" as | 981 dcl-electric-reindent-regexps and define the key \"n\" as |
982 dcl-electric-character. | 982 dcl-electric-character. |
983 " | 983 " |
984 (let ((case-fold-search t)) | 984 (let ((case-fold-search t)) |
985 (save-excursion | 985 (save-excursion |
986 (cond | 986 (cond |
987 ;; No indentation, this word is `then': +2 | 987 ;; No indentation, this word is `then': +2 |
1001 (cond | 1001 (cond |
1002 ((looking-at "\\bthen\\b") | 1002 ((looking-at "\\bthen\\b") |
1003 (- (+ cur-indent extra-indent) 2)) | 1003 (- (+ cur-indent extra-indent) 2)) |
1004 ((looking-at "\\belse\\b") | 1004 ((looking-at "\\belse\\b") |
1005 (- (+ cur-indent extra-indent) 2)))) | 1005 (- (+ cur-indent extra-indent) 2)))) |
1006 ;; Outdent, this word is `endif' or `else': + 2 | 1006 ;; Outdent, this word is `endif' or `else': + 2 |
1007 ((equal indent-type 'outdent) | 1007 ((equal indent-type 'outdent) |
1008 (goto-char this-point) | 1008 (goto-char this-point) |
1009 (cond | 1009 (cond |
1010 ((looking-at "\\bendif\\b") | 1010 ((looking-at "\\bendif\\b") |
1011 (+ cur-indent extra-indent 2)) | 1011 (+ cur-indent extra-indent 2)) |
1026 method or by calling dcl-calc-command-indent-function if it is | 1026 method or by calling dcl-calc-command-indent-function if it is |
1027 non-nil. | 1027 non-nil. |
1028 | 1028 |
1029 If the current line should be outdented, calculate its indentation, | 1029 If the current line should be outdented, calculate its indentation, |
1030 either with the default method or by calling | 1030 either with the default method or by calling |
1031 dcl-calc-command-indent-function if it is non-nil. | 1031 dcl-calc-command-indent-function if it is non-nil. |
1032 | 1032 |
1033 | 1033 |
1034 Rules for default indentation: | 1034 Rules for default indentation: |
1035 | 1035 |
1036 If it is the first line in the buffer, indent dcl-margin-offset. | 1036 If it is the first line in the buffer, indent dcl-margin-offset. |
1037 | 1037 |
1038 Go to the previous command line with a command on it. | 1038 Go to the previous command line with a command on it. |
1039 Find out how much it is indented (cur-indent). | 1039 Find out how much it is indented (cur-indent). |
1040 Look at the first word on the line to see if the indentation should be | 1040 Look at the first word on the line to see if the indentation should be |
1041 adjusted. Skip margin-label, continuations and comments while looking for | 1041 adjusted. Skip margin-label, continuations and comments while looking for |
1042 the first word. Save this buffer position as `last-point'. | 1042 the first word. Save this buffer position as `last-point'. |
1043 If the first word after a label is SUBROUTINE, set extra-indent to | 1043 If the first word after a label is SUBROUTINE, set extra-indent to |
1044 dcl-margin-offset. | 1044 dcl-margin-offset. |
1045 | 1045 |
1046 First word extra-indent | 1046 First word extra-indent |
1047 THEN +dcl-basic-offset | 1047 THEN +dcl-basic-offset |
1048 ELSE +dcl-basic-offset | 1048 ELSE +dcl-basic-offset |
1049 block-begin +dcl-basic-offset | 1049 block-begin +dcl-basic-offset |
1050 | 1050 |
1051 Then return to the current line and look at the first word to see if the | 1051 Then return to the current line and look at the first word to see if the |
1052 indentation should be adjusted again. Save this buffer position as | 1052 indentation should be adjusted again. Save this buffer position as |
1053 `this-point'. | 1053 `this-point'. |
1054 | 1054 |
1055 First word extra-indent | 1055 First word extra-indent |
1056 ELSE -dcl-basic-offset | 1056 ELSE -dcl-basic-offset |
1057 ENDIF -dcl-basic-offset | 1057 ENDIF -dcl-basic-offset |
1058 block-end -dcl-basic-offset | 1058 block-end -dcl-basic-offset |
1061 If dcl-calc-command-indent-function is nil or returns nil set | 1061 If dcl-calc-command-indent-function is nil or returns nil set |
1062 cur-indent to cur-indent+extra-indent. | 1062 cur-indent to cur-indent+extra-indent. |
1063 | 1063 |
1064 If an extra adjustment is necessary and if | 1064 If an extra adjustment is necessary and if |
1065 dcl-calc-command-indent-function is nil or returns nil set cur-indent | 1065 dcl-calc-command-indent-function is nil or returns nil set cur-indent |
1066 to cur-indent+extra-indent. | 1066 to cur-indent+extra-indent. |
1067 | 1067 |
1068 See also documentation for dcl-calc-command-indent-function. | 1068 See also documentation for dcl-calc-command-indent-function. |
1069 The indent-type classification could probably be expanded upon. | 1069 The indent-type classification could probably be expanded upon. |
1070 " | 1070 " |
1071 () | 1071 () |
1104 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r "$"))) | 1104 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r "$"))) |
1105 (setq done t))) ; not a label-only line, exit the loop | 1105 (setq done t))) ; not a label-only line, exit the loop |
1106 ;; We couldn't go further back, so this must have been the | 1106 ;; We couldn't go further back, so this must have been the |
1107 ;; first line. | 1107 ;; first line. |
1108 (setq cur-indent dcl-margin-offset | 1108 (setq cur-indent dcl-margin-offset |
1109 last-point (dcl-indentation-point)) | 1109 last-point (dcl-indentation-point)) |
1110 (setq done t))) | 1110 (setq done t))) |
1111 ;; Examine the line to get current indentation and possibly a | 1111 ;; Examine the line to get current indentation and possibly a |
1112 ;; reason to indent. | 1112 ;; reason to indent. |
1113 (cond | 1113 (cond |
1114 (cur-indent) | 1114 (cur-indent) |
1200 $ if ((a.eq.b .and. - | 1200 $ if ((a.eq.b .and. - |
1201 d.eq.c .or. f$function(xxxx, - | 1201 d.eq.c .or. f$function(xxxx, - |
1202 yyy))) | 1202 yyy))) |
1203 " | 1203 " |
1204 (let ((case-fold-search t) | 1204 (let ((case-fold-search t) |
1205 indent) | 1205 indent) |
1206 (save-excursion | 1206 (save-excursion |
1207 (dcl-beginning-of-statement) | 1207 (dcl-beginning-of-statement) |
1208 (let ((end (save-excursion (forward-line 1) (point)))) | 1208 (let ((end (save-excursion (forward-line 1) (point)))) |
1209 ;; Move over blanks and label | 1209 ;; Move over blanks and label |
1210 (if (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r | 1210 (if (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r |
1219 (progn | 1219 (progn |
1220 (setq was-assignment t) | 1220 (setq was-assignment t) |
1221 (skip-chars-forward " \t:=" end))) | 1221 (skip-chars-forward " \t:=" end))) |
1222 ;; This could be the position to indent to | 1222 ;; This could be the position to indent to |
1223 (setq indent (current-column)) | 1223 (setq indent (current-column)) |
1224 | 1224 |
1225 ;; Move to the next word unless we have seen an | 1225 ;; Move to the next word unless we have seen an |
1226 ;; assignment. If it starts with `/' it's a | 1226 ;; assignment. If it starts with `/' it's a |
1227 ;; qualifier and we will indent to that position | 1227 ;; qualifier and we will indent to that position |
1228 (if (and (not was-assignment) | 1228 (if (and (not was-assignment) |
1229 (> (skip-chars-forward "a-zA-Z0-9_" end) 0)) | 1229 (> (skip-chars-forward "a-zA-Z0-9_" end) 0)) |
1326 (progn | 1326 (progn |
1327 (dcl-indent-to dcl-margin-label-offset) | 1327 (dcl-indent-to dcl-margin-label-offset) |
1328 (re-search-forward dcl-label-r))) | 1328 (re-search-forward dcl-label-r))) |
1329 (dcl-indent-to indent 1) | 1329 (dcl-indent-to indent 1) |
1330 ) | 1330 ) |
1331 ;; | 1331 ;; |
1332 (if (> (- (point-max) pos) (point)) | 1332 (if (> (- (point-max) pos) (point)) |
1333 (goto-char (- (point-max) pos))) | 1333 (goto-char (- (point-max) pos))) |
1334 )) | 1334 )) |
1335 | 1335 |
1336 | 1336 |
1374 (insert "$" ) | 1374 (insert "$" ) |
1375 (dcl-indent-command-line)) | 1375 (dcl-indent-command-line)) |
1376 (t | 1376 (t |
1377 (message "dcl-indent-line: unknown type")) | 1377 (message "dcl-indent-line: unknown type")) |
1378 ))) | 1378 ))) |
1379 | 1379 |
1380 | 1380 |
1381 ;;;------------------------------------------------------------------------- | 1381 ;;;------------------------------------------------------------------------- |
1382 (defun dcl-indent-command () | 1382 (defun dcl-indent-command () |
1383 "Indents the complete command line that point is on. | 1383 "Indents the complete command line that point is on. |
1384 This includes continuation lines." | 1384 This includes continuation lines." |
1404 (interactive "*") | 1404 (interactive "*") |
1405 (let ((type (dcl-get-line-type)) | 1405 (let ((type (dcl-get-line-type)) |
1406 (start-point (point))) | 1406 (start-point (point))) |
1407 (cond | 1407 (cond |
1408 ;; Data line : always insert tab | 1408 ;; Data line : always insert tab |
1409 ((or (equal type 'data) (equal type 'empty-data)) | 1409 ((or (equal type 'data) (equal type 'empty-data)) |
1410 (tab-to-tab-stop)) | 1410 (tab-to-tab-stop)) |
1411 ;; Indent only at start of line | 1411 ;; Indent only at start of line |
1412 ((not dcl-tab-always-indent) ; nil | 1412 ((not dcl-tab-always-indent) ; nil |
1413 (let ((search-end-point | 1413 (let ((search-end-point |
1414 (save-excursion | 1414 (save-excursion |
1415 (beginning-of-line) | 1415 (beginning-of-line) |
1416 (re-search-forward "^\\$?[ \t]*" start-point t)))) | 1416 (re-search-forward "^\\$?[ \t]*" start-point t)))) |
1426 | 1426 |
1427 | 1427 |
1428 ;;;------------------------------------------------------------------------- | 1428 ;;;------------------------------------------------------------------------- |
1429 (defun dcl-electric-character (arg) | 1429 (defun dcl-electric-character (arg) |
1430 "Inserts a character and indents if necessary. | 1430 "Inserts a character and indents if necessary. |
1431 Insert a character if the user gave a numeric argument or the flag | 1431 Insert a character if the user gave a numeric argument or the flag |
1432 `dcl-electric-characters' is not set. If an argument was given, | 1432 `dcl-electric-characters' is not set. If an argument was given, |
1433 insert that many characters. | 1433 insert that many characters. |
1434 | 1434 |
1435 The line is only reindented if the word just typed matches any of the | 1435 The line is only reindented if the word just typed matches any of the |
1436 regexps in `dcl-electric-reindent-regexps'." | 1436 regexps in `dcl-electric-reindent-regexps'." |
1441 (self-insert-command 1)) | 1441 (self-insert-command 1)) |
1442 ;; Insert the character and indent | 1442 ;; Insert the character and indent |
1443 (self-insert-command 1) | 1443 (self-insert-command 1) |
1444 (let ((case-fold-search t)) | 1444 (let ((case-fold-search t)) |
1445 ;; There must be a better way than (memq t ...). | 1445 ;; There must be a better way than (memq t ...). |
1446 ;; (apply 'or ...) didn't work | 1446 ;; (apply 'or ...) didn't work |
1447 (if (memq t (mapcar 'dcl-was-looking-at dcl-electric-reindent-regexps)) | 1447 (if (memq t (mapcar 'dcl-was-looking-at dcl-electric-reindent-regexps)) |
1448 (dcl-indent-line))))) | 1448 (dcl-indent-line))))) |
1449 | 1449 |
1450 | 1450 |
1451 ;;;------------------------------------------------------------------------- | 1451 ;;;------------------------------------------------------------------------- |
1461 (setq indent (max col (+ collapsed (or minimum 0)))) | 1461 (setq indent (max col (+ collapsed (or minimum 0)))) |
1462 (if (/= indent cur-indent) | 1462 (if (/= indent cur-indent) |
1463 (progn | 1463 (progn |
1464 (dcl-delete-chars " \t") | 1464 (dcl-delete-chars " \t") |
1465 (indent-to col minimum))))) | 1465 (indent-to col minimum))))) |
1466 | 1466 |
1467 | 1467 |
1468 ;;;------------------------------------------------------------------------- | 1468 ;;;------------------------------------------------------------------------- |
1469 (defun dcl-split-line () | 1469 (defun dcl-split-line () |
1470 "Break line at point and insert text to keep the syntax valid. | 1470 "Break line at point and insert text to keep the syntax valid. |
1471 | 1471 |
1509 )))) | 1509 )))) |
1510 ;; use the normal function for other cases | 1510 ;; use the normal function for other cases |
1511 (if (not done) ; normal M-LFD action | 1511 (if (not done) ; normal M-LFD action |
1512 (indent-new-comment-line)))) | 1512 (indent-new-comment-line)))) |
1513 | 1513 |
1514 | 1514 |
1515 ;;;------------------------------------------------------------------------- | 1515 ;;;------------------------------------------------------------------------- |
1516 (defun dcl-delete-indentation (&optional arg) | 1516 (defun dcl-delete-indentation (&optional arg) |
1517 "Join this line to previous like delete-indentation. | 1517 "Join this line to previous like delete-indentation. |
1518 Also remove the continuation mark if easily detected." | 1518 Also remove the continuation mark if easily detected." |
1519 (interactive "*P") | 1519 (interactive "*P") |
1580 | 1580 |
1581 ;;;------------------------------------------------------------------------- | 1581 ;;;------------------------------------------------------------------------- |
1582 (defun dcl-option-value-margin-offset (option-assoc) | 1582 (defun dcl-option-value-margin-offset (option-assoc) |
1583 "Guess a value for margin offset. | 1583 "Guess a value for margin offset. |
1584 Find the column of the first non-blank character on the line, not | 1584 Find the column of the first non-blank character on the line, not |
1585 counting labels. | 1585 counting labels. |
1586 Returns a number as a string." | 1586 Returns a number as a string." |
1587 (save-excursion | 1587 (save-excursion |
1588 (beginning-of-line) | 1588 (beginning-of-line) |
1589 (dcl-back-to-indentation) | 1589 (dcl-back-to-indentation) |
1590 (current-column))) | 1590 (current-column))) |
1608 ;; suggesting it. | 1608 ;; suggesting it. |
1609 (if (looking-at "^\\$[^!\n]*!") | 1609 (if (looking-at "^\\$[^!\n]*!") |
1610 (let ((regexp (buffer-substring (match-beginning 0) (match-end 0)))) | 1610 (let ((regexp (buffer-substring (match-beginning 0) (match-end 0)))) |
1611 (concat "^" (regexp-quote regexp))) | 1611 (concat "^" (regexp-quote regexp))) |
1612 dcl-comment-line-regexp)))) | 1612 dcl-comment-line-regexp)))) |
1613 | 1613 |
1614 | 1614 |
1615 ;;;------------------------------------------------------------------------- | 1615 ;;;------------------------------------------------------------------------- |
1616 (defun dcl-guess-option-value (option) | 1616 (defun dcl-guess-option-value (option) |
1617 "Guess what value the user would like to give the symbol option." | 1617 "Guess what value the user would like to give the symbol option." |
1618 (let* ((option-assoc (assoc option dcl-option-alist)) | 1618 (let* ((option-assoc (assoc option dcl-option-alist)) |
1699 (or (and prev-indent ; last cmd is indented differently | 1699 (or (and prev-indent ; last cmd is indented differently |
1700 (/= (- this-indent prev-indent) 0)) | 1700 (/= (- this-indent prev-indent) 0)) |
1701 (and next-indent | 1701 (and next-indent |
1702 (/= (- this-indent next-indent) 0)))))) | 1702 (/= (- this-indent next-indent) 0)))))) |
1703 "dcl-basic-offset") | 1703 "dcl-basic-offset") |
1704 ;; No more guesses. | 1704 ;; No more guesses. |
1705 (t | 1705 (t |
1706 "")))) | 1706 "")))) |
1707 | 1707 |
1708 | 1708 |
1709 ;;;------------------------------------------------------------------------- | 1709 ;;;------------------------------------------------------------------------- |
1737 | 1737 |
1738 | 1738 |
1739 ;;;------------------------------------------------------------------------- | 1739 ;;;------------------------------------------------------------------------- |
1740 (defun dcl-save-local-variable (var &optional def-prefix def-suffix) | 1740 (defun dcl-save-local-variable (var &optional def-prefix def-suffix) |
1741 "Save a variable in a `Local Variables' list. | 1741 "Save a variable in a `Local Variables' list. |
1742 Set or update the value of VAR in the current buffers | 1742 Set or update the value of VAR in the current buffers |
1743 `Local Variables:' list." | 1743 `Local Variables:' list." |
1744 ;; Look for "Local variables:" line in last page. | 1744 ;; Look for "Local variables:" line in last page. |
1745 (save-excursion | 1745 (save-excursion |
1746 (goto-char (point-max)) | 1746 (goto-char (point-max)) |
1747 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) | 1747 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) |
1748 (if (let ((case-fold-search t)) | 1748 (if (let ((case-fold-search t)) |
1788 (if (string-equal (downcase str) "end") | 1788 (if (string-equal (downcase str) "end") |
1789 (progn | 1789 (progn |
1790 ;; Not found. Insert a new entry before this line | 1790 ;; Not found. Insert a new entry before this line |
1791 (setq continue nil) | 1791 (setq continue nil) |
1792 (beginning-of-line) | 1792 (beginning-of-line) |
1793 (insert (concat prefix-string (symbol-name var) ": " | 1793 (insert (concat prefix-string (symbol-name var) ": " |
1794 (prin1-to-string (eval var)) " " | 1794 (prin1-to-string (eval var)) " " |
1795 suffix-string "\n"))) | 1795 suffix-string "\n"))) |
1796 ;; Is it the variable we are looking for? | 1796 ;; Is it the variable we are looking for? |
1797 (if (eq var found-var) | 1797 (if (eq var found-var) |
1798 (progn | 1798 (progn |
1834 (if (or (equal comment-end "") | 1834 (if (or (equal comment-end "") |
1835 (string-match "^[ \t]" comment-end)) | 1835 (string-match "^[ \t]" comment-end)) |
1836 comment-end | 1836 comment-end |
1837 (concat " " comment-end)))))) | 1837 (concat " " comment-end)))))) |
1838 (insert (concat def-prefix "Local variables:" def-suffix "\n")) | 1838 (insert (concat def-prefix "Local variables:" def-suffix "\n")) |
1839 (insert (concat def-prefix (symbol-name var) ": " | 1839 (insert (concat def-prefix (symbol-name var) ": " |
1840 (prin1-to-string (eval var)) def-suffix "\n")) | 1840 (prin1-to-string (eval var)) def-suffix "\n")) |
1841 (insert (concat def-prefix "end:" def-suffix))) | 1841 (insert (concat def-prefix "end:" def-suffix))) |
1842 ))) | 1842 ))) |
1843 | 1843 |
1844 | 1844 |
1907 | 1907 |
1908 | 1908 |
1909 (require 'tempo) | 1909 (require 'tempo) |
1910 (defvar dcl-tempo-tags nil | 1910 (defvar dcl-tempo-tags nil |
1911 "Tempo tags for DCL mode.") | 1911 "Tempo tags for DCL mode.") |
1912 | 1912 |
1913 (tempo-define-template "dcl-f$context" | 1913 (tempo-define-template "dcl-f$context" |
1914 '("f$context" dcl-tempo-left-paren | 1914 '("f$context" dcl-tempo-left-paren |
1915 (p "context-type: ") dcl-tempo-comma | 1915 (p "context-type: ") dcl-tempo-comma |
1916 (p "context-symbol: ") dcl-tempo-comma | 1916 (p "context-symbol: ") dcl-tempo-comma |
1917 (p "selection-item: ") dcl-tempo-comma | 1917 (p "selection-item: ") dcl-tempo-comma |
1918 (p "selection-value: ") dcl-tempo-comma | 1918 (p "selection-value: ") dcl-tempo-comma |
1919 (p "value-qualifier: ") dcl-tempo-right-paren) | 1919 (p "value-qualifier: ") dcl-tempo-right-paren) |
1920 "f$context" "" 'dcl-tempo-tags) | 1920 "f$context" "" 'dcl-tempo-tags) |
1921 | 1921 |
1922 (tempo-define-template "dcl-f$csid" | 1922 (tempo-define-template "dcl-f$csid" |
1923 '("f$csid" dcl-tempo-left-paren | 1923 '("f$csid" dcl-tempo-left-paren |
1924 (p "context-symbol: ") dcl-tempo-right-paren) | 1924 (p "context-symbol: ") dcl-tempo-right-paren) |
1925 "f$csid" "" 'dcl-tempo-tags) | 1925 "f$csid" "" 'dcl-tempo-tags) |
1926 | 1926 |
1927 (tempo-define-template "dcl-f$cvsi" | 1927 (tempo-define-template "dcl-f$cvsi" |
1928 '("f$cvsi" dcl-tempo-left-paren | 1928 '("f$cvsi" dcl-tempo-left-paren |
1929 (p "start-bit: ") dcl-tempo-comma | 1929 (p "start-bit: ") dcl-tempo-comma |
1930 (p "number-of-bits: ") dcl-tempo-comma | 1930 (p "number-of-bits: ") dcl-tempo-comma |
1931 (p "string: ") dcl-tempo-right-paren) | 1931 (p "string: ") dcl-tempo-right-paren) |
1932 "f$cvsi" "" 'dcl-tempo-tags) | 1932 "f$cvsi" "" 'dcl-tempo-tags) |
1933 | 1933 |
1934 (tempo-define-template "dcl-f$cvtime" | 1934 (tempo-define-template "dcl-f$cvtime" |
1935 '("f$cvtime" dcl-tempo-left-paren | 1935 '("f$cvtime" dcl-tempo-left-paren |
1936 (p "[input_time]: ") dcl-tempo-comma | 1936 (p "[input_time]: ") dcl-tempo-comma |
1937 (p "[output_time_format]: ") dcl-tempo-comma | 1937 (p "[output_time_format]: ") dcl-tempo-comma |
1938 (p "[output_field]: ") dcl-tempo-right-paren) | 1938 (p "[output_field]: ") dcl-tempo-right-paren) |
1939 "f$cvtime" "" 'dcl-tempo-tags) | 1939 "f$cvtime" "" 'dcl-tempo-tags) |
1940 | 1940 |
1941 (tempo-define-template "dcl-f$cvui" | 1941 (tempo-define-template "dcl-f$cvui" |
1942 '("f$cvui" dcl-tempo-left-paren | 1942 '("f$cvui" dcl-tempo-left-paren |
1943 (p "start-bit: ") dcl-tempo-comma | 1943 (p "start-bit: ") dcl-tempo-comma |
1944 (p "number-of-bits: ") dcl-tempo-comma | 1944 (p "number-of-bits: ") dcl-tempo-comma |
1945 (p "string") dcl-tempo-right-paren) | 1945 (p "string") dcl-tempo-right-paren) |
1946 "f$cvui" "" 'dcl-tempo-tags) | 1946 "f$cvui" "" 'dcl-tempo-tags) |
1947 | 1947 |
1948 (tempo-define-template "dcl-f$device" | 1948 (tempo-define-template "dcl-f$device" |
1949 '("f$device" dcl-tempo-left-paren | 1949 '("f$device" dcl-tempo-left-paren |
1950 (p "[search_devnam]: ") dcl-tempo-comma | 1950 (p "[search_devnam]: ") dcl-tempo-comma |
1951 (p "[devclass]: ") dcl-tempo-comma | 1951 (p "[devclass]: ") dcl-tempo-comma |
1952 (p "[devtype]: ") dcl-tempo-comma | 1952 (p "[devtype]: ") dcl-tempo-comma |
1953 (p "[stream-id]: ") dcl-tempo-right-paren) | 1953 (p "[stream-id]: ") dcl-tempo-right-paren) |
1954 "f$device" "" 'dcl-tempo-tags) | 1954 "f$device" "" 'dcl-tempo-tags) |
1957 '("f$directory" dcl-tempo-left-paren | 1957 '("f$directory" dcl-tempo-left-paren |
1958 dcl-tempo-right-paren) | 1958 dcl-tempo-right-paren) |
1959 "f$directory" "" 'dcl-tempo-tags) | 1959 "f$directory" "" 'dcl-tempo-tags) |
1960 | 1960 |
1961 (tempo-define-template "dcl-f$edit" | 1961 (tempo-define-template "dcl-f$edit" |
1962 '("f$edit" dcl-tempo-left-paren | 1962 '("f$edit" dcl-tempo-left-paren |
1963 (p "string: ") dcl-tempo-comma | 1963 (p "string: ") dcl-tempo-comma |
1964 (p "edit-list: ") dcl-tempo-right-paren) | 1964 (p "edit-list: ") dcl-tempo-right-paren) |
1965 "f$edit" "" 'dcl-tempo-tags) | 1965 "f$edit" "" 'dcl-tempo-tags) |
1966 | 1966 |
1967 (tempo-define-template "dcl-f$element" | 1967 (tempo-define-template "dcl-f$element" |
1968 '("f$element" dcl-tempo-left-paren | 1968 '("f$element" dcl-tempo-left-paren |
1969 (p "element-number: ") dcl-tempo-comma | 1969 (p "element-number: ") dcl-tempo-comma |
1970 (p "delimiter: ") dcl-tempo-comma | 1970 (p "delimiter: ") dcl-tempo-comma |
1971 (p "string: ") dcl-tempo-right-paren) | 1971 (p "string: ") dcl-tempo-right-paren) |
1972 "f$element" "" 'dcl-tempo-tags) | 1972 "f$element" "" 'dcl-tempo-tags) |
1973 | 1973 |
1974 (tempo-define-template "dcl-f$environment" | 1974 (tempo-define-template "dcl-f$environment" |
1975 '("f$environment" dcl-tempo-left-paren | 1975 '("f$environment" dcl-tempo-left-paren |
1976 (p "item: ") dcl-tempo-right-paren) | 1976 (p "item: ") dcl-tempo-right-paren) |
1977 "f$environment" "" 'dcl-tempo-tags) | 1977 "f$environment" "" 'dcl-tempo-tags) |
1978 | 1978 |
1979 (tempo-define-template "dcl-f$extract" | 1979 (tempo-define-template "dcl-f$extract" |
1980 '("f$extract" dcl-tempo-left-paren | 1980 '("f$extract" dcl-tempo-left-paren |
1981 (p "start: ") dcl-tempo-comma | 1981 (p "start: ") dcl-tempo-comma |
1982 (p "length: ") dcl-tempo-comma | 1982 (p "length: ") dcl-tempo-comma |
1983 (p "string: ") dcl-tempo-right-paren) | 1983 (p "string: ") dcl-tempo-right-paren) |
1984 "f$extract" "" 'dcl-tempo-tags) | 1984 "f$extract" "" 'dcl-tempo-tags) |
1985 | 1985 |
1986 (tempo-define-template "dcl-f$fao" | 1986 (tempo-define-template "dcl-f$fao" |
1987 '("f$fao" dcl-tempo-left-paren | 1987 '("f$fao" dcl-tempo-left-paren |
1988 (p "control-string: ") dcl-tempo-comma | 1988 (p "control-string: ") dcl-tempo-comma |
1989 ("argument[,...]: ") dcl-tempo-right-paren) | 1989 ("argument[,...]: ") dcl-tempo-right-paren) |
1990 "f$fao" "" 'dcl-tempo-tags) | 1990 "f$fao" "" 'dcl-tempo-tags) |
1991 | 1991 |
1992 (tempo-define-template "dcl-f$file_attributes" | 1992 (tempo-define-template "dcl-f$file_attributes" |
1993 '("f$file_attributes" dcl-tempo-left-paren | 1993 '("f$file_attributes" dcl-tempo-left-paren |
1994 (p "filespec: ") dcl-tempo-comma | 1994 (p "filespec: ") dcl-tempo-comma |
1995 (p "item: ") dcl-tempo-right-paren) | 1995 (p "item: ") dcl-tempo-right-paren) |
1996 "f$file_attributes" "" 'dcl-tempo-tags) | 1996 "f$file_attributes" "" 'dcl-tempo-tags) |
1997 | 1997 |
1998 (tempo-define-template "dcl-f$getdvi" | 1998 (tempo-define-template "dcl-f$getdvi" |
1999 '("f$getdvi" dcl-tempo-left-paren | 1999 '("f$getdvi" dcl-tempo-left-paren |
2000 (p "device-name: ") dcl-tempo-comma | 2000 (p "device-name: ") dcl-tempo-comma |
2001 (p "item: ") dcl-tempo-right-paren) | 2001 (p "item: ") dcl-tempo-right-paren) |
2002 "f$getdvi" "" 'dcl-tempo-tags) | 2002 "f$getdvi" "" 'dcl-tempo-tags) |
2003 | 2003 |
2004 (tempo-define-template "dcl-f$getjpi" | 2004 (tempo-define-template "dcl-f$getjpi" |
2005 '("f$getjpi" dcl-tempo-left-paren | 2005 '("f$getjpi" dcl-tempo-left-paren |
2006 (p "pid: ") dcl-tempo-comma | 2006 (p "pid: ") dcl-tempo-comma |
2007 (p "item: ") dcl-tempo-right-paren ) | 2007 (p "item: ") dcl-tempo-right-paren ) |
2008 "f$getjpi" "" 'dcl-tempo-tags) | 2008 "f$getjpi" "" 'dcl-tempo-tags) |
2009 | 2009 |
2010 (tempo-define-template "dcl-f$getqui" | 2010 (tempo-define-template "dcl-f$getqui" |
2011 '("f$getqui" dcl-tempo-left-paren | 2011 '("f$getqui" dcl-tempo-left-paren |
2012 (p "function: ") dcl-tempo-comma | 2012 (p "function: ") dcl-tempo-comma |
2013 (p "[item]: ") dcl-tempo-comma | 2013 (p "[item]: ") dcl-tempo-comma |
2014 (p "[object-id]: ") dcl-tempo-comma | 2014 (p "[object-id]: ") dcl-tempo-comma |
2015 (p "[flags]: ") dcl-tempo-right-paren) | 2015 (p "[flags]: ") dcl-tempo-right-paren) |
2016 "f$getqui" "" 'dcl-tempo-tags) | 2016 "f$getqui" "" 'dcl-tempo-tags) |
2017 | 2017 |
2018 (tempo-define-template "dcl-f$getsyi" | 2018 (tempo-define-template "dcl-f$getsyi" |
2019 '("f$getsyi" dcl-tempo-left-paren | 2019 '("f$getsyi" dcl-tempo-left-paren |
2020 (p "item: ") dcl-tempo-comma | 2020 (p "item: ") dcl-tempo-comma |
2021 (p "[node-name]: ") dcl-tempo-comma | 2021 (p "[node-name]: ") dcl-tempo-comma |
2022 (p "[cluster-id]: ") dcl-tempo-right-paren) | 2022 (p "[cluster-id]: ") dcl-tempo-right-paren) |
2023 "f$getsyi" "" 'dcl-tempo-tags) | 2023 "f$getsyi" "" 'dcl-tempo-tags) |
2024 | 2024 |
2025 (tempo-define-template "dcl-f$identifier" | 2025 (tempo-define-template "dcl-f$identifier" |
2026 '("f$identifier" dcl-tempo-left-paren | 2026 '("f$identifier" dcl-tempo-left-paren |
2027 (p "identifier: ") dcl-tempo-comma | 2027 (p "identifier: ") dcl-tempo-comma |
2028 (p "conversion-type: ") dcl-tempo-right-paren) | 2028 (p "conversion-type: ") dcl-tempo-right-paren) |
2029 "f$identifier" "" 'dcl-tempo-tags) | 2029 "f$identifier" "" 'dcl-tempo-tags) |
2030 | 2030 |
2031 (tempo-define-template "dcl-f$integer" | 2031 (tempo-define-template "dcl-f$integer" |
2032 '("f$integer" dcl-tempo-left-paren | 2032 '("f$integer" dcl-tempo-left-paren |
2033 (p "expression: ") dcl-tempo-right-paren) | 2033 (p "expression: ") dcl-tempo-right-paren) |
2034 "f$integer" "" 'dcl-tempo-tags) | 2034 "f$integer" "" 'dcl-tempo-tags) |
2035 | 2035 |
2036 (tempo-define-template "dcl-f$length" | 2036 (tempo-define-template "dcl-f$length" |
2037 '("f$length" dcl-tempo-left-paren | 2037 '("f$length" dcl-tempo-left-paren |
2038 (p "string: ") dcl-tempo-right-paren ) | 2038 (p "string: ") dcl-tempo-right-paren ) |
2039 "f$length" "" 'dcl-tempo-tags) | 2039 "f$length" "" 'dcl-tempo-tags) |
2040 | 2040 |
2041 (tempo-define-template "dcl-f$locate" | 2041 (tempo-define-template "dcl-f$locate" |
2042 '("f$locate" dcl-tempo-left-paren | 2042 '("f$locate" dcl-tempo-left-paren |
2043 (p "substring: ") dcl-tempo-comma | 2043 (p "substring: ") dcl-tempo-comma |
2044 (p "string: ") dcl-tempo-right-paren) | 2044 (p "string: ") dcl-tempo-right-paren) |
2045 "f$locate" "" 'dcl-tempo-tags) | 2045 "f$locate" "" 'dcl-tempo-tags) |
2046 | 2046 |
2047 (tempo-define-template "dcl-f$message" | 2047 (tempo-define-template "dcl-f$message" |
2048 '("f$message" dcl-tempo-left-paren | 2048 '("f$message" dcl-tempo-left-paren |
2049 (p "status-code: ") dcl-tempo-right-paren ) | 2049 (p "status-code: ") dcl-tempo-right-paren ) |
2050 "f$message" "" 'dcl-tempo-tags) | 2050 "f$message" "" 'dcl-tempo-tags) |
2051 | 2051 |
2052 (tempo-define-template "dcl-f$mode" | 2052 (tempo-define-template "dcl-f$mode" |
2053 '("f$mode" dcl-tempo-left-paren dcl-tempo-right-paren) | 2053 '("f$mode" dcl-tempo-left-paren dcl-tempo-right-paren) |
2054 "f$mode" "" 'dcl-tempo-tags) | 2054 "f$mode" "" 'dcl-tempo-tags) |
2055 | 2055 |
2056 (tempo-define-template "dcl-f$parse" | 2056 (tempo-define-template "dcl-f$parse" |
2057 '("f$parse" dcl-tempo-left-paren | 2057 '("f$parse" dcl-tempo-left-paren |
2058 (p "filespec: ") dcl-tempo-comma | 2058 (p "filespec: ") dcl-tempo-comma |
2059 (p "[default-spec]: ") dcl-tempo-comma | 2059 (p "[default-spec]: ") dcl-tempo-comma |
2060 (p "[related-spec]: ") dcl-tempo-comma | 2060 (p "[related-spec]: ") dcl-tempo-comma |
2061 (p "[field]: ") dcl-tempo-comma | 2061 (p "[field]: ") dcl-tempo-comma |
2062 (p "[parse-type]: ") dcl-tempo-right-paren) | 2062 (p "[parse-type]: ") dcl-tempo-right-paren) |
2063 "f$parse" "" 'dcl-tempo-tags) | 2063 "f$parse" "" 'dcl-tempo-tags) |
2064 | 2064 |
2065 (tempo-define-template "dcl-f$pid" | 2065 (tempo-define-template "dcl-f$pid" |
2066 '("f$pid" dcl-tempo-left-paren | 2066 '("f$pid" dcl-tempo-left-paren |
2067 (p "context-symbol: ") dcl-tempo-right-paren) | 2067 (p "context-symbol: ") dcl-tempo-right-paren) |
2068 "f$pid" "" 'dcl-tempo-tags) | 2068 "f$pid" "" 'dcl-tempo-tags) |
2069 | 2069 |
2070 (tempo-define-template "dcl-f$privilege" | 2070 (tempo-define-template "dcl-f$privilege" |
2071 '("f$privilege" dcl-tempo-left-paren | 2071 '("f$privilege" dcl-tempo-left-paren |
2072 (p "priv-states: ") dcl-tempo-right-paren) | 2072 (p "priv-states: ") dcl-tempo-right-paren) |
2073 "f$privilege" "" 'dcl-tempo-tags) | 2073 "f$privilege" "" 'dcl-tempo-tags) |
2074 | 2074 |
2075 (tempo-define-template "dcl-f$process" | 2075 (tempo-define-template "dcl-f$process" |
2076 '("f$process()") | 2076 '("f$process()") |
2077 "f$process" "" 'dcl-tempo-tags) | 2077 "f$process" "" 'dcl-tempo-tags) |
2078 | 2078 |
2079 (tempo-define-template "dcl-f$search" | 2079 (tempo-define-template "dcl-f$search" |
2080 '("f$search" dcl-tempo-left-paren | 2080 '("f$search" dcl-tempo-left-paren |
2081 (p "filespec: ") dcl-tempo-comma | 2081 (p "filespec: ") dcl-tempo-comma |
2082 (p "[stream-id]: ") dcl-tempo-right-paren) | 2082 (p "[stream-id]: ") dcl-tempo-right-paren) |
2083 "f$search" "" 'dcl-tempo-tags) | 2083 "f$search" "" 'dcl-tempo-tags) |
2084 | 2084 |
2085 (tempo-define-template "dcl-f$setprv" | 2085 (tempo-define-template "dcl-f$setprv" |
2086 '("f$setprv" dcl-tempo-left-paren | 2086 '("f$setprv" dcl-tempo-left-paren |
2087 (p "priv-states: ") dcl-tempo-right-paren) | 2087 (p "priv-states: ") dcl-tempo-right-paren) |
2088 "f$setprv" "" 'dcl-tempo-tags) | 2088 "f$setprv" "" 'dcl-tempo-tags) |
2089 | 2089 |
2090 (tempo-define-template "dcl-f$string" | 2090 (tempo-define-template "dcl-f$string" |
2091 '("f$string" dcl-tempo-left-paren | 2091 '("f$string" dcl-tempo-left-paren |
2092 (p "expression: ") dcl-tempo-right-paren) | 2092 (p "expression: ") dcl-tempo-right-paren) |
2093 "f$string" "" 'dcl-tempo-tags) | 2093 "f$string" "" 'dcl-tempo-tags) |
2094 | 2094 |
2095 (tempo-define-template "dcl-f$time" | 2095 (tempo-define-template "dcl-f$time" |
2096 '("f$time" dcl-tempo-left-paren dcl-tempo-right-paren) | 2096 '("f$time" dcl-tempo-left-paren dcl-tempo-right-paren) |
2097 "f$time" "" 'dcl-tempo-tags) | 2097 "f$time" "" 'dcl-tempo-tags) |
2098 | 2098 |
2099 (tempo-define-template "dcl-f$trnlnm" | 2099 (tempo-define-template "dcl-f$trnlnm" |
2100 '("f$trnlnm" dcl-tempo-left-paren | 2100 '("f$trnlnm" dcl-tempo-left-paren |
2101 (p "logical-name: ") dcl-tempo-comma | 2101 (p "logical-name: ") dcl-tempo-comma |
2102 (p "[table]: ") dcl-tempo-comma | 2102 (p "[table]: ") dcl-tempo-comma |
2103 (p "[index]: ") dcl-tempo-comma | 2103 (p "[index]: ") dcl-tempo-comma |
2104 (p "[mode]: ") dcl-tempo-comma | 2104 (p "[mode]: ") dcl-tempo-comma |
2105 (p "[case]: ") dcl-tempo-comma | 2105 (p "[case]: ") dcl-tempo-comma |
2106 (p "[item]: ") dcl-tempo-right-paren) | 2106 (p "[item]: ") dcl-tempo-right-paren) |
2107 "f$trnlnm" "" 'dcl-tempo-tags) | 2107 "f$trnlnm" "" 'dcl-tempo-tags) |
2108 | 2108 |
2109 (tempo-define-template "dcl-f$type" | 2109 (tempo-define-template "dcl-f$type" |
2110 '("f$type" dcl-tempo-left-paren | 2110 '("f$type" dcl-tempo-left-paren |
2111 (p "symbol-name: ") dcl-tempo-right-paren) | 2111 (p "symbol-name: ") dcl-tempo-right-paren) |
2112 "f$type" "" 'dcl-tempo-tags) | 2112 "f$type" "" 'dcl-tempo-tags) |
2113 | 2113 |
2114 (tempo-define-template "dcl-f$user" | 2114 (tempo-define-template "dcl-f$user" |
2115 '("f$user" dcl-tempo-left-paren dcl-tempo-right-paren) | 2115 '("f$user" dcl-tempo-left-paren dcl-tempo-right-paren) |
2116 "f$user" "" 'dcl-tempo-tags) | 2116 "f$user" "" 'dcl-tempo-tags) |
2117 | 2117 |
2118 (tempo-define-template "dcl-f$verify" | 2118 (tempo-define-template "dcl-f$verify" |
2119 '("f$verify" dcl-tempo-left-paren | 2119 '("f$verify" dcl-tempo-left-paren |
2120 (p "[procedure-value]: ") dcl-tempo-comma | 2120 (p "[procedure-value]: ") dcl-tempo-comma |
2121 (p "[image-value]: ") dcl-tempo-right-paren) | 2121 (p "[image-value]: ") dcl-tempo-right-paren) |
2122 "f$verify" "" 'dcl-tempo-tags) | 2122 "f$verify" "" 'dcl-tempo-tags) |
2123 | 2123 |
2124 | 2124 |
2169 (found (re-search-backward regexp 0 t))) | 2169 (found (re-search-backward regexp 0 t))) |
2170 (if (not found) | 2170 (if (not found) |
2171 () | 2171 () |
2172 (equal start (match-end 0)))))) | 2172 (equal start (match-end 0)))))) |
2173 | 2173 |
2174 | 2174 |
2175 ;;;------------------------------------------------------------------------- | 2175 ;;;------------------------------------------------------------------------- |
2176 (defun dcl-imenu-create-index-function () | 2176 (defun dcl-imenu-create-index-function () |
2177 "Jacket routine to make imenu searches non case sensitive." | 2177 "Jacket routine to make imenu searches non case sensitive." |
2178 (let ((case-fold-search t)) | 2178 (let ((case-fold-search t)) |
2179 (imenu-default-create-index-function))) | 2179 (imenu-default-create-index-function))) |