1 ;;; dcl-mode.el --- major mode for editing DCL command files
3 ;; Copyright (C) 1997, 2001-2015 Free Software Foundation, Inc.
5 ;; Author: Odd Gripenstam <gripenstamol@decus.se>
6 ;; Maintainer: Odd Gripenstam <gripenstamol@decus.se>
7 ;; Keywords: DCL editing major-mode languages
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; DCL mode is a package for editing DCL command files. It helps you
27 ;; indent lines, add leading `$' and trailing `-', move around in the
28 ;; code and insert lexical functions.
30 ;; Type `C-h m' when you are editing a .COM file to get more
31 ;; information about this mode.
33 ;; To use templates you will need a version of tempo.el that is at
34 ;; least later than the buggy 1.1.1, which was included with my versions of
35 ;; Emacs. I used version 1.2.4.
36 ;; The latest tempo.el distribution can be fetched from
37 ;; ftp.lysator.liu.se in the directory /pub/emacs.
38 ;; I recommend setting (setq tempo-interactive t). This will make
39 ;; tempo prompt you for values to put in the blank spots in the templates.
41 ;; There is limited support for imenu. The limitation is that you need
42 ;; a version of imenu.el that uses imenu-generic-expression. I found
43 ;; the version I use in Emacs 19.30. (It was *so* much easier to hook
44 ;; into that version than the one in 19.27...)
46 ;; Any feedback will be welcomed. If you write functions for
47 ;; dcl-calc-command-indent-function or dcl-calc-cont-indent-function,
48 ;; please send them to the maintainer.
51 ;; Ideas for improvement:
52 ;; * Better font-lock support.
53 ;; * Change meaning of `left margin' when dcl-tab-always-indent is nil.
54 ;; Consider the following line (`_' is the cursor):
56 ;; Pressing tab with the cursor at the underline now inserts a tab.
57 ;; This should be part of the left margin and pressing tab should indent
59 ;; * Make M-LFD work properly with comments in all cases. Now it only
60 ;; works on comment-only lines. But what is "properly"? New rules for
61 ;; indenting comments?
62 ;; * Even smarter indentation of continuation lines.
63 ;; * A delete-indentation function (M-^) that joins continued lines,
64 ;; including lines with end line comments?
66 ;; * `indent list' commands: C-M-q, C-u TAB. What is a list in DCL? One
67 ;; complete command line? A block? A subroutine?
73 ;;; *** Customization *****************************************************
76 ;; First, font lock. This is a minimal approach, please improve!
78 (defvar dcl-font-lock-keywords
79 '(("\\<\\(if\\|then\\|else\\|endif\\)\\>"
80 1 font-lock-keyword-face
)
82 0 font-lock-builtin-face
)
83 ("[.]\\(eq\\|not\\|or\\|and\\|lt\\|gt\\|le\\|ge\\|eqs\\|nes\\)[.]"
84 0 font-lock-builtin-face
))
85 "Font lock keyword specification for DCL mode.
86 Presently this includes some syntax, .OP.erators, and \"f$\" lexicals.")
88 (defvar dcl-font-lock-defaults
89 '(dcl-font-lock-keywords nil
)
90 "Font lock specification for DCL mode.")
96 "Major mode for editing DCL command files."
97 :link
'(custom-group-link :tag
"Font Lock Faces group" font-lock-faces
)
100 (defcustom dcl-basic-offset
4
101 "Number of columns to indent a block in DCL.
102 A block is the commands between THEN-ELSE-ENDIF and between the commands
103 dcl-block-begin-regexp and dcl-block-end-regexp.
105 The meaning of this variable may be changed if
106 dcl-calc-command-indent-function is set to a function."
111 (defcustom dcl-continuation-offset
6
112 "Number of columns to indent a continuation line in DCL.
113 A continuation line is a line that follows a line ending with `-'.
115 The meaning of this variable may be changed if
116 dcl-calc-cont-indent-function is set to a function."
121 (defcustom dcl-margin-offset
8
122 "Indentation for the first command line in DCL.
123 The first command line in a file or after a SUBROUTINE statement is indented
124 this much. Other command lines are indented the same number of columns as
125 the preceding command line.
126 A command line is a line that starts with `$'."
131 (defcustom dcl-margin-label-offset
2
132 "Number of columns to indent a margin label in DCL.
133 A margin label is a label that doesn't begin or end a block, i.e. it
134 doesn't match dcl-block-begin-regexp or dcl-block-end-regexp."
139 (defcustom dcl-comment-line-regexp
"^\\$!"
140 "Regexp describing the start of a comment line in DCL.
141 Comment lines are not indented."
146 (defcustom dcl-block-begin-regexp
"loop[0-9]*:"
147 "Regexp describing a command that begins an indented block in DCL.
148 Set to nil to only indent at THEN-ELSE-ENDIF."
153 (defcustom dcl-block-end-regexp
"endloop[0-9]*:"
154 "Regexp describing a command that ends an indented block in DCL.
155 Set to nil to only indent at THEN-ELSE-ENDIF."
160 (defcustom dcl-calc-command-indent-function nil
161 "Function to calculate indentation for a command line in DCL.
162 If this variable is non-nil it is called as a function:
164 \(func INDENT-TYPE CUR-INDENT EXTRA-INDENT LAST-POINT THIS-POINT)
166 The function must return the number of columns to indent the current line or
167 nil to get the default indentation.
169 INDENT-TYPE is a symbol indicating what kind of indentation should be done.
170 It can have the following values:
171 indent the indentation should be increased, e.g., after THEN.
172 outdent the indentation should be decreased, e.g., a line with ENDIF.
173 first-line indentation for the first line in a buffer or SUBROUTINE.
174 CUR-INDENT is the indentation of the preceding command line.
175 EXTRA-INDENT is the default change in indentation for this line
176 \(a negative number for 'outdent).
177 LAST-POINT is the buffer position of the first significant word on the
178 previous line or nil if the current line is the first line.
179 THIS-POINT is the buffer position of the first significant word on the
182 If this variable is nil, the indentation is calculated as
183 CUR-INDENT + EXTRA-INDENT.
185 This package includes two functions suitable for this:
186 dcl-calc-command-indent-multiple
187 dcl-calc-command-indent-hang"
188 :type
'(choice (const nil
) function
)
192 (defcustom dcl-calc-cont-indent-function
'dcl-calc-cont-indent-relative
193 "Function to calculate indentation for a continuation line.
194 If this variable is non-nil it is called as a function:
196 \(func CUR-INDENT EXTRA-INDENT)
198 The function must return the number of columns to indent the current line or
199 nil to get the default indentation.
201 If this variable is nil, the indentation is calculated as
202 CUR-INDENT + EXTRA-INDENT.
204 This package includes one function suitable for this:
205 dcl-calc-cont-indent-relative"
210 (defcustom dcl-tab-always-indent t
211 "Controls the operation of the TAB key in DCL mode.
212 If t, pressing TAB always indents the current line.
213 If nil, pressing TAB indents the current line if point is at the left margin.
214 Data lines (i.e. lines not part of a command line or continuation line) are
220 (defcustom dcl-electric-characters t
221 "Non-nil means reindent immediately when a label, ELSE or ENDIF is inserted."
226 (defcustom dcl-tempo-comma
", "
227 "Text to insert when a comma is needed in a template, in DCL mode."
231 (defcustom dcl-tempo-left-paren
"("
232 "Text to insert when a left parenthesis is needed in a template in DCL."
237 (defcustom dcl-tempo-right-paren
")"
238 "Text to insert when a right parenthesis is needed in a template in DCL."
242 ; I couldn't decide what looked best, so I'll let you decide...
243 ; Remember, you can also customize this with imenu-submenu-name-format.
244 (defcustom dcl-imenu-label-labels
"Labels"
245 "Imenu menu title for sub-listing with label names."
248 (defcustom dcl-imenu-label-goto
"GOTO"
249 "Imenu menu title for sub-listing with GOTO statements."
252 (defcustom dcl-imenu-label-gosub
"GOSUB"
253 "Imenu menu title for sub-listing with GOSUB statements."
256 (defcustom dcl-imenu-label-call
"CALL"
257 "Imenu menu title for sub-listing with CALL statements."
261 (defcustom dcl-imenu-generic-expression
262 `((nil "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):[ \t]+SUBROUTINE\\b" 1)
263 (,dcl-imenu-label-labels
264 "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):\\([ \t]\\|$\\)" 1)
265 (,dcl-imenu-label-goto
"\\s-GOTO[ \t]+\\([A-Za-z0-9_\$]+\\)" 1)
266 (,dcl-imenu-label-gosub
"\\s-GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)" 1)
267 (,dcl-imenu-label-call
"\\s-CALL[ \t]+\\([A-Za-z0-9_\$]+\\)" 1))
268 "Default imenu generic expression for DCL.
270 The default includes SUBROUTINE labels in the main listing and
271 sub-listings for other labels, CALL, GOTO and GOSUB statements.
272 See `imenu-generic-expression' for details."
273 :type
'(repeat (sexp :tag
"Imenu Expression"))
277 (defcustom dcl-mode-hook nil
278 "Hook called by `dcl-mode'."
283 ;;; *** Global variables ****************************************************
286 (defvar dcl-mode-syntax-table nil
287 "Syntax table used in DCL-buffers.")
288 (unless dcl-mode-syntax-table
289 (setq dcl-mode-syntax-table
(make-syntax-table))
290 (modify-syntax-entry ?
! "<" dcl-mode-syntax-table
) ; comment start
291 (modify-syntax-entry ?
\n ">" dcl-mode-syntax-table
) ; comment end
292 (modify-syntax-entry ?
< "(>" dcl-mode-syntax-table
) ; < and ...
293 (modify-syntax-entry ?
> ")<" dcl-mode-syntax-table
) ; > is a matching pair
294 (modify-syntax-entry ?
\\ "_" dcl-mode-syntax-table
) ; not an escape
299 (let ((map (make-sparse-keymap)))
300 (define-key map
"\e\n" 'dcl-split-line
)
301 (define-key map
"\e\t" 'tempo-complete-tag
)
302 (define-key map
"\e^" 'dcl-delete-indentation
)
303 (define-key map
"\em" 'dcl-back-to-indentation
)
304 (define-key map
"\ee" 'dcl-forward-command
)
305 (define-key map
"\ea" 'dcl-backward-command
)
306 (define-key map
"\e\C-q" 'dcl-indent-command
)
307 (define-key map
"\t" 'dcl-tab
)
308 (define-key map
":" 'dcl-electric-character
)
309 (define-key map
"F" 'dcl-electric-character
)
310 (define-key map
"f" 'dcl-electric-character
)
311 (define-key map
"E" 'dcl-electric-character
)
312 (define-key map
"e" 'dcl-electric-character
)
313 (define-key map
"\C-c\C-o" 'dcl-set-option
)
314 (define-key map
"\C-c\C-f" 'tempo-forward-mark
)
315 (define-key map
"\C-c\C-b" 'tempo-backward-mark
)
317 (define-key map
[menu-bar
] (make-sparse-keymap))
318 (define-key map
[menu-bar dcl
]
319 (cons "DCL" (make-sparse-keymap "DCL")))
321 ;; Define these in bottom-up order
322 (define-key map
[menu-bar dcl tempo-backward-mark
]
323 '("Previous template mark" . tempo-backward-mark
))
324 (define-key map
[menu-bar dcl tempo-forward-mark
]
325 '("Next template mark" . tempo-forward-mark
))
326 (define-key map
[menu-bar dcl tempo-complete-tag
]
327 '("Complete template tag" . tempo-complete-tag
))
328 (define-key map
[menu-bar dcl dcl-separator-tempo
]
330 (define-key map
[menu-bar dcl dcl-save-all-options
]
331 '("Save all options" . dcl-save-all-options
))
332 (define-key map
[menu-bar dcl dcl-save-nondefault-options
]
333 '("Save changed options" . dcl-save-nondefault-options
))
334 (define-key map
[menu-bar dcl dcl-set-option
]
335 '("Set option" . dcl-set-option
))
336 (define-key map
[menu-bar dcl dcl-separator-option
]
338 (define-key map
[menu-bar dcl dcl-delete-indentation
]
339 '("Delete indentation" . dcl-delete-indentation
))
340 (define-key map
[menu-bar dcl dcl-split-line
]
341 '("Split line" . dcl-split-line
))
342 (define-key map
[menu-bar dcl dcl-indent-command
]
343 '("Indent command" . dcl-indent-command
))
344 (define-key map
[menu-bar dcl dcl-tab
]
345 '("Indent line/insert tab" . dcl-tab
))
346 (define-key map
[menu-bar dcl dcl-back-to-indentation
]
347 '("Back to indentation" . dcl-back-to-indentation
))
348 (define-key map
[menu-bar dcl dcl-forward-command
]
349 '("End of statement" . dcl-forward-command
))
350 (define-key map
[menu-bar dcl dcl-backward-command
]
351 '("Beginning of statement" . dcl-backward-command
))
352 ;; imenu is only supported for versions with imenu-generic-expression
353 (if (boundp 'imenu-generic-expression
)
355 (define-key map
[menu-bar dcl dcl-separator-movement
]
357 (define-key map
[menu-bar dcl imenu
]
358 '("Buffer index menu" . imenu
))))
360 "Keymap used in DCL-mode buffers.")
363 "\\([ \t]*-[ \t]*\\(!.*\\)*\n\\)*[ \t]*"
364 "Regular expression describing white space in a DCL command line.
365 White space is any number of continued lines with only space,tab,endcomment
366 followed by space or tab."
371 (defcustom dcl-label-r
372 "[a-zA-Z0-9_\$]*:\\([ \t!]\\|$\\)"
373 "Regular expression describing a label.
374 A label is a name followed by a colon followed by white-space or end-of-line."
380 "^\\$\\(.*-[ \t]*\\(!.*\\)*\n\\)*[^!\"\n]*\\(\".*\\(\"\".*\\)*\"\\)*[^!\"\n]*"
381 "Regular expression describing a DCL command line up to a trailing comment.
382 A line starting with $, optionally followed by continuation lines,
383 followed by the end of the command line.
384 A continuation line is any characters followed by `-',
385 optionally followed by a comment, followed by a newline."
390 (defcustom dcl-command-regexp
391 "^\\$\\(.*-[ \t]*\\(!.*\\)*\n\\)*.*\\(\".*\\(\"\".*\\)*\"\\)*"
392 "Regular expression describing a DCL command line.
393 A line starting with $, optionally followed by continuation lines,
394 followed by the end of the command line.
395 A continuation line is any characters followed by `-',
396 optionally followed by a comment, followed by a newline."
401 (defcustom dcl-electric-reindent-regexps
402 (list "endif" "else" dcl-label-r
)
403 "Regexps that can trigger an electric reindent.
404 A list of regexps that will trigger a reindent if the last letter
405 is defined as dcl-electric-character.
407 E.g.: if this list contains `endif', the key `f' is defined as
408 dcl-electric-character and you have just typed the `f' in
409 `endif', the line will be reindented."
410 :type
'(repeat regexp
)
414 (defvar dcl-option-alist
415 '((dcl-basic-offset dcl-option-value-basic
)
416 (dcl-continuation-offset curval
)
417 (dcl-margin-offset dcl-option-value-margin-offset
)
418 (dcl-margin-label-offset dcl-option-value-offset
)
419 (dcl-comment-line-regexp dcl-option-value-comment-line
)
420 (dcl-block-begin-regexp curval
)
421 (dcl-block-end-regexp curval
)
422 (dcl-tab-always-indent toggle
)
423 (dcl-electric-characters toggle
)
424 (dcl-electric-reindent-regexps curval
)
425 (dcl-tempo-comma curval
)
426 (dcl-tempo-left-paren curval
)
427 (dcl-tempo-right-paren curval
)
428 (dcl-calc-command-indent-function curval
)
429 (dcl-calc-cont-indent-function curval
)
430 (comment-start curval
)
431 (comment-start-skip curval
)
433 "Options and default values for dcl-set-option.
435 An alist with option variables and functions or keywords to get a
436 default value for the option.
439 curval the current value
440 toggle the opposite of the current value (for t/nil)")
443 (defvar dcl-option-history
444 (mapcar (lambda (option-assoc)
445 (format "%s" (car option-assoc
)))
447 "The history list for dcl-set-option.
448 Preloaded with all known option names from dcl-option-alist")
451 ;; Must be defined after dcl-cmd-r
452 ;; This version is more correct but much slower than the one
453 ;; above. This version won't find GOTOs in comments or text strings.
454 ;(defvar dcl-imenu-generic-expression
456 ; ((nil "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):[ \t]+SUBROUTINE\\b" 1)
457 ; ("Labels" "^\\$[ \t]*\\([A-Za-z0-9_\$]+\\):\\([ \t]\\|$\\)" 1)
458 ; ("GOTO" (, (concat dcl-cmd-r "GOTO[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5)
459 ; ("GOSUB" (, (concat dcl-cmd-r
460 ; "GOSUB[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5)
461 ; ("CALL" (, (concat dcl-cmd-r "CALL[ \t]+\\([A-Za-z0-9_\$]+\\)")) 5)))
462 ; "*Default imenu generic expression for DCL.
464 ;The default includes SUBROUTINE labels in the main listing and
465 ;sub-listings for other labels, CALL, GOTO and GOSUB statements.
466 ;See `imenu-generic-expression' in a recent (e.g. Emacs 19.30) imenu.el
470 ;;; *** Mode initialization *************************************************
474 (define-derived-mode dcl-mode prog-mode
"DCL"
475 "Major mode for editing DCL-files.
477 This mode indents command lines in blocks. (A block is commands between
478 THEN-ELSE-ENDIF and between lines matching dcl-block-begin-regexp and
479 dcl-block-end-regexp.)
481 Labels are indented to a fixed position unless they begin or end a block.
482 Whole-line comments (matching dcl-comment-line-regexp) are not indented.
483 Data lines are not indented.
488 Commands not usually bound to keys:
490 \\[dcl-save-nondefault-options]\t\tSave changed options
491 \\[dcl-save-all-options]\t\tSave all options
492 \\[dcl-save-option]\t\t\tSave any option
493 \\[dcl-save-mode]\t\t\tSave buffer mode
495 Variables controlling indentation style and extra features:
498 Extra indentation within blocks.
500 dcl-continuation-offset
501 Extra indentation for continued lines.
504 Indentation for the first command line in a file or SUBROUTINE.
506 dcl-margin-label-offset
507 Indentation for a label.
509 dcl-comment-line-regexp
510 Lines matching this regexp will not be indented.
512 dcl-block-begin-regexp
514 Regexps that match command lines that begin and end, respectively,
515 a block of command lines that will be given extra indentation.
516 Command lines between THEN-ELSE-ENDIF are always indented; these variables
517 make it possible to define other places to indent.
518 Set to nil to disable this feature.
520 dcl-calc-command-indent-function
521 Can be set to a function that customizes indentation for command lines.
522 Two such functions are included in the package:
523 dcl-calc-command-indent-multiple
524 dcl-calc-command-indent-hang
526 dcl-calc-cont-indent-function
527 Can be set to a function that customizes indentation for continued lines.
528 One such function is included in the package:
529 dcl-calc-cont-indent-relative (set by default)
531 dcl-tab-always-indent
532 If t, pressing TAB always indents the current line.
533 If nil, pressing TAB indents the current line if point is at the left
536 dcl-electric-characters
537 Non-nil causes lines to be indented at once when a label, ELSE or ENDIF is
540 dcl-electric-reindent-regexps
541 Use this variable and function dcl-electric-character to customize
542 which words trigger electric indentation.
546 dcl-tempo-right-paren
547 These variables control the look of expanded templates.
549 dcl-imenu-generic-expression
550 Default value for imenu-generic-expression. The default includes
551 SUBROUTINE labels in the main listing and sub-listings for
552 other labels, CALL, GOTO and GOSUB statements.
554 dcl-imenu-label-labels
556 dcl-imenu-label-gosub
558 Change the text that is used as sub-listing labels in imenu.
560 Loading this package calls the value of the variable
561 `dcl-mode-load-hook' with no args, if that value is non-nil.
562 Turning on DCL mode calls the value of the variable `dcl-mode-hook'
563 with no args, if that value is non-nil.
566 The following example uses the default values for all variables:
568 $! This is a comment line that is not indented (it matches
569 $! dcl-comment-line-regexp)
570 $! Next follows the first command line. It is indented dcl-margin-offset.
572 $ ! Other comments are indented like command lines.
573 $ ! A margin label indented dcl-margin-label-offset:
577 $ ! Lines between THEN-ELSE and ELSE-ENDIF are
578 $ ! indented dcl-basic-offset
579 $ loop1: ! This matches dcl-block-begin-regexp...
580 $ ! ...so this line is indented dcl-basic-offset
581 $ text = \"This \" + - ! is a continued line
582 \"lined up with the command line\"
584 Data lines are not indented at all.
585 $ endloop1: ! This matches dcl-block-end-regexp
590 There is some minimal font-lock support (see vars
591 `dcl-font-lock-defaults' and `dcl-font-lock-keywords')."
592 (set (make-local-variable 'indent-line-function
) 'dcl-indent-line
)
593 (set (make-local-variable 'comment-start
) "!")
594 (set (make-local-variable 'comment-end
) "")
595 (set (make-local-variable 'comment-multi-line
) nil
)
597 ;; This used to be "^\\$[ \t]*![ \t]*" which looks more correct.
598 ;; The drawback was that you couldn't make empty comment lines by pressing
599 ;; C-M-j repeatedly - only the first line became a comment line.
600 ;; This version has the drawback that the "$" can be anywhere in the line,
601 ;; and something inappropriate might be interpreted as a comment.
602 (set (make-local-variable 'comment-start-skip
) "\\$[ \t]*![ \t]*")
604 (if (boundp 'imenu-generic-expression
)
605 (progn (setq imenu-generic-expression dcl-imenu-generic-expression
)
606 (setq imenu-case-fold-search t
)))
607 (setq imenu-create-index-function
'dcl-imenu-create-index-function
)
609 (make-local-variable 'dcl-comment-line-regexp
)
610 (make-local-variable 'dcl-block-begin-regexp
)
611 (make-local-variable 'dcl-block-end-regexp
)
612 (make-local-variable 'dcl-basic-offset
)
613 (make-local-variable 'dcl-continuation-offset
)
614 (make-local-variable 'dcl-margin-label-offset
)
615 (make-local-variable 'dcl-margin-offset
)
616 (make-local-variable 'dcl-tab-always-indent
)
617 (make-local-variable 'dcl-electric-characters
)
618 (make-local-variable 'dcl-calc-command-indent-function
)
619 (make-local-variable 'dcl-calc-cont-indent-function
)
620 (make-local-variable 'dcl-electric-reindent-regexps
)
623 (set (make-local-variable 'font-lock-defaults
) dcl-font-lock-defaults
)
625 (tempo-use-tag-list 'dcl-tempo-tags
))
628 ;;; *** Movement commands ***************************************************
631 ;;;-------------------------------------------------------------------------
632 (defun dcl-beginning-of-statement ()
633 "Go to the beginning of the preceding or current command line."
635 (re-search-backward dcl-command-regexp nil t
))
638 ;;;-------------------------------------------------------------------------
639 (defun dcl-end-of-statement ()
640 "Go to the end of the next or current command line."
642 (if (or (dcl-end-of-command-p)
643 (dcl-beginning-of-command-p)
644 (not (dcl-command-p)))
646 (dcl-beginning-of-statement))
647 (re-search-forward dcl-command-regexp nil t
))
650 ;;;-------------------------------------------------------------------------
651 (defun dcl-beginning-of-command ()
652 "Move point to beginning of current command."
654 (let ((type (dcl-get-line-type)))
655 (if (and (eq type
'$
)
657 () ; already in the correct position
658 (dcl-beginning-of-statement))))
661 ;;;-------------------------------------------------------------------------
662 (defun dcl-end-of-command ()
663 "Move point to end of current command or next command if not on a command."
665 (let ((type (dcl-get-line-type)))
669 (dcl-beginning-of-command)
670 (dcl-end-of-statement))
671 (dcl-end-of-statement))))
674 ;;;-------------------------------------------------------------------------
675 (defun dcl-backward-command (&optional incl-comment-commands
)
676 "Move backward to a command.
677 Move point to the preceding command line that is not a comment line,
678 a command line with only a comment, only contains a `$' or only
681 Returns point of the found command line or nil if not able to move."
683 (let ((start (point))
686 ;; Find first non-empty command line
688 ;; back up one statement and look at the command
689 (if (dcl-beginning-of-statement)
691 ((and dcl-block-begin-regexp
; might be nil
692 (looking-at (concat "^\\$" dcl-ws-r
693 dcl-block-begin-regexp
)))
694 (setq done t retval
(point)))
695 ((and dcl-block-end-regexp
; might be nil
696 (looking-at (concat "^\\$" dcl-ws-r
697 dcl-block-end-regexp
)))
698 (setq done t retval
(point)))
699 ((looking-at dcl-comment-line-regexp
)
700 t
) ; comment line, one more loop
701 ((and (not incl-comment-commands
)
702 (looking-at "\\$[ \t]*!"))
703 t
) ; comment only command, loop...
704 ((looking-at "^\\$[ \t]*$")
705 t
) ; empty line, one more loop
707 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r
"$")))
708 (setq done t
) ; not a label-only line, exit the loop
709 (setq retval
(point))))
710 ;; We couldn't go further back, and we haven't found a command yet.
711 ;; Return to the start position.
718 ;;;-------------------------------------------------------------------------
719 (defun dcl-forward-command (&optional incl-comment-commands
)
720 "Move forward to a command.
721 Move point to the end of the next command line that is not a comment line,
722 a command line with only a comment, only contains a `$' or only
725 Returns point of the found command line or nil if not able to move."
727 (let ((start (point))
730 ;; Find first non-empty command line
732 ;; go forward one statement and look at the command
733 (if (dcl-end-of-statement)
735 (dcl-beginning-of-statement)
737 ((and dcl-block-begin-regexp
; might be nil
738 (looking-at (concat "^\\$" dcl-ws-r
739 dcl-block-begin-regexp
)))
741 (setq retval
(point)))
742 ((and dcl-block-end-regexp
; might be nil
743 (looking-at (concat "^\\$" dcl-ws-r
744 dcl-block-end-regexp
)))
746 (setq retval
(point)))
747 ((looking-at dcl-comment-line-regexp
)
748 t
) ; comment line, one more loop
749 ((and (not incl-comment-commands
)
750 (looking-at "\\$[ \t]*!"))
751 t
) ; comment only command, loop...
752 ((looking-at "^\\$[ \t]*$")
753 t
) ; empty line, one more loop
755 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r
"$")))
756 (setq done t
) ; not a label-only line, exit the loop
757 (setq retval
(point)))))
758 ;; We couldn't go further back, and we haven't found a command yet.
759 ;; Return to the start position.
766 ;;;-------------------------------------------------------------------------
767 (defun dcl-back-to-indentation ()
768 "Move point to the first non-whitespace character on this line.
769 Leading $ and labels counts as whitespace in this case.
770 If this is a comment line then move to the first non-whitespace character
773 Typing \\[dcl-back-to-indentation] several times in a row will move point to other
774 `interesting' points closer to the left margin, and then back to the
775 rightmost point again.
777 E.g. on the following line, point would go to the positions indicated
778 by the numbers in order 1-2-3-1-... :
783 (if (eq last-command
'dcl-back-to-indentation
)
784 (dcl-back-to-indentation-1 (point))
785 (dcl-back-to-indentation-1)))
786 (defun dcl-back-to-indentation-1 (&optional limit
)
787 "Helper function for dcl-back-to-indentation"
789 ;; "Indentation points" that we will travel to
802 (let* ((default-limit (1+ (line-end-position)))
803 (limit (or limit default-limit
))
804 (last-good-point (point))
807 (back-to-indentation)
809 ;; If we already were at the outermost indentation point then we
810 ;; start searching for the innermost point again.
811 (if (= (point) opoint
)
812 (setq limit default-limit
))
814 (if (< (point) limit
)
815 (setq last-good-point
(point)))
818 ;; Special treatment for comment lines. We are trying to allow
819 ;; things like "$ !*" as comment lines.
820 ((looking-at dcl-comment-line-regexp
)
821 (re-search-forward (concat dcl-comment-line-regexp
"[ \t]*") limit t
)
822 (if (< (point) limit
)
823 (setq last-good-point
(point))))
825 ;; Normal command line
826 ((looking-at "^\\$[ \t]*")
827 ;; Move over leading "$" and blanks
828 (re-search-forward "^\\$[ \t]*" limit t
)
829 (if (< (point) limit
)
830 (setq last-good-point
(point)))
832 ;; Move over a label (if it isn't a block begin/end)
833 ;; We must treat block begin/end labels as commands because
834 ;; dcl-set-option relies on it.
835 (if (and (looking-at dcl-label-r
)
836 (not (or (and dcl-block-begin-regexp
837 (looking-at dcl-block-begin-regexp
))
838 (and dcl-block-end-regexp
839 (looking-at dcl-block-end-regexp
)))))
840 (re-search-forward (concat dcl-label-r
"[ \t]*") limit t
))
841 (if (< (point) limit
)
842 (setq last-good-point
(point)))
844 ;; Move over the beginning of a comment
845 (if (looking-at "![ \t]*")
846 (re-search-forward "![ \t]*" limit t
))
847 (if (< (point) limit
)
848 (setq last-good-point
(point)))))
849 (goto-char last-good-point
)))
852 ;;; *** Support for indentation *********************************************
855 (defun dcl-get-line-type ()
856 "Determine the type of the current line.
857 Returns one of the following symbols:
858 $ for a complete command line or the beginning of a command line.
859 - for a continuation line
860 $! for a comment line
862 empty-data for an empty line following a data line
863 empty-$ for an empty line following a command line"
865 ;; Check if it's a comment line.
866 ;; A comment line starts with $!
869 (if (looking-at dcl-comment-line-regexp
)
871 ;; Check if it's a command line.
872 ;; A command line starts with $
875 (if (looking-at "^\\$")
877 ;; Check if it's a continuation line
880 ;; If we're at the beginning of the buffer it can't be a continuation
883 (let ((opoint (point)))
884 (dcl-beginning-of-statement)
885 (re-search-forward dcl-command-regexp opoint t
)
886 (if (>= (point) opoint
)
888 ;; Empty lines might be different things
890 (if (and (bolp) (eolp))
894 (let ((type (dcl-get-line-type)))
896 ((or (equal type
'$
) (equal type
'$
!) (equal type
'-
))
900 ;; Anything else must be a data line
905 ;;;-------------------------------------------------------------------------
906 (defun dcl-indentation-point ()
907 "Return point of first non-`whitespace' on this line."
909 (dcl-back-to-indentation)
913 ;;;---------------------------------------------------------------------------
914 (defun dcl-show-line-type ()
915 "Test dcl-get-line-type."
917 (let ((type (dcl-get-line-type)))
920 (message "command line"))
924 (message "comment line"))
926 (message "continuation line"))
929 ((equal type
'empty-data
)
930 (message "empty-data"))
931 ((equal type
'empty-$
)
938 ;;; *** Perform indentation *************************************************
941 ;;;---------------------------------------------------------------------------
942 (defun dcl-calc-command-indent-multiple
943 (indent-type cur-indent extra-indent _last-point _this-point
)
944 "Indent lines to a multiple of dcl-basic-offset.
946 Set dcl-calc-command-indent-function to this function to customize
947 indentation of command lines.
949 Command lines that need to be indented beyond the left margin are
950 always indented to a column that is a multiple of dcl-basic-offset, as
951 if tab stops were set at 4, 8, 12, etc.
953 This supports a formatting style like this (dcl-margin offset = 2,
954 dcl-basic-offset = 4):
962 ;; calculate indentation if it's an interesting indent-type,
963 ;; otherwise return nil to get the default indentation
966 ((equal indent-type
'indent
)
967 (setq indent
(- cur-indent
(% cur-indent dcl-basic-offset
)))
968 (setq indent
(+ indent extra-indent
))))))
971 ;;;---------------------------------------------------------------------------
972 ;; Some people actually writes likes this. To each his own...
973 (defun dcl-calc-command-indent-hang
974 (indent-type cur-indent extra-indent last-point this-point
)
975 "Indent lines as default, but indent THEN, ELSE and ENDIF extra.
977 Set dcl-calc-command-indent-function to this function to customize
978 indentation of command lines.
980 This function supports a formatting style like this:
988 If you use this function you will probably want to add \"then\" to
989 dcl-electric-reindent-regexps and define the key \"n\" as
990 dcl-electric-character.
992 (let ((case-fold-search t
))
995 ;; No indentation, this word is `then': +2
996 ;; last word was endif: -2
999 (goto-char this-point
)
1000 (if (looking-at "\\bthen\\b")
1001 (+ cur-indent extra-indent
2)))
1003 (goto-char last-point
)
1004 (if (looking-at "\\bendif\\b")
1005 (- (+ cur-indent extra-indent
) 2)))))
1006 ;; Indentation, last word was `then' or `else': -2
1007 ((equal indent-type
'indent
)
1008 (goto-char last-point
)
1010 ((looking-at "\\bthen\\b")
1011 (- (+ cur-indent extra-indent
) 2))
1012 ((looking-at "\\belse\\b")
1013 (- (+ cur-indent extra-indent
) 2))))
1014 ;; Outdent, this word is `endif' or `else': + 2
1015 ((equal indent-type
'outdent
)
1016 (goto-char this-point
)
1018 ((looking-at "\\bendif\\b")
1019 (+ cur-indent extra-indent
2))
1020 ((looking-at "\\belse\\b")
1021 (+ cur-indent extra-indent
2))))))))
1024 ;;;---------------------------------------------------------------------------
1025 (defun dcl-calc-command-indent ()
1026 "Calculate how much the current line shall be indented.
1027 The line is known to be a command line.
1029 Find the indentation of the preceding line and analyze its contents to
1030 see if the current lines should be indented.
1031 Analyze the current line to see if it should be `outdented'.
1033 Calculate the indentation of the current line, either with the default
1034 method or by calling dcl-calc-command-indent-function if it is
1037 If the current line should be outdented, calculate its indentation,
1038 either with the default method or by calling
1039 dcl-calc-command-indent-function if it is non-nil.
1042 Rules for default indentation:
1044 If it is the first line in the buffer, indent dcl-margin-offset.
1046 Go to the previous command line with a command on it.
1047 Find out how much it is indented (cur-indent).
1048 Look at the first word on the line to see if the indentation should be
1049 adjusted. Skip margin-label, continuations and comments while looking for
1050 the first word. Save this buffer position as `last-point'.
1051 If the first word after a label is SUBROUTINE, set extra-indent to
1054 First word extra-indent
1055 THEN +dcl-basic-offset
1056 ELSE +dcl-basic-offset
1057 block-begin +dcl-basic-offset
1059 Then return to the current line and look at the first word to see if the
1060 indentation should be adjusted again. Save this buffer position as
1063 First word extra-indent
1064 ELSE -dcl-basic-offset
1065 ENDIF -dcl-basic-offset
1066 block-end -dcl-basic-offset
1069 If dcl-calc-command-indent-function is nil or returns nil set
1070 cur-indent to cur-indent+extra-indent.
1072 If an extra adjustment is necessary and if
1073 dcl-calc-command-indent-function is nil or returns nil set cur-indent
1074 to cur-indent+extra-indent.
1076 See also documentation for dcl-calc-command-indent-function.
1077 The indent-type classification could probably be expanded upon.
1082 (let ((is-block nil
)
1083 (case-fold-search t
)
1086 indent-type last-point this-point extra-indent2 cur-indent2
1088 (if (bobp) ; first line in buffer
1089 (setq cur-indent
0 extra-indent dcl-margin-offset
1090 indent-type
'first-line
1091 this-point
(dcl-indentation-point))
1094 ;; Find first non-empty command line
1096 ;; back up one statement and look at the command
1097 (if (dcl-beginning-of-statement)
1099 ((and dcl-block-begin-regexp
; might be nil
1100 (looking-at (concat "^\\$" dcl-ws-r
1101 dcl-block-begin-regexp
)))
1102 (setq done t
) (setq is-block t
))
1103 ((and dcl-block-end-regexp
; might be nil
1104 (looking-at (concat "^\\$" dcl-ws-r
1105 dcl-block-end-regexp
)))
1106 (setq done t
) (setq is-block t
))
1107 ((looking-at dcl-comment-line-regexp
)
1108 t
) ; comment line, one more loop
1109 ((looking-at "^\\$[ \t]*$")
1110 t
) ; empty line, one more loop
1112 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r
"$")))
1113 (setq done t
))) ; not a label-only line, exit the loop
1114 ;; We couldn't go further back, so this must have been the
1116 (setq cur-indent dcl-margin-offset
1117 last-point
(dcl-indentation-point))
1119 ;; Examine the line to get current indentation and possibly a
1120 ;; reason to indent.
1123 ((looking-at (concat "^\\$[ \t]*" dcl-label-r dcl-ws-r
1124 "\\(subroutine\\b\\)"))
1125 (setq cur-indent dcl-margin-offset
1126 last-point
(1+ (match-beginning 1))))
1128 ;; Find out how much this line is indented.
1129 ;; Look at comment, continuation character, command but not label
1130 ;; unless it's a block.
1132 (re-search-forward "^\\$[ \t]*")
1133 (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r
1135 (setq cur-indent
(current-column))
1136 ;; Look for a reason to indent: Find first word on this line
1137 (re-search-forward dcl-ws-r
)
1138 (setq last-point
(point))
1140 ((looking-at "\\bthen\\b")
1141 (setq extra-indent dcl-basic-offset indent-type
'indent
))
1142 ((looking-at "\\belse\\b")
1143 (setq extra-indent dcl-basic-offset indent-type
'indent
))
1144 ((and dcl-block-begin-regexp
; might be nil
1145 (looking-at dcl-block-begin-regexp
))
1146 (setq extra-indent dcl-basic-offset indent-type
'indent
))
1148 (setq extra-indent2
0)
1149 ;; We're back at the beginning of the original line.
1150 ;; Look for a reason to outdent: Find first word on this line
1151 (re-search-forward (concat "^\\$" dcl-ws-r
))
1152 (setq this-point
(dcl-indentation-point))
1154 ((looking-at "\\belse\\b")
1155 (setq extra-indent2
(- dcl-basic-offset
) indent-type2
'outdent
))
1156 ((looking-at "\\bendif\\b")
1157 (setq extra-indent2
(- dcl-basic-offset
) indent-type2
'outdent
))
1158 ((and dcl-block-end-regexp
; might be nil
1159 (looking-at dcl-block-end-regexp
))
1160 (setq extra-indent2
(- dcl-basic-offset
) indent-type2
'outdent
))
1161 ((looking-at (concat dcl-label-r dcl-ws-r
"\\(subroutine\\b\\)"))
1162 (setq cur-indent2
0 extra-indent2 dcl-margin-offset
1163 indent-type2
'first-line
1164 this-point
(1+ (match-beginning 1)))))
1167 (or (and dcl-calc-command-indent-function
1168 (funcall dcl-calc-command-indent-function
1169 indent-type cur-indent extra-indent
1170 last-point this-point
))
1171 (+ cur-indent extra-indent
)))
1172 ;; Calculate outdent
1175 (or cur-indent2
(setq cur-indent2 cur-indent
))
1177 (or (and dcl-calc-command-indent-function
1178 (funcall dcl-calc-command-indent-function
1179 indent-type2 cur-indent2 extra-indent2
1180 last-point this-point
))
1181 (+ cur-indent2 extra-indent2
)))))
1186 ;;;---------------------------------------------------------------------------
1187 (defun dcl-calc-cont-indent-relative (_cur-indent _extra-indent
)
1188 "Indent continuation lines to align with words on previous line.
1190 Indent continuation lines to a position relative to preceding
1191 significant command line elements.
1193 Set `dcl-calc-cont-indent-function' to this function to customize
1194 indentation of continuation lines.
1196 Indented lines will align with either:
1198 * the second word on the command line
1201 * the word after an assignment
1204 * the third word if it's a qualifier
1205 $ set terminal/width=80 -
1207 * the innermost nonclosed parenthesis
1208 $ if ((a.eq.b .and. -
1209 d.eq.c .or. f$function(xxxx, -
1212 (let ((case-fold-search t
)
1215 (dcl-beginning-of-statement)
1216 (let ((end (save-excursion (forward-line 1) (point))))
1217 ;; Move over blanks and label
1218 (if (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r
1219 "\\)*[ \t]*") end t
)
1221 ;; Move over the first word (might be `@filespec')
1222 (if (> (skip-chars-forward "@:[]<>$\\-a-zA-Z0-9_.;" end
) 0)
1223 (let (was-assignment)
1224 (skip-chars-forward " \t" end
)
1225 ;; skip over assignment if there is one
1226 (if (looking-at ":?==?")
1228 (setq was-assignment t
)
1229 (skip-chars-forward " \t:=" end
)))
1230 ;; This could be the position to indent to
1231 (setq indent
(current-column))
1233 ;; Move to the next word unless we have seen an
1234 ;; assignment. If it starts with `/' it's a
1235 ;; qualifier and we will indent to that position
1236 (if (and (not was-assignment
)
1237 (> (skip-chars-forward "a-zA-Z0-9_" end
) 0))
1239 (skip-chars-forward " \t" end
)
1240 (if (= (char-after (point)) ?
/)
1241 (setq indent
(current-column)))))
1243 ;; Now check if there are any parenthesis to adjust to.
1244 ;; If there is, we will indent to the position after the last non-closed
1245 ;; opening parenthesis.
1248 (let* ((start (save-excursion (dcl-beginning-of-statement) (point)))
1249 (parse-sexp-ignore-comments t
) ; for parse-partial
1250 (par-pos (nth 1 (parse-partial-sexp start
(point)))))
1251 (if par-pos
; is nil if no parenthesis was found
1252 (setq indent
(save-excursion
1254 (1+ (current-column)))))))
1258 ;;;---------------------------------------------------------------------------
1259 (defun dcl-calc-continuation-indent ()
1260 "Calculate how much the current line shall be indented.
1261 The line is known to be a continuation line.
1263 Go to the previous command line.
1264 Find out how much it is indented."
1265 ;; This was copied without much thought from dcl-calc-command-indent, so
1266 ;; it's a bit clumsy.
1271 ;; Huh? a continuation line first in the buffer??
1273 (let ((is-block nil
)
1276 ;; Find first non-empty command line
1279 (if (dcl-beginning-of-statement)
1281 ((and dcl-block-begin-regexp
1282 (looking-at (concat "^\\$" dcl-ws-r
1283 dcl-block-begin-regexp
)))
1284 (setq done t
) (setq is-block t
))
1285 ((and dcl-block-end-regexp
1286 (looking-at (concat "^\\$" dcl-ws-r
1287 dcl-block-end-regexp
)))
1288 (setq done t
) (setq is-block t
))
1289 ((looking-at dcl-comment-line-regexp
)
1291 ((looking-at "^\\$[ \t]*$")
1294 (concat "^\\$" dcl-ws-r dcl-label-r dcl-ws-r
"$")))
1296 ;; This must have been the first line.
1297 (setq indent dcl-margin-offset
)
1301 ;; Find out how much this line is indented.
1302 ;; Look at comment, continuation character, command but not label
1303 ;; unless it's a block.
1305 (re-search-forward "^\\$[ \t]*")
1306 (re-search-forward (concat "^\\$[ \t]*\\(" dcl-label-r
1308 (setq indent
(current-column))
1310 ;; We're back at the beginning of the original line.
1311 (or (and dcl-calc-cont-indent-function
1312 (funcall dcl-calc-cont-indent-function indent
1313 dcl-continuation-offset
))
1314 (+ indent dcl-continuation-offset
))
1318 ;;;---------------------------------------------------------------------------
1319 (defun dcl-indent-command-line ()
1320 "Indent a line known to be a command line."
1321 (let ((indent (dcl-calc-command-indent))
1322 (pos (- (point-max) (point))))
1325 (re-search-forward "^\\$[ \t]*")
1326 ;; Indent any margin-label if the offset is set
1327 ;; (Don't look at block labels)
1328 (if (and dcl-margin-label-offset
1329 (looking-at dcl-label-r
)
1330 (not (and dcl-block-begin-regexp
1331 (looking-at dcl-block-begin-regexp
)))
1332 (not (and dcl-block-end-regexp
1333 (looking-at dcl-block-end-regexp
))))
1335 (dcl-indent-to dcl-margin-label-offset
)
1336 (re-search-forward dcl-label-r
)))
1337 (dcl-indent-to indent
1)
1340 (if (> (- (point-max) pos
) (point))
1341 (goto-char (- (point-max) pos
)))
1345 ;;;-------------------------------------------------------------------------
1346 (defun dcl-indent-continuation-line ()
1347 "Indent a line known to be a continuation line.
1349 Notice that no special treatment is made for labels. They have to be
1350 on the first part on a command line to be taken into consideration."
1351 (let ((indent (dcl-calc-continuation-indent)))
1354 (re-search-forward "^[ \t]*")
1355 (dcl-indent-to indent
))
1356 (skip-chars-forward " \t")))
1359 ;;;---------------------------------------------------------------------------
1360 (defun dcl-delete-chars (chars)
1361 "Delete all characters in the set CHARS around point."
1362 (skip-chars-backward chars
)
1363 (delete-region (point) (progn (skip-chars-forward chars
) (point))))
1366 ;;;---------------------------------------------------------------------------
1367 (defun dcl-indent-line ()
1368 "The DCL version of `indent-line-function'.
1369 Adjusts indentation on the current line. Data lines are not indented."
1370 (let ((type (dcl-get-line-type)))
1373 (dcl-indent-command-line))
1375 (message "Unknown line type!"))
1377 ((equal type
'data
))
1378 ((equal type
'empty-data
))
1380 (dcl-indent-continuation-line))
1381 ((equal type
'empty-$
)
1383 (dcl-indent-command-line))
1385 (message "dcl-indent-line: unknown type"))
1389 ;;;-------------------------------------------------------------------------
1390 (defun dcl-indent-command ()
1391 "Indents the complete command line that point is on.
1392 This includes continuation lines."
1394 (let ((type (dcl-get-line-type)))
1395 (if (or (equal type
'$
)
1397 (equal type
'empty-$
))
1399 (indent-region (progn (or (looking-at "^\\$")
1400 (dcl-beginning-of-statement))
1402 (progn (dcl-end-of-statement) (point))
1406 ;;;-------------------------------------------------------------------------
1408 "Insert tab in data lines or indent code.
1409 If `dcl-tab-always-indent' is t, code lines are always indented.
1410 If nil, indent the current line only if point is at the left margin or in
1411 the lines indentation; otherwise insert a tab."
1413 (let ((type (dcl-get-line-type))
1414 (start-point (point)))
1416 ;; Data line : always insert tab
1417 ((or (equal type
'data
) (equal type
'empty-data
))
1419 ;; Indent only at start of line
1420 ((not dcl-tab-always-indent
) ; nil
1421 (let ((search-end-point
1424 (re-search-forward "^\\$?[ \t]*" start-point t
))))
1426 (and search-end-point
1427 (>= search-end-point start-point
)))
1429 (tab-to-tab-stop))))
1431 ((eq dcl-tab-always-indent t
) ; t
1436 ;;;-------------------------------------------------------------------------
1437 (defun dcl-electric-character (arg)
1438 "Inserts a character and indents if necessary.
1439 Insert a character if the user gave a numeric argument or the flag
1440 `dcl-electric-characters' is not set. If an argument was given,
1441 insert that many characters.
1443 The line is only reindented if the word just typed matches any of the
1444 regexps in `dcl-electric-reindent-regexps'."
1446 (if (or arg
(not dcl-electric-characters
))
1448 (self-insert-command (prefix-numeric-value arg
))
1449 (self-insert-command 1))
1450 ;; Insert the character and indent
1451 (self-insert-command 1)
1452 (let ((case-fold-search t
))
1453 ;; There must be a better way than (memq t ...).
1454 ;; (apply 'or ...) didn't work
1455 (if (memq t
(mapcar 'dcl-was-looking-at dcl-electric-reindent-regexps
))
1456 (dcl-indent-line)))))
1459 ;;;-------------------------------------------------------------------------
1460 (defun dcl-indent-to (col &optional minimum
)
1461 "Like indent-to, but only indents if indentation would change"
1463 (let (cur-indent collapsed indent
)
1465 (skip-chars-forward " \t")
1466 (setq cur-indent
(current-column))
1467 (skip-chars-backward " \t")
1468 (setq collapsed
(current-column)))
1469 (setq indent
(max col
(+ collapsed
(or minimum
0))))
1470 (if (/= indent cur-indent
)
1472 (dcl-delete-chars " \t")
1473 (indent-to col minimum
)))))
1476 ;;;-------------------------------------------------------------------------
1477 (defun dcl-split-line ()
1478 "Break line at point and insert text to keep the syntax valid.
1480 Inserts continuation marks and splits character strings."
1481 ;; Still don't know what to do with comments at the end of a command line.
1484 (type (dcl-get-line-type)))
1486 ((or (equal type
'$
) (equal type
'-
))
1487 (let ((info (parse-partial-sexp
1488 (save-excursion (dcl-beginning-of-statement) (point))
1490 ;; handle some special cases
1492 ((nth 3 info
) ; in text constant
1493 (insert "\" + -\n\"")
1494 (indent-according-to-mode)
1496 ((not (nth 4 info
)) ; not in comment
1499 (= (char-after (point)) ?
\")
1500 (= (char-after (1- (point))) ?
\"))
1501 (progn ; a " "" " situation
1503 (insert "\" + -\n\"")
1505 (indent-according-to-mode)
1507 ((and (dcl-was-looking-at "[ \t]*-[ \t]*") ; after cont mark
1508 (looking-at "[ \t]*\\(!.*\\)?$"))
1509 ;; Do default below. This might considered wrong if we're
1510 ;; after a subtraction: $ x = 3 - <M-LFD>
1513 (delete-horizontal-space)
1515 (insert "\n") (indent-according-to-mode)
1518 ;; use the normal function for other cases
1519 (if (not done
) ; normal M-LFD action
1520 (indent-new-comment-line))))
1523 ;;;-------------------------------------------------------------------------
1524 (defun dcl-delete-indentation (&optional arg
)
1525 "Join this line to previous like delete-indentation.
1526 Also remove the continuation mark if easily detected."
1528 (delete-indentation arg
)
1529 (let ((type (dcl-get-line-type)))
1530 (if (and (member type
'($ - empty-$
))
1532 (= (char-before) ?-
))
1535 (fixup-whitespace)))))
1538 ;;; *** Set options *********************************************************
1541 ;;;-------------------------------------------------------------------------
1542 (defun dcl-option-value-basic (_option-assoc)
1543 "Guess a value for basic-offset."
1545 (dcl-beginning-of-command)
1546 (let* (;; current lines indentation
1547 (this-indent (save-excursion
1548 (dcl-back-to-indentation)
1550 ;; previous lines indentation
1551 (prev-indent (save-excursion
1552 (if (dcl-backward-command)
1554 (dcl-back-to-indentation)
1555 (current-column)))))
1556 (next-indent (save-excursion
1557 (dcl-end-of-command)
1558 (if (dcl-forward-command)
1560 (dcl-beginning-of-command)
1561 (dcl-back-to-indentation)
1562 (current-column)))))
1563 (diff (if prev-indent
1564 (abs (- this-indent prev-indent
)))))
1570 (/= (- this-indent next-indent
) 0))
1571 (abs (- this-indent next-indent
)))
1573 dcl-basic-offset
)))))
1576 ;;;-------------------------------------------------------------------------
1577 (defun dcl-option-value-offset (_option-assoc)
1578 "Guess a value for an offset.
1579 Find the column of the first non-blank character on the line.
1580 Returns the column offset."
1583 (re-search-forward "^$[ \t]*" nil t
)
1587 ;;;-------------------------------------------------------------------------
1588 (defun dcl-option-value-margin-offset (_option-assoc)
1589 "Guess a value for margin offset.
1590 Find the column of the first non-blank character on the line, not
1592 Returns a number as a string."
1595 (dcl-back-to-indentation)
1599 ;;;-------------------------------------------------------------------------
1600 (defun dcl-option-value-comment-line (_option-assoc)
1601 "Guess a value for `dcl-comment-line-regexp'.
1602 Must return a string."
1603 ;; Should we set comment-start and comment-start-skip as well?
1604 ;; If someone wants `$!&' as a comment line, C-M-j won't work well if
1606 ;; This must be done after the user has given the real value in
1612 ;; We could search for "^\\$.*!+[^ \t]*", but, as noted above, we
1613 ;; can't handle that case very good, so there is no point in
1615 (if (looking-at "^\\$[^!\n]*!")
1616 (let ((regexp (buffer-substring (match-beginning 0) (match-end 0))))
1617 (concat "^" (regexp-quote regexp
)))
1618 dcl-comment-line-regexp
))))
1621 ;;;-------------------------------------------------------------------------
1622 (defun dcl-guess-option-value (option)
1623 "Guess what value the user would like to give the symbol option."
1624 (let* ((option-assoc (assoc option dcl-option-alist
))
1625 (option (car option-assoc
))
1626 (action (car (cdr option-assoc
)))
1629 (funcall action option-assoc
))
1630 ((eq action
'toggle
)
1631 (not (eval option
)))
1632 ((eq action
'curval
)
1633 (cond ((or (stringp (symbol-value option
))
1634 (numberp (symbol-value option
)))
1635 (format "%S" (symbol-value option
)))
1637 (format "'%S" (symbol-value option
))))))))
1638 ;; format the value as a string if not already done
1641 (format "%S" value
))))
1644 ;;;-------------------------------------------------------------------------
1645 (defun dcl-guess-option ()
1646 "Guess what option the user wants to set by looking around in the code.
1647 Returns the name of the option variable as a string."
1648 (let ((case-fold-search t
))
1651 ((eq (dcl-get-line-type) '-
)
1652 "dcl-calc-cont-indent-function")
1656 (looking-at "^\\$[ \t]*!"))
1657 "dcl-comment-line-regexp")
1658 ;; Margin offset: subroutine statement or first line in buffer
1659 ;; Test this before label indentation to detect a subroutine
1662 (or (looking-at (concat "^\\$[ \t]*" dcl-label-r dcl-ws-r
1665 (not (dcl-backward-command t
)))))
1666 "dcl-margin-offset")
1667 ;; Margin offset: on command line after subroutine statement
1670 (and (eq (dcl-get-line-type) '$
)
1671 (dcl-backward-command)
1672 (looking-at (concat "^\\$[ \t]*" dcl-label-r dcl-ws-r
1674 "dcl-margin-offset")
1675 ;; Label indentation
1678 (and (looking-at (concat "^\\$[ \t]*" dcl-label-r
))
1679 (not (and dcl-block-begin-regexp
1680 (looking-at (concat "^\\$[ \t]*"
1681 dcl-block-begin-regexp
))))
1682 (not (and dcl-block-end-regexp
1683 (looking-at (concat "^\\$[ \t]*"
1684 dcl-block-end-regexp
))))))
1685 "dcl-margin-label-offset")
1687 ((and (eq (dcl-get-line-type) '$
) ; beginning of command
1690 (let* ((this-indent (save-excursion
1691 (dcl-back-to-indentation)
1693 (prev-indent (save-excursion
1694 (if (dcl-backward-command)
1696 (dcl-back-to-indentation)
1697 (current-column)))))
1698 (next-indent (save-excursion
1699 (dcl-end-of-command)
1700 (if (dcl-forward-command)
1702 (dcl-beginning-of-command)
1703 (dcl-back-to-indentation)
1704 (current-column))))))
1705 (or (and prev-indent
; last cmd is indented differently
1706 (/= (- this-indent prev-indent
) 0))
1708 (/= (- this-indent next-indent
) 0))))))
1715 ;;;-------------------------------------------------------------------------
1716 (defun dcl-set-option (option-sym option-value
)
1717 "Set a value for one of the dcl customization variables.
1718 The function tries to guess which variable should be set and to what value.
1719 All variable names are available as completions and in the history list."
1722 (intern (completing-read
1723 "Set DCL option: " ; prompt
1724 (mapcar (function ; alist of valid values
1725 (lambda (option-assoc)
1726 (cons (format "%s" (car option-assoc
)) nil
)))
1729 t
; only value from the list OK
1730 (dcl-guess-option) ; initial (default) value
1731 'dcl-option-history
))) ; history list
1734 (format "Set DCL option %s to: " option-sym
)
1735 (dcl-guess-option-value option-sym
))))
1736 (list option-sym option-value
)))
1737 ;; Should make a sanity check on the symbol/value pair.
1738 ;; `set' instead of `setq' because we want option-sym to be evaluated.
1739 (set option-sym option-value
))
1742 ;;; *** Save options ********************************************************
1745 ;;;-------------------------------------------------------------------------
1746 (defun dcl-save-local-variable (var &optional def-prefix def-suffix
)
1747 "Save a variable in a `Local Variables' list.
1748 Set or update the value of VAR in the current buffers
1749 `Local Variables:' list."
1750 ;; Look for "Local variables:" line in last page.
1752 (goto-char (point-max))
1753 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move
)
1754 (if (let ((case-fold-search t
))
1755 (search-forward "Local Variables:" nil t
))
1757 prefix prefixlen suffix beg
1758 prefix-string suffix-string
)
1759 ;; The prefix is what comes before "local variables:" in its line.
1760 ;; The suffix is what comes after "local variables:" in its line.
1761 (skip-chars-forward " \t")
1763 (setq suffix-string
(buffer-substring (point)
1764 (line-end-position))))
1765 (goto-char (match-beginning 0))
1768 (buffer-substring (point)
1769 (progn (beginning-of-line) (point)))))
1771 (if prefix-string
(setq prefixlen
(length prefix-string
)
1772 prefix
(regexp-quote prefix-string
)))
1773 (if suffix-string
(setq suffix
(concat (regexp-quote suffix-string
)
1776 ;; Look at next local variable spec.
1777 (if selective-display
(re-search-forward "[\n\C-m]")
1779 ;; Skip the prefix, if any.
1781 (if (looking-at prefix
)
1782 (forward-char prefixlen
)
1783 (error "Local variables entry is missing the prefix")))
1784 ;; Find the variable name; strip whitespace.
1785 (skip-chars-forward " \t")
1787 (skip-chars-forward "^:\n")
1788 (if (eolp) (error "Missing colon in local variables entry"))
1789 (skip-chars-backward " \t")
1790 (let* ((str (buffer-substring beg
(point)))
1791 (found-var (read str
)))
1792 ;; Setting variable named "end" means end of list.
1793 (if (string-equal (downcase str
) "end")
1795 ;; Not found. Insert a new entry before this line
1798 (insert (concat prefix-string
(symbol-name var
) ": "
1799 (prin1-to-string (eval var
)) " "
1800 suffix-string
"\n")))
1801 ;; Is it the variable we are looking for?
1802 (if (eq var found-var
)
1804 ;; Found it: delete the variable value and insert the
1807 (skip-chars-forward "^:")
1809 (delete-region (point) (progn (read (current-buffer))
1812 (prin1 (eval var
) (current-buffer))
1813 (skip-chars-backward "\n")
1814 (skip-chars-forward " \t")
1815 (or (if suffix
(looking-at suffix
) (eolp))
1817 "Local variables entry is terminated incorrectly")))
1819 ;; Did not find "Local variables:"
1820 (goto-char (point-max))
1823 ;; If def- parameter not set, use comment- if set. In that case, make
1824 ;; sure there is a space in a suitable position
1830 (if (or (equal comment-start
"")
1831 (string-match "[ \t]$" comment-start
))
1833 (concat comment-start
" ")))))
1839 (if (or (equal comment-end
"")
1840 (string-match "^[ \t]" comment-end
))
1842 (concat " " comment-end
))))))
1843 (insert (concat def-prefix
"Local variables:" def-suffix
"\n"))
1844 (insert (concat def-prefix
(symbol-name var
) ": "
1845 (prin1-to-string (eval var
)) def-suffix
"\n"))
1846 (insert (concat def-prefix
"end:" def-suffix
)))
1850 ;;;-------------------------------------------------------------------------
1851 (defun dcl-save-all-options ()
1852 "Save all dcl-mode options for this buffer.
1853 Saves or updates all dcl-mode related options in a `Local Variables:'
1854 section at the end of the current buffer."
1856 (mapcar (lambda (option-assoc)
1857 (let* ((option (car option-assoc
)))
1858 (dcl-save-local-variable option
"$! ")))
1862 ;;;-------------------------------------------------------------------------
1863 (defun dcl-save-nondefault-options ()
1864 "Save changed DCL mode options for this buffer.
1865 Saves or updates all DCL mode related options that don't have their
1866 default values in a `Local Variables:' section at the end of the
1869 No entries are removed from the `Local Variables:' section. This means
1870 that if a variable is given a non-default value in the section and
1871 later is manually reset to its default value, the variable's entry will
1872 still be present in the `Local Variables:' section with its old value."
1874 (mapcar (lambda (option-assoc)
1875 (let* ((option (car option-assoc
))
1876 (option-name (symbol-name option
)))
1877 (if (and (string-equal "dcl-"
1878 (substring option-name
0 4))
1879 (not (equal (default-value option
) (eval option
))))
1880 (dcl-save-local-variable option
"$! "))))
1884 ;;;-------------------------------------------------------------------------
1885 (defun dcl-save-option (option)
1886 "Save a DCL mode option for this buffer.
1887 Saves or updates an option in a `Local Variables:'
1888 section at the end of the current buffer."
1890 (let ((option (intern (completing-read "Option: " obarray
))))
1892 (dcl-save-local-variable option
))
1895 ;;;-------------------------------------------------------------------------
1897 ;; Dynamically bound in `dcl-save-mode'.
1900 (defun dcl-save-mode ()
1901 "Save the current mode for this buffer.
1902 Save the current mode in a `Local Variables:'
1903 section at the end of the current buffer."
1905 (let ((mode (prin1-to-string major-mode
)))
1906 (if (string-match "-mode$" mode
)
1907 (let ((mode (intern (substring mode
0 (match-beginning 0)))))
1908 (dcl-save-option 'mode
))
1909 (message "Strange mode: %s" mode
))))
1912 ;;; *** Templates ***********************************************************
1913 ;; tempo seems to be the only suitable package among those included in
1914 ;; standard Emacs. I would have liked something closer to the functionality
1915 ;; of LSE templates...
1917 (defvar dcl-tempo-tags nil
1918 "Tempo tags for DCL mode.")
1920 (tempo-define-template "dcl-f$context"
1921 '("f$context" dcl-tempo-left-paren
1922 (p "context-type: ") dcl-tempo-comma
1923 (p "context-symbol: ") dcl-tempo-comma
1924 (p "selection-item: ") dcl-tempo-comma
1925 (p "selection-value: ") dcl-tempo-comma
1926 (p "value-qualifier: ") dcl-tempo-right-paren
)
1927 "f$context" "" 'dcl-tempo-tags
)
1929 (tempo-define-template "dcl-f$csid"
1930 '("f$csid" dcl-tempo-left-paren
1931 (p "context-symbol: ") dcl-tempo-right-paren
)
1932 "f$csid" "" 'dcl-tempo-tags
)
1934 (tempo-define-template "dcl-f$cvsi"
1935 '("f$cvsi" dcl-tempo-left-paren
1936 (p "start-bit: ") dcl-tempo-comma
1937 (p "number-of-bits: ") dcl-tempo-comma
1938 (p "string: ") dcl-tempo-right-paren
)
1939 "f$cvsi" "" 'dcl-tempo-tags
)
1941 (tempo-define-template "dcl-f$cvtime"
1942 '("f$cvtime" dcl-tempo-left-paren
1943 (p "[input_time]: ") dcl-tempo-comma
1944 (p "[output_time_format]: ") dcl-tempo-comma
1945 (p "[output_field]: ") dcl-tempo-right-paren
)
1946 "f$cvtime" "" 'dcl-tempo-tags
)
1948 (tempo-define-template "dcl-f$cvui"
1949 '("f$cvui" dcl-tempo-left-paren
1950 (p "start-bit: ") dcl-tempo-comma
1951 (p "number-of-bits: ") dcl-tempo-comma
1952 (p "string") dcl-tempo-right-paren
)
1953 "f$cvui" "" 'dcl-tempo-tags
)
1955 (tempo-define-template "dcl-f$device"
1956 '("f$device" dcl-tempo-left-paren
1957 (p "[search_devnam]: ") dcl-tempo-comma
1958 (p "[devclass]: ") dcl-tempo-comma
1959 (p "[devtype]: ") dcl-tempo-comma
1960 (p "[stream-id]: ") dcl-tempo-right-paren
)
1961 "f$device" "" 'dcl-tempo-tags
)
1963 (tempo-define-template "dcl-f$directory"
1964 '("f$directory" dcl-tempo-left-paren
1965 dcl-tempo-right-paren
)
1966 "f$directory" "" 'dcl-tempo-tags
)
1968 (tempo-define-template "dcl-f$edit"
1969 '("f$edit" dcl-tempo-left-paren
1970 (p "string: ") dcl-tempo-comma
1971 (p "edit-list: ") dcl-tempo-right-paren
)
1972 "f$edit" "" 'dcl-tempo-tags
)
1974 (tempo-define-template "dcl-f$element"
1975 '("f$element" dcl-tempo-left-paren
1976 (p "element-number: ") dcl-tempo-comma
1977 (p "delimiter: ") dcl-tempo-comma
1978 (p "string: ") dcl-tempo-right-paren
)
1979 "f$element" "" 'dcl-tempo-tags
)
1981 (tempo-define-template "dcl-f$environment"
1982 '("f$environment" dcl-tempo-left-paren
1983 (p "item: ") dcl-tempo-right-paren
)
1984 "f$environment" "" 'dcl-tempo-tags
)
1986 (tempo-define-template "dcl-f$extract"
1987 '("f$extract" dcl-tempo-left-paren
1988 (p "start: ") dcl-tempo-comma
1989 (p "length: ") dcl-tempo-comma
1990 (p "string: ") dcl-tempo-right-paren
)
1991 "f$extract" "" 'dcl-tempo-tags
)
1993 (tempo-define-template "dcl-f$fao"
1994 '("f$fao" dcl-tempo-left-paren
1995 (p "control-string: ") dcl-tempo-comma
1996 ("argument[,...]: ") dcl-tempo-right-paren
)
1997 "f$fao" "" 'dcl-tempo-tags
)
1999 (tempo-define-template "dcl-f$file_attributes"
2000 '("f$file_attributes" dcl-tempo-left-paren
2001 (p "filespec: ") dcl-tempo-comma
2002 (p "item: ") dcl-tempo-right-paren
)
2003 "f$file_attributes" "" 'dcl-tempo-tags
)
2005 (tempo-define-template "dcl-f$getdvi"
2006 '("f$getdvi" dcl-tempo-left-paren
2007 (p "device-name: ") dcl-tempo-comma
2008 (p "item: ") dcl-tempo-right-paren
)
2009 "f$getdvi" "" 'dcl-tempo-tags
)
2011 (tempo-define-template "dcl-f$getjpi"
2012 '("f$getjpi" dcl-tempo-left-paren
2013 (p "pid: ") dcl-tempo-comma
2014 (p "item: ") dcl-tempo-right-paren
)
2015 "f$getjpi" "" 'dcl-tempo-tags
)
2017 (tempo-define-template "dcl-f$getqui"
2018 '("f$getqui" dcl-tempo-left-paren
2019 (p "function: ") dcl-tempo-comma
2020 (p "[item]: ") dcl-tempo-comma
2021 (p "[object-id]: ") dcl-tempo-comma
2022 (p "[flags]: ") dcl-tempo-right-paren
)
2023 "f$getqui" "" 'dcl-tempo-tags
)
2025 (tempo-define-template "dcl-f$getsyi"
2026 '("f$getsyi" dcl-tempo-left-paren
2027 (p "item: ") dcl-tempo-comma
2028 (p "[node-name]: ") dcl-tempo-comma
2029 (p "[cluster-id]: ") dcl-tempo-right-paren
)
2030 "f$getsyi" "" 'dcl-tempo-tags
)
2032 (tempo-define-template "dcl-f$identifier"
2033 '("f$identifier" dcl-tempo-left-paren
2034 (p "identifier: ") dcl-tempo-comma
2035 (p "conversion-type: ") dcl-tempo-right-paren
)
2036 "f$identifier" "" 'dcl-tempo-tags
)
2038 (tempo-define-template "dcl-f$integer"
2039 '("f$integer" dcl-tempo-left-paren
2040 (p "expression: ") dcl-tempo-right-paren
)
2041 "f$integer" "" 'dcl-tempo-tags
)
2043 (tempo-define-template "dcl-f$length"
2044 '("f$length" dcl-tempo-left-paren
2045 (p "string: ") dcl-tempo-right-paren
)
2046 "f$length" "" 'dcl-tempo-tags
)
2048 (tempo-define-template "dcl-f$locate"
2049 '("f$locate" dcl-tempo-left-paren
2050 (p "substring: ") dcl-tempo-comma
2051 (p "string: ") dcl-tempo-right-paren
)
2052 "f$locate" "" 'dcl-tempo-tags
)
2054 (tempo-define-template "dcl-f$message"
2055 '("f$message" dcl-tempo-left-paren
2056 (p "status-code: ") dcl-tempo-right-paren
)
2057 "f$message" "" 'dcl-tempo-tags
)
2059 (tempo-define-template "dcl-f$mode"
2060 '("f$mode" dcl-tempo-left-paren dcl-tempo-right-paren
)
2061 "f$mode" "" 'dcl-tempo-tags
)
2063 (tempo-define-template "dcl-f$parse"
2064 '("f$parse" dcl-tempo-left-paren
2065 (p "filespec: ") dcl-tempo-comma
2066 (p "[default-spec]: ") dcl-tempo-comma
2067 (p "[related-spec]: ") dcl-tempo-comma
2068 (p "[field]: ") dcl-tempo-comma
2069 (p "[parse-type]: ") dcl-tempo-right-paren
)
2070 "f$parse" "" 'dcl-tempo-tags
)
2072 (tempo-define-template "dcl-f$pid"
2073 '("f$pid" dcl-tempo-left-paren
2074 (p "context-symbol: ") dcl-tempo-right-paren
)
2075 "f$pid" "" 'dcl-tempo-tags
)
2077 (tempo-define-template "dcl-f$privilege"
2078 '("f$privilege" dcl-tempo-left-paren
2079 (p "priv-states: ") dcl-tempo-right-paren
)
2080 "f$privilege" "" 'dcl-tempo-tags
)
2082 (tempo-define-template "dcl-f$process"
2084 "f$process" "" 'dcl-tempo-tags
)
2086 (tempo-define-template "dcl-f$search"
2087 '("f$search" dcl-tempo-left-paren
2088 (p "filespec: ") dcl-tempo-comma
2089 (p "[stream-id]: ") dcl-tempo-right-paren
)
2090 "f$search" "" 'dcl-tempo-tags
)
2092 (tempo-define-template "dcl-f$setprv"
2093 '("f$setprv" dcl-tempo-left-paren
2094 (p "priv-states: ") dcl-tempo-right-paren
)
2095 "f$setprv" "" 'dcl-tempo-tags
)
2097 (tempo-define-template "dcl-f$string"
2098 '("f$string" dcl-tempo-left-paren
2099 (p "expression: ") dcl-tempo-right-paren
)
2100 "f$string" "" 'dcl-tempo-tags
)
2102 (tempo-define-template "dcl-f$time"
2103 '("f$time" dcl-tempo-left-paren dcl-tempo-right-paren
)
2104 "f$time" "" 'dcl-tempo-tags
)
2106 (tempo-define-template "dcl-f$trnlnm"
2107 '("f$trnlnm" dcl-tempo-left-paren
2108 (p "logical-name: ") dcl-tempo-comma
2109 (p "[table]: ") dcl-tempo-comma
2110 (p "[index]: ") dcl-tempo-comma
2111 (p "[mode]: ") dcl-tempo-comma
2112 (p "[case]: ") dcl-tempo-comma
2113 (p "[item]: ") dcl-tempo-right-paren
)
2114 "f$trnlnm" "" 'dcl-tempo-tags
)
2116 (tempo-define-template "dcl-f$type"
2117 '("f$type" dcl-tempo-left-paren
2118 (p "symbol-name: ") dcl-tempo-right-paren
)
2119 "f$type" "" 'dcl-tempo-tags
)
2121 (tempo-define-template "dcl-f$user"
2122 '("f$user" dcl-tempo-left-paren dcl-tempo-right-paren
)
2123 "f$user" "" 'dcl-tempo-tags
)
2125 (tempo-define-template "dcl-f$verify"
2126 '("f$verify" dcl-tempo-left-paren
2127 (p "[procedure-value]: ") dcl-tempo-comma
2128 (p "[image-value]: ") dcl-tempo-right-paren
)
2129 "f$verify" "" 'dcl-tempo-tags
)
2134 ;;; *** Unsorted stuff *****************************************************
2137 ;;;-------------------------------------------------------------------------
2138 (defun dcl-beginning-of-command-p ()
2139 "Return t if point is at the beginning of a command.
2140 Otherwise return nil."
2142 (eq (dcl-get-line-type) '$
)))
2145 ;;;-------------------------------------------------------------------------
2146 (defun dcl-end-of-command-p ()
2147 "Check if point is at the end of a command.
2148 Return t if point is at the end of a command, either the end of an
2149 only line or at the end of the last continuation line.
2150 Otherwise return nil."
2151 ;; Must be at end-of-line on a command line or a continuation line
2152 (let ((type (dcl-get-line-type)))
2156 ;; Next line must not be a continuation line
2159 (not (eq (dcl-get-line-type) '-
))))))
2162 ;;;-------------------------------------------------------------------------
2163 (defun dcl-command-p ()
2164 "Check if point is on a command line.
2165 Return t if point is on a command line or a continuation line,
2166 otherwise return nil."
2167 (let ((type (dcl-get-line-type)))
2172 ;;;-------------------------------------------------------------------------
2173 (defun dcl-was-looking-at (regexp)
2175 (let ((start (point))
2176 (found (re-search-backward regexp
0 t
)))
2179 (equal start
(match-end 0))))))
2181 (declare-function imenu-default-create-index-function
"imenu" ())
2183 ;;;-------------------------------------------------------------------------
2184 (defun dcl-imenu-create-index-function ()
2185 "Jacket routine to make imenu searches non case sensitive."
2186 (let ((case-fold-search t
))
2187 (imenu-default-create-index-function)))
2191 ;;; *** Epilogue ************************************************************
2196 (run-hooks 'dcl-mode-load-hook
) ; for your customizations
2198 ;;; dcl-mode.el ends here