annotate lisp/progmodes/dcl-mode.el @ 35703:c691980103d7

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