Mercurial > emacs
annotate lisp/progmodes/pascal.el @ 12877:e5a2fab50a4b
(rmail-new-summary): Enable the Input/output menu.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 17 Aug 1995 16:51:57 +0000 |
parents | 83ef0f002ecf |
children | 83fd8f17cfe4 |
rev | line source |
---|---|
4934 | 1 ;;; pascal.el - Major mode for editing pascal source in emacs. |
2 | |
11235 | 3 ;;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. |
4934 | 4 |
5723 | 5 ;;; Author: Espen Skoglund (espensk@stud.cs.uit.no) |
6 ;;; Keywords: languages | |
4934 | 7 |
5723 | 8 ;;; This file is part of GNU Emacs. |
4934 | 9 |
5723 | 10 ;;; This program is free software; you can redistribute it and/or modify |
11 ;;; it under the terms of the GNU General Public License as published by | |
12 ;;; the Free Software Foundation; either version 2 of the License, or | |
13 ;;; (at your option) any later version. | |
4934 | 14 |
5723 | 15 ;;; This program is distributed in the hope that it will be useful, |
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;;; GNU General Public License for more details. | |
4934 | 19 |
5723 | 20 ;;; You should have received a copy of the GNU General Public License |
21 ;;; along with this program; if not, write to the Free Software | |
22 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
4934 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;;; USAGE | |
27 ;;; ===== | |
5723 | 28 |
29 ;;; Emacs should enter Pascal mode when you find a Pascal source file. | |
30 ;;; When you have entered Pascal mode, you may get more info by pressing | |
4934 | 31 ;;; C-h m. You may also get online help describing various functions by: |
5723 | 32 ;;; C-h f <Name of function you want described> |
33 | |
34 ;;; If you want to customize Pascal mode to fit you better, you may add | |
35 ;;; these lines (the values of the variables presented here are the defaults): | |
36 ;;; | |
37 ;;; ;; User customization for Pascal mode | |
38 ;;; (setq pascal-indent-level 3 | |
39 ;;; pascal-case-indent 2 | |
40 ;;; pascal-auto-newline nil | |
41 ;;; pascal-tab-always-indent t | |
42 ;;; pascal-auto-endcomments t | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
43 ;;; pascal-auto-lineup '(all) |
5723 | 44 ;;; pascal-toggle-completions nil |
45 ;;; pascal-type-keywords '("array" "file" "packed" "char" | |
46 ;;; "integer" "real" "string" "record") | |
47 ;;; pascal-start-keywords '("begin" "end" "function" "procedure" | |
48 ;;; "repeat" "until" "while" "read" "readln" | |
49 ;;; "reset" "rewrite" "write" "writeln") | |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
50 ;;; pascal-separator-keywords '("downto" "else" "mod" "div" "then")) |
4934 | 51 |
52 ;;; KNOWN BUGS / BUGREPORTS | |
53 ;;; ======================= | |
54 ;;; As far as I know, there are no bugs in the current version of this | |
5723 | 55 ;;; package. This may not be true however, since I never use this mode |
56 ;;; myself and therefore would never notice them anyway. If you do | |
57 ;;; find any bugs, you may submit them to: espensk@stud.cs.uit.no | |
58 ;;; as well as to bug-gnu-emacs@prep.ai.mit.edu. | |
59 | |
60 ;;; Code: | |
4934 | 61 |
62 (defvar pascal-mode-abbrev-table nil | |
63 "Abbrev table in use in Pascal-mode buffers.") | |
64 (define-abbrev-table 'pascal-mode-abbrev-table ()) | |
65 | |
66 (defvar pascal-mode-map () | |
67 "Keymap used in Pascal mode.") | |
5723 | 68 (if pascal-mode-map |
69 () | |
70 (setq pascal-mode-map (make-sparse-keymap)) | |
71 (define-key pascal-mode-map ";" 'electric-pascal-semi-or-dot) | |
72 (define-key pascal-mode-map "." 'electric-pascal-semi-or-dot) | |
73 (define-key pascal-mode-map ":" 'electric-pascal-colon) | |
74 (define-key pascal-mode-map "=" 'electric-pascal-equal) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
75 (define-key pascal-mode-map "#" 'electric-pascal-hash) |
5723 | 76 (define-key pascal-mode-map "\r" 'electric-pascal-terminate-line) |
77 (define-key pascal-mode-map "\t" 'electric-pascal-tab) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
78 (define-key pascal-mode-map "\M-\t" 'pascal-complete-word) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
79 (define-key pascal-mode-map "\M-?" 'pascal-show-completions) |
5723 | 80 (define-key pascal-mode-map "\177" 'backward-delete-char-untabify) |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
81 (define-key pascal-mode-map "\M-\C-h" 'pascal-mark-defun) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
82 (define-key pascal-mode-map "\C-c\C-b" 'pascal-insert-block) |
5723 | 83 (define-key pascal-mode-map "\M-*" 'pascal-star-comment) |
84 (define-key pascal-mode-map "\C-c\C-c" 'pascal-comment-area) | |
85 (define-key pascal-mode-map "\C-c\C-u" 'pascal-uncomment-area) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
86 (define-key pascal-mode-map "\M-\C-a" 'pascal-beg-of-defun) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
87 (define-key pascal-mode-map "\M-\C-e" 'pascal-end-of-defun) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
88 (define-key pascal-mode-map "\C-c\C-d" 'pascal-goto-defun) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
89 (define-key pascal-mode-map "\C-c\C-o" 'pascal-outline) |
4934 | 90 ;;; A command to change the whole buffer won't be used terribly |
91 ;;; often, so no need for a key binding. | |
5723 | 92 ; (define-key pascal-mode-map "\C-cd" 'pascal-downcase-keywords) |
93 ; (define-key pascal-mode-map "\C-cu" 'pascal-upcase-keywords) | |
94 ; (define-key pascal-mode-map "\C-cc" 'pascal-capitalize-keywords) | |
95 ) | |
12689
83ef0f002ecf
(pascal-mode): Added imenu support.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
96 |
83ef0f002ecf
(pascal-mode): Added imenu support.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
97 (defvar pascal-imenu-generic-expression |
83ef0f002ecf
(pascal-mode): Added imenu support.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
98 '("^[ \t]*\\(function\\|procedure\\)[ \t\n]+\\([a-zA-Z0-9_.:]+\\)" . (2)) |
83ef0f002ecf
(pascal-mode): Added imenu support.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
99 "Imenu expression for Pascal-mode. See `imenu-generic-expression'.") |
5723 | 100 |
101 (defvar pascal-keywords | |
102 '("and" "array" "begin" "case" "const" "div" "do" "downto" "else" "end" | |
103 "file" "for" "function" "goto" "if" "in" "label" "mod" "nil" "not" "of" | |
104 "or" "packed" "procedure" "program" "record" "repeat" "set" "then" "to" | |
105 "type" "until" "var" "while" "with" | |
106 ;; The following are not standard in pascal, but widely used. | |
107 "get" "put" "input" "output" "read" "readln" "reset" "rewrite" "write" | |
108 "writeln")) | |
4934 | 109 |
5723 | 110 ;;; |
111 ;;; Regular expressions used to calculate indent, etc. | |
112 ;;; | |
113 (defconst pascal-symbol-re "\\<[a-zA-Z_][a-zA-Z_0-9.]*\\>") | |
114 (defconst pascal-beg-block-re "\\<\\(begin\\|case\\|record\\|repeat\\)\\>") | |
115 (defconst pascal-end-block-re "\\<\\(end\\|until\\)\\>") | |
116 (defconst pascal-declaration-re "\\<\\(const\\|label\\|type\\|var\\)\\>") | |
117 (defconst pascal-defun-re "\\<\\(function\\|procedure\\|program\\)\\>") | |
6123
3c66892f0083
(pascal-sub-block-re): Recognize for and with.
Richard M. Stallman <rms@gnu.org>
parents:
5723
diff
changeset
|
118 (defconst pascal-sub-block-re "\\<\\(if\\|else\\|for\\|while\\|with\\)\\>") |
6153
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
119 (defconst pascal-noindent-re "\\<\\(begin\\|end\\|until\\|else\\)\\>") |
5723 | 120 (defconst pascal-nosemi-re "\\<\\(begin\\|repeat\\|then\\|do\\|else\\)\\>") |
121 (defconst pascal-autoindent-lines-re | |
122 "\\<\\(label\\|var\\|type\\|const\\|until\\|end\\|begin\\|repeat\\|else\\)\\>") | |
123 | |
124 ;;; Strings used to mark beginning and end of excluded text | |
125 (defconst pascal-exclude-str-start "{-----\\/----- EXCLUDED -----\\/-----") | |
126 (defconst pascal-exclude-str-end " -----/\\----- EXCLUDED -----/\\-----}") | |
4934 | 127 |
128 (defvar pascal-mode-syntax-table nil | |
129 "Syntax table in use in Pascal-mode buffers.") | |
130 | |
131 (if pascal-mode-syntax-table | |
132 () | |
133 (setq pascal-mode-syntax-table (make-syntax-table)) | |
11104
ef10b4684bb5
(pascal-mode-syntax-table): Give \ punctuation syntax.
Richard M. Stallman <rms@gnu.org>
parents:
10534
diff
changeset
|
134 (modify-syntax-entry ?\\ "." pascal-mode-syntax-table) |
5723 | 135 (modify-syntax-entry ?( "()1" pascal-mode-syntax-table) |
136 (modify-syntax-entry ?) ")(4" pascal-mode-syntax-table) | |
4934 | 137 (modify-syntax-entry ?* ". 23" pascal-mode-syntax-table) |
5723 | 138 (modify-syntax-entry ?{ "<" pascal-mode-syntax-table) |
139 (modify-syntax-entry ?} ">" pascal-mode-syntax-table) | |
140 (modify-syntax-entry ?+ "." pascal-mode-syntax-table) | |
141 (modify-syntax-entry ?- "." pascal-mode-syntax-table) | |
142 (modify-syntax-entry ?= "." pascal-mode-syntax-table) | |
143 (modify-syntax-entry ?% "." pascal-mode-syntax-table) | |
144 (modify-syntax-entry ?< "." pascal-mode-syntax-table) | |
145 (modify-syntax-entry ?> "." pascal-mode-syntax-table) | |
146 (modify-syntax-entry ?& "." pascal-mode-syntax-table) | |
147 (modify-syntax-entry ?| "." pascal-mode-syntax-table) | |
148 (modify-syntax-entry ?_ "w" pascal-mode-syntax-table) | |
149 (modify-syntax-entry ?\' "\"" pascal-mode-syntax-table)) | |
4934 | 150 |
9387
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
151 (defvar pascal-font-lock-keywords |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
152 (list |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
153 '("^[ \t]*\\(function\\|pro\\(cedure\\|gram\\)\\)\\>[ \t]*\\(\\sw+\\)?" |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
154 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t)) |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
155 ; ("type" "const" "real" "integer" "char" "boolean" "var" |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
156 ; "record" "array" "file") |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
157 (cons (concat "\\<\\(array\\|boolean\\|c\\(har\\|onst\\)\\|file\\|" |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
158 "integer\\|re\\(al\\|cord\\)\\|type\\|var\\)\\>") |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
159 'font-lock-type-face) |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
160 '("\\<\\(label\\|external\\|forward\\)\\>" . font-lock-reference-face) |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
161 '("\\<\\([0-9]+\\)[ \t]*:" 1 font-lock-reference-face) |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
162 ; ("of" "to" "for" "if" "then" "else" "case" "while" |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
163 ; "do" "until" "and" "or" "not" "in" "with" "repeat" "begin" "end") |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
164 (concat "\\<\\(" |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
165 "and\\|begin\\|case\\|do\\|e\\(lse\\|nd\\)\\|for\\|i[fn]\\|" |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
166 "not\\|o[fr]\\|repeat\\|t\\(hen\\|o\\)\\|until\\|w\\(hile\\|ith\\)" |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
167 "\\)\\>") |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
168 '("\\<\\(goto\\)\\>[ \t]*\\([0-9]+\\)?" |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
169 (1 font-lock-keyword-face) (2 font-lock-reference-face nil t))) |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
170 "Additional expressions to highlight in Pascal mode.") |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
171 |
5723 | 172 (defvar pascal-indent-level 3 |
4934 | 173 "*Indentation of Pascal statements with respect to containing block.") |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
174 |
5723 | 175 (defvar pascal-case-indent 2 |
176 "*Indentation for case statements.") | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
177 |
5723 | 178 (defvar pascal-auto-newline nil |
179 "*Non-nil means automatically newline after simcolons and the punctation mark | |
180 after an end.") | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
181 |
5723 | 182 (defvar pascal-tab-always-indent t |
183 "*Non-nil means TAB in Pascal mode should always reindent the current line, | |
184 regardless of where in the line point is when the TAB command is used.") | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
185 |
5723 | 186 (defvar pascal-auto-endcomments t |
187 "*Non-nil means a comment { ... } is set after the ends which ends cases and | |
188 functions. The name of the function or case will be set between the braces.") | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
189 |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
190 (defvar pascal-auto-lineup '(all) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
191 "*List of contexts where auto lineup of :'s or ='s should be done. |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
192 Elements can be of type: 'paramlist', 'declaration' or 'case', which will |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
193 do auto lineup in parameterlist, declarations or case-statements |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
194 respectively. The word 'all' will do all lineups. '(case paramlist) for |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
195 instance will do lineup in case-statements and parameterlist, while '(all) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
196 will do all lineups.") |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
197 |
5723 | 198 (defvar pascal-toggle-completions nil |
199 "*Non-nil means that \\<pascal-mode-map>\\[pascal-complete-label] should \ | |
200 not display a completion buffer when | |
201 the label couldn't be completed, but instead toggle the possible completions | |
202 with repeated \\[pascal-complete-label]'s.") | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
203 |
5723 | 204 (defvar pascal-type-keywords |
205 '("array" "file" "packed" "char" "integer" "real" "string" "record") | |
206 "*Keywords for types used when completing a word in a declaration or parmlist. | |
207 \(eg. integer, real, char.) The types defined within the Pascal program | |
208 will be completed runtime, and should not be added to this list.") | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
209 |
5723 | 210 (defvar pascal-start-keywords |
211 '("begin" "end" "function" "procedure" "repeat" "until" "while" | |
212 "read" "readln" "reset" "rewrite" "write" "writeln") | |
213 "*Keywords to complete when standing at the first word of a statement. | |
214 \(eg. begin, repeat, until, readln.) | |
215 The procedures and variables defined within the Pascal program | |
216 will be completed runtime and should not be added to this list.") | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
217 |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
218 (defvar pascal-separator-keywords |
5723 | 219 '("downto" "else" "mod" "div" "then") |
220 "*Keywords to complete when NOT standing at the first word of a statement. | |
221 \(eg. downto, else, mod, then.) | |
222 Variables and function names defined within the | |
223 Pascal program are completed runtime and should not be added to this list.") | |
224 | |
225 ;;; | |
226 ;;; Macros | |
227 ;;; | |
228 | |
229 (defsubst pascal-get-beg-of-line (&optional arg) | |
230 (save-excursion | |
231 (beginning-of-line arg) | |
232 (point))) | |
233 | |
234 (defsubst pascal-get-end-of-line (&optional arg) | |
235 (save-excursion | |
236 (end-of-line arg) | |
237 (point))) | |
238 | |
239 (defun pascal-declaration-end () | |
240 (let ((nest 1)) | |
241 (while (and (> nest 0) | |
242 (re-search-forward | |
243 "[:=]\\|\\(\\<record\\>\\)\\|\\(\\<end\\>\\)" | |
244 (save-excursion (end-of-line 2) (point)) t)) | |
245 (cond ((match-beginning 1) (setq nest (1+ nest))) | |
246 ((match-beginning 2) (setq nest (1- nest))))))) | |
247 | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
248 |
5723 | 249 (defun pascal-declaration-beg () |
250 (let ((nest 1)) | |
251 (while (and (> nest 0) | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
252 (re-search-backward "[:=]\\|\\<\\(type\\|var\\|label\\|const\\)\\>\\|\\(\\<record\\>\\)\\|\\(\\<end\\>\\)" (pascal-get-beg-of-line 0) t)) |
5723 | 253 (cond ((match-beginning 1) (setq nest 0)) |
254 ((match-beginning 2) (setq nest (1- nest))) | |
255 ((match-beginning 3) (setq nest (1+ nest))))) | |
256 (= nest 0))) | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
257 |
5723 | 258 |
259 (defsubst pascal-within-string () | |
260 (save-excursion | |
261 (nth 3 (parse-partial-sexp (pascal-get-beg-of-line) (point))))) | |
262 | |
4934 | 263 |
264 ;;;###autoload | |
265 (defun pascal-mode () | |
5723 | 266 "Major mode for editing Pascal code. \\<pascal-mode-map> |
267 TAB indents for Pascal code. Delete converts tabs to spaces as it moves back. | |
268 | |
269 \\[pascal-complete-word] completes the word around current point with respect \ | |
270 to position in code | |
271 \\[pascal-show-completions] shows all possible completions at this point. | |
272 | |
273 Other useful functions are: | |
274 | |
275 \\[pascal-mark-defun]\t- Mark function. | |
276 \\[pascal-insert-block]\t- insert begin ... end; | |
277 \\[pascal-star-comment]\t- insert (* ... *) | |
278 \\[pascal-comment-area]\t- Put marked area in a comment, fixing nested comments. | |
279 \\[pascal-uncomment-area]\t- Uncomment an area commented with \ | |
280 \\[pascal-comment-area]. | |
281 \\[pascal-beg-of-defun]\t- Move to beginning of current function. | |
282 \\[pascal-end-of-defun]\t- Move to end of current function. | |
283 \\[pascal-goto-defun]\t- Goto function prompted for in the minibuffer. | |
284 \\[pascal-outline]\t- Enter pascal-outline-mode (see also pascal-outline). | |
285 | |
286 Variables controlling indentation/edit style: | |
287 | |
288 pascal-indent-level (default 3) | |
289 Indentation of Pascal statements with respect to containing block. | |
290 pascal-case-indent (default 2) | |
291 Indentation for case statements. | |
292 pascal-auto-newline (default nil) | |
293 Non-nil means automatically newline after simcolons and the punctation mark | |
294 after an end. | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
295 pascal-tab-always-indent (default t) |
4934 | 296 Non-nil means TAB in Pascal mode should always reindent the current line, |
297 regardless of where in the line point is when the TAB command is used. | |
5723 | 298 pascal-auto-endcomments (default t) |
299 Non-nil means a comment { ... } is set after the ends which ends cases and | |
300 functions. The name of the function or case will be set between the braces. | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
301 pascal-auto-lineup (default t) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
302 List of contexts where auto lineup of :'s or ='s hould be done. |
4934 | 303 |
5723 | 304 See also the user variables pascal-type-keywords, pascal-start-keywords and |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
305 pascal-separator-keywords. |
4934 | 306 |
307 Turning on Pascal mode calls the value of the variable pascal-mode-hook with | |
308 no args, if that value is non-nil." | |
309 (interactive) | |
310 (kill-all-local-variables) | |
311 (use-local-map pascal-mode-map) | |
312 (setq major-mode 'pascal-mode) | |
313 (setq mode-name "Pascal") | |
314 (setq local-abbrev-table pascal-mode-abbrev-table) | |
315 (set-syntax-table pascal-mode-syntax-table) | |
316 (make-local-variable 'indent-line-function) | |
317 (setq indent-line-function 'pascal-indent-line) | |
5723 | 318 (setq comment-indent-function 'pascal-indent-comment) |
4934 | 319 (make-local-variable 'parse-sexp-ignore-comments) |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
320 (setq parse-sexp-ignore-comments nil) |
4934 | 321 (make-local-variable 'case-fold-search) |
322 (setq case-fold-search t) | |
9387
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
323 (make-local-variable 'comment-start-skip) |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
324 (setq comment-start-skip "(\\*+ *\\|{ *") |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
325 (make-local-variable 'comment-end) |
ccd27c6ef48d
(pascal-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8689
diff
changeset
|
326 (setq comment-end "}") |
12689
83ef0f002ecf
(pascal-mode): Added imenu support.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
327 ;; Font lock support |
9479
ef7c2b4dfee4
* pascal.el: (pascal-mode): Set font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
9387
diff
changeset
|
328 (make-local-variable 'font-lock-defaults) |
ef7c2b4dfee4
* pascal.el: (pascal-mode): Set font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
9387
diff
changeset
|
329 (setq font-lock-defaults '(pascal-font-lock-keywords nil t)) |
12689
83ef0f002ecf
(pascal-mode): Added imenu support.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
330 ;; Imenu support |
83ef0f002ecf
(pascal-mode): Added imenu support.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
331 (make-local-variable 'imenu-generic-expression) |
83ef0f002ecf
(pascal-mode): Added imenu support.
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
332 (setq imenu-generic-expression pascal-imenu-generic-expression) |
4934 | 333 (run-hooks 'pascal-mode-hook)) |
334 | |
5723 | 335 |
336 | |
4934 | 337 ;;; |
338 ;;; Electric functions | |
339 ;;; | |
340 (defun electric-pascal-terminate-line () | |
341 "Terminate line and indent next line." | |
342 (interactive) | |
5723 | 343 ;; First, check if current line should be indented |
4934 | 344 (save-excursion |
345 (beginning-of-line) | |
346 (skip-chars-forward " \t") | |
5723 | 347 (if (looking-at pascal-autoindent-lines-re) |
4934 | 348 (pascal-indent-line))) |
5723 | 349 (delete-horizontal-space) ; Removes trailing whitespaces |
4934 | 350 (newline) |
5723 | 351 ;; Indent next line |
4934 | 352 (pascal-indent-line) |
353 ;; Maybe we should set some endcomments | |
354 (if pascal-auto-endcomments | |
355 (pascal-set-auto-comments)) | |
356 ;; Check if we shall indent inside comment | |
357 (let ((setstar nil)) | |
358 (save-excursion | |
359 (forward-line -1) | |
360 (skip-chars-forward " \t") | |
5723 | 361 (cond ((looking-at "\\*[ \t]+)") |
4934 | 362 ;; Delete region between `*' and `)' if there is only whitespaces. |
363 (forward-char 1) | |
5723 | 364 (delete-horizontal-space)) |
4934 | 365 ((and (looking-at "(\\*\\|\\*[^)]") |
366 (not (save-excursion | |
367 (search-forward "*)" (pascal-get-end-of-line) t)))) | |
368 (setq setstar t)))) | |
369 ;; If last line was a star comment line then this one shall be too. | |
5723 | 370 (if (null setstar) |
371 (pascal-indent-line) | |
372 (insert "* ")))) | |
4934 | 373 |
374 | |
5723 | 375 (defun electric-pascal-semi-or-dot () |
376 "Insert `;' or `.' character and reindent the line." | |
4934 | 377 (interactive) |
378 (insert last-command-char) | |
379 (save-excursion | |
380 (beginning-of-line) | |
381 (pascal-indent-line)) | |
382 (if pascal-auto-newline | |
383 (electric-pascal-terminate-line))) | |
384 | |
385 (defun electric-pascal-colon () | |
5723 | 386 "Insert `:' and do all indentions except line indent on this line." |
4934 | 387 (interactive) |
388 (insert last-command-char) | |
5723 | 389 ;; Do nothing if within string. |
390 (if (pascal-within-string) | |
391 () | |
392 (save-excursion | |
393 (beginning-of-line) | |
394 (pascal-indent-line)) | |
395 (let ((pascal-tab-always-indent nil)) | |
396 (pascal-indent-command)))) | |
397 | |
4934 | 398 (defun electric-pascal-equal () |
5723 | 399 "Insert `=', and do indention if within type declaration." |
4934 | 400 (interactive) |
401 (insert last-command-char) | |
5723 | 402 (if (eq (car (pascal-calculate-indent)) 'declaration) |
4934 | 403 (let ((pascal-tab-always-indent nil)) |
404 (pascal-indent-command)))) | |
405 | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
406 (defun electric-pascal-hash () |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
407 "Insert `#', and indent to coulmn 0 if this is a CPP directive." |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
408 (interactive) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
409 (insert last-command-char) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
410 (if (save-excursion (beginning-of-line) (looking-at "^[ \t]*#")) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
411 (save-excursion (beginning-of-line) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
412 (delete-horizontal-space)))) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
413 |
4934 | 414 (defun electric-pascal-tab () |
5723 | 415 "Function called when TAB is pressed in Pascal mode." |
4934 | 416 (interactive) |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
417 ;; Do nothing if within a string or in a CPP directive. |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
418 (if (or (pascal-within-string) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
419 (and (not (bolp)) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
420 (save-excursion (beginning-of-line) (eq (following-char) ?#)))) |
5723 | 421 (insert "\t") |
422 ;; If pascal-tab-always-indent, indent the beginning of the line. | |
423 (if pascal-tab-always-indent | |
424 (save-excursion | |
425 (beginning-of-line) | |
426 (pascal-indent-line)) | |
427 (insert "\t")) | |
428 (pascal-indent-command))) | |
429 | |
430 | |
4934 | 431 |
432 ;;; | |
433 ;;; Interactive functions | |
434 ;;; | |
435 (defun pascal-insert-block () | |
5723 | 436 "Insert Pascal begin ... end; block in the code with right indentation." |
4934 | 437 (interactive) |
438 (pascal-indent-line) | |
439 (insert "begin") | |
440 (electric-pascal-terminate-line) | |
441 (save-excursion | |
442 (electric-pascal-terminate-line) | |
443 (insert "end;") | |
444 (beginning-of-line) | |
445 (pascal-indent-line))) | |
446 | |
447 (defun pascal-star-comment () | |
5723 | 448 "Insert Pascal star comment at point." |
4934 | 449 (interactive) |
450 (pascal-indent-line) | |
451 (insert "(*") | |
452 (electric-pascal-terminate-line) | |
453 (save-excursion | |
454 (electric-pascal-terminate-line) | |
5723 | 455 (delete-horizontal-space) |
456 (insert ")")) | |
457 (insert " ")) | |
4934 | 458 |
5723 | 459 (defun pascal-mark-defun () |
4934 | 460 "Mark the current pascal function (or procedure). |
5723 | 461 This puts the mark at the end, and point at the beginning." |
4934 | 462 (interactive) |
463 (push-mark (point)) | |
5723 | 464 (pascal-end-of-defun) |
4934 | 465 (push-mark (point)) |
5723 | 466 (pascal-beg-of-defun) |
467 (if (fboundp 'zmacs-activate-region) | |
468 (zmacs-activate-region))) | |
4934 | 469 |
470 (defun pascal-comment-area (start end) | |
5723 | 471 "Put the region into a Pascal comment. |
472 The comments that are in this area are \"deformed\": | |
473 `*)' becomes `!(*' and `}' becomes `!{'. | |
474 These deformed comments are returned to normal if you use | |
475 \\[pascal-uncomment-area] to undo the commenting. | |
476 | |
477 The commented area starts with `pascal-exclude-str-start', and ends with | |
478 `pascal-include-str-end'. But if you change these variables, | |
479 \\[pascal-uncomment-area] won't recognize the comments." | |
4934 | 480 (interactive "r") |
481 (save-excursion | |
482 ;; Insert start and endcomments | |
483 (goto-char end) | |
484 (if (and (save-excursion (skip-chars-forward " \t") (eolp)) | |
485 (not (save-excursion (skip-chars-backward " \t") (bolp)))) | |
486 (forward-line 1) | |
487 (beginning-of-line)) | |
5723 | 488 (insert pascal-exclude-str-end) |
4934 | 489 (setq end (point)) |
490 (newline) | |
491 (goto-char start) | |
492 (beginning-of-line) | |
5723 | 493 (insert pascal-exclude-str-start) |
4934 | 494 (newline) |
495 ;; Replace end-comments within commented area | |
496 (goto-char end) | |
497 (save-excursion | |
498 (while (re-search-backward "\\*)" start t) | |
499 (replace-match "!(*" t t))) | |
500 (save-excursion | |
501 (while (re-search-backward "}" start t) | |
502 (replace-match "!{" t t))))) | |
503 | |
504 (defun pascal-uncomment-area () | |
5723 | 505 "Uncomment a commented area; change deformed comments back to normal. |
506 This command does nothing if the pointer is not in a commented | |
4934 | 507 area. See also `pascal-comment-area'." |
508 (interactive) | |
509 (save-excursion | |
510 (let ((start (point)) | |
511 (end (point))) | |
512 ;; Find the boundaries of the comment | |
513 (save-excursion | |
5723 | 514 (setq start (progn (search-backward pascal-exclude-str-start nil t) |
4934 | 515 (point))) |
5723 | 516 (setq end (progn (search-forward pascal-exclude-str-end nil t) |
4934 | 517 (point)))) |
518 ;; Check if we're really inside a comment | |
519 (if (or (equal start (point)) (<= end (point))) | |
520 (message "Not standing within commented area.") | |
521 (progn | |
522 ;; Remove endcomment | |
523 (goto-char end) | |
524 (beginning-of-line) | |
525 (let ((pos (point))) | |
526 (end-of-line) | |
527 (delete-region pos (1+ (point)))) | |
528 ;; Change comments back to normal | |
529 (save-excursion | |
530 (while (re-search-backward "!{" start t) | |
531 (replace-match "}" t t))) | |
532 (save-excursion | |
533 (while (re-search-backward "!(\\*" start t) | |
534 (replace-match "*)" t t))) | |
535 ;; Remove startcomment | |
536 (goto-char start) | |
537 (beginning-of-line) | |
538 (let ((pos (point))) | |
539 (end-of-line) | |
540 (delete-region pos (1+ (point))))))))) | |
541 | |
5723 | 542 (defun pascal-beg-of-defun () |
543 "Move backward to the beginning of the current function or procedure." | |
4934 | 544 (interactive) |
5723 | 545 (catch 'found |
546 (if (not (looking-at (concat "\\s \\|\\s)\\|" pascal-defun-re))) | |
547 (forward-sexp 1)) | |
548 (let ((nest 0) (max -1) (func 0) | |
549 (reg (concat pascal-beg-block-re "\\|" | |
550 pascal-end-block-re "\\|" | |
551 pascal-defun-re))) | |
552 (while (re-search-backward reg nil 'move) | |
553 (cond ((let ((state (save-excursion | |
554 (parse-partial-sexp (point-min) (point))))) | |
555 (or (nth 3 state) (nth 4 state))) ; Inside string or comment | |
556 ()) | |
557 ((match-end 1) ; begin|case|record|repeat | |
558 (if (and (looking-at "\\<record\\>") (>= max 0)) | |
559 (setq func (1- func))) | |
560 (setq nest (1+ nest) | |
561 max (max nest max))) | |
562 ((match-end 2) ; end|until | |
563 (if (and (= nest max) (>= max 0)) | |
564 (setq func (1+ func))) | |
565 (setq nest (1- nest))) | |
566 ((match-end 3) ; function|procedure | |
567 (if (= 0 func) | |
568 (throw 'found t) | |
569 (setq func (1- func))))))) | |
570 nil)) | |
4934 | 571 |
5723 | 572 (defun pascal-end-of-defun () |
573 "Move forward to the end of the current function or procedure." | |
4934 | 574 (interactive) |
5723 | 575 (if (looking-at "\\s ") |
576 (forward-sexp 1)) | |
577 (if (not (looking-at pascal-defun-re)) | |
578 (pascal-beg-of-defun)) | |
579 (forward-char 1) | |
580 (let ((nest 0) (func 1) | |
581 (reg (concat pascal-beg-block-re "\\|" | |
582 pascal-end-block-re "\\|" | |
583 pascal-defun-re))) | |
584 (while (and (/= func 0) | |
585 (re-search-forward reg nil 'move)) | |
586 (cond ((let ((state (save-excursion | |
587 (parse-partial-sexp (point-min) (point))))) | |
588 (or (nth 3 state) (nth 4 state))) ; Inside string or comment | |
589 ()) | |
590 ((match-end 1) | |
591 (setq nest (1+ nest)) | |
592 (if (save-excursion | |
593 (goto-char (match-beginning 0)) | |
594 (looking-at "\\<record\\>")) | |
595 (setq func (1+ func)))) | |
596 ((match-end 2) | |
597 (setq nest (1- nest)) | |
598 (if (= nest 0) | |
599 (setq func (1- func)))) | |
600 ((match-end 3) | |
601 (setq func (1+ func)))))) | |
602 (forward-line 1)) | |
4934 | 603 |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
604 (defun pascal-end-of-statement () |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
605 "Move forward to end of current statement." |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
606 (interactive) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
607 (let ((nest 0) pos |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
608 (regexp (concat "\\(" pascal-beg-block-re "\\)\\|\\(" |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
609 pascal-end-block-re "\\)"))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
610 (if (not (looking-at "[ \t\n]")) (forward-sexp -1)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
611 (or (looking-at pascal-beg-block-re) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
612 ;; Skip to end of statement |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
613 (setq pos (catch 'found |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
614 (while t |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
615 (forward-sexp 1) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
616 (cond ((looking-at "[ \t]*;") |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
617 (skip-chars-forward "^;") |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
618 (forward-char 1) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
619 (throw 'found (point))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
620 ((save-excursion |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
621 (forward-sexp -1) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
622 (looking-at pascal-beg-block-re)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
623 (goto-char (match-beginning 0)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
624 (throw 'found nil)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
625 ((eobp) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
626 (throw 'found (point)))))))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
627 (if (not pos) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
628 ;; Skip a whole block |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
629 (catch 'found |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
630 (while t |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
631 (re-search-forward regexp nil 'move) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
632 (setq nest (if (match-end 1) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
633 (1+ nest) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
634 (1- nest))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
635 (cond ((eobp) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
636 (throw 'found (point))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
637 ((= 0 nest) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
638 (throw 'found (pascal-end-of-statement)))))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
639 pos))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
640 |
4934 | 641 (defun pascal-downcase-keywords () |
5723 | 642 "Downcase all Pascal keywords in the buffer." |
4934 | 643 (interactive) |
644 (pascal-change-keywords 'downcase-word)) | |
645 | |
646 (defun pascal-upcase-keywords () | |
5723 | 647 "Upcase all Pascal keywords in the buffer." |
4934 | 648 (interactive) |
649 (pascal-change-keywords 'upcase-word)) | |
650 | |
651 (defun pascal-capitalize-keywords () | |
5723 | 652 "Capitalize all Pascal keywords in the buffer." |
4934 | 653 (interactive) |
654 (pascal-change-keywords 'capitalize-word)) | |
655 | |
5723 | 656 ;; Change the keywords according to argument. |
4934 | 657 (defun pascal-change-keywords (change-word) |
658 (save-excursion | |
5723 | 659 (let ((keyword-re (concat "\\<\\(" |
660 (mapconcat 'identity pascal-keywords "\\|") | |
661 "\\)\\>"))) | |
662 (goto-char (point-min)) | |
663 (while (re-search-forward keyword-re nil t) | |
664 (funcall change-word -1))))) | |
665 | |
666 | |
4934 | 667 |
668 ;;; | |
669 ;;; Other functions | |
670 ;;; | |
671 (defun pascal-set-auto-comments () | |
5723 | 672 "Insert `{ case }' or `{ NAME }' on this line if appropriate. |
673 Insert `{ case }' if there is an `end' on the line which | |
674 ends a case block. Insert `{ NAME }' if there is an `end' | |
675 on the line which ends a function or procedure named NAME." | |
4934 | 676 (save-excursion |
677 (forward-line -1) | |
678 (skip-chars-forward " \t") | |
5723 | 679 (if (and (looking-at "\\<end;") |
4934 | 680 (not (save-excursion |
681 (end-of-line) | |
5723 | 682 (search-backward "{" (pascal-get-beg-of-line) t)))) |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
683 (let ((type (car (pascal-calculate-indent)))) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
684 (if (eq type 'declaration) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
685 () |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
686 (if (eq type 'case) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
687 ;; This is a case block |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
688 (progn |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
689 (end-of-line) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
690 (delete-horizontal-space) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
691 (insert " { case }")) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
692 (let ((nest 1)) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
693 ;; Check if this is the end of a function |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
694 (save-excursion |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
695 (while (not (or (looking-at pascal-defun-re) (bobp))) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
696 (backward-sexp 1) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
697 (cond ((looking-at pascal-beg-block-re) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
698 (setq nest (1- nest))) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
699 ((looking-at pascal-end-block-re) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
700 (setq nest (1+ nest))))) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
701 (if (bobp) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
702 (setq nest 1))) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
703 (if (zerop nest) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
704 (progn |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
705 (end-of-line) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
706 (delete-horizontal-space) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
707 (insert " { ") |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
708 (let (b e) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
709 (save-excursion |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
710 (setq b (progn (pascal-beg-of-defun) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
711 (skip-chars-forward "^ \t") |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
712 (skip-chars-forward " \t") |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
713 (point)) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
714 e (progn (skip-chars-forward "a-zA-Z0-9_") |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
715 (point)))) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
716 (insert-buffer-substring (current-buffer) b e)) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
717 (insert " }")))))))))) |
4934 | 718 |
5723 | 719 |
720 | |
4934 | 721 ;;; |
5723 | 722 ;;; Indentation |
723 ;;; | |
724 (defconst pascal-indent-alist | |
725 '((block . (+ ind pascal-indent-level)) | |
726 (case . (+ ind pascal-case-indent)) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
727 (caseblock . ind) (cpp . 0) |
5723 | 728 (declaration . (+ ind pascal-indent-level)) |
729 (paramlist . (pascal-indent-paramlist t)) | |
730 (comment . (pascal-indent-comment t)) | |
731 (defun . ind) (contexp . ind) | |
732 (unknown . 0) (string . 0))) | |
733 | |
4934 | 734 (defun pascal-indent-command () |
5723 | 735 "Indent for special part of code." |
736 (let* ((indent-str (pascal-calculate-indent)) | |
737 (type (car indent-str)) | |
738 (ind (car (cdr indent-str)))) | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
739 (cond ((and (eq type 'paramlist) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
740 (or (memq 'all pascal-auto-lineup) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
741 (memq 'paramlist pascal-auto-lineup))) |
5723 | 742 (pascal-indent-paramlist) |
743 (pascal-indent-paramlist)) | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
744 ((and (eq type 'declaration) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
745 (or (memq 'all pascal-auto-lineup) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
746 (memq 'declaration pascal-auto-lineup))) |
5723 | 747 (pascal-indent-declaration)) |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
748 ((and (eq type 'case) (not (looking-at "^[ \t]*$")) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
749 (or (memq 'all pascal-auto-lineup) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
750 (memq 'case pascal-auto-lineup))) |
5723 | 751 (pascal-indent-case))) |
752 (if (looking-at "[ \t]+$") | |
753 (skip-chars-forward " \t")))) | |
4934 | 754 |
755 (defun pascal-indent-line () | |
5723 | 756 "Indent current line as a Pascal statement." |
757 (let* ((indent-str (pascal-calculate-indent)) | |
758 (type (car indent-str)) | |
759 (ind (car (cdr indent-str)))) | |
760 (if (looking-at "^[0-9a-zA-Z]+[ \t]*:[^=]") | |
761 (search-forward ":" nil t)) | |
762 (delete-horizontal-space) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
763 ;; Some things should not be indented |
5723 | 764 (if (or (and (eq type 'declaration) (looking-at pascal-declaration-re)) |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
765 (eq type 'cpp) |
5723 | 766 (looking-at pascal-defun-re)) |
767 () | |
768 ;; Other things should have no extra indent | |
769 (if (looking-at pascal-noindent-re) | |
770 (indent-to ind) | |
771 ;; But most lines are treated this way: | |
772 (indent-to (eval (cdr (assoc type pascal-indent-alist)))) | |
773 )))) | |
4934 | 774 |
5723 | 775 (defun pascal-calculate-indent () |
776 "Calculate the indent of the current Pascal line. | |
777 Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | |
778 (save-excursion | |
779 (let* ((oldpos (point)) | |
780 (state (save-excursion (parse-partial-sexp (point-min) (point)))) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
781 (nest 0) (par 0) (complete (looking-at "[ \t]*end\\>")) |
6153
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
782 (elsed (looking-at "[ \t]*else\\>")) |
5723 | 783 (type (catch 'nesting |
784 ;; Check if inside a string, comment or parenthesis | |
785 (cond ((nth 3 state) (throw 'nesting 'string)) | |
786 ((nth 4 state) (throw 'nesting 'comment)) | |
787 ((> (car state) 0) | |
788 (goto-char (scan-lists (point) -1 (car state))) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
789 (setq par (1+ (current-column)))) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
790 ((save-excursion (beginning-of-line) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
791 (eq (following-char) ?#)) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
792 (throw 'nesting 'cpp))) |
5723 | 793 ;; Loop until correct indent is found |
794 (while t | |
795 (backward-sexp 1) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
796 (cond (;--Escape from case statements |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
797 (and (looking-at "[A-Za-z0-9]+[ \t]*:[^=]") |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
798 (not complete) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
799 (save-excursion (skip-chars-backward " \t") |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
800 (bolp)) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
801 (= (save-excursion |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
802 (end-of-line) (backward-sexp) (point)) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
803 (point)) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
804 (> (save-excursion (goto-char oldpos) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
805 (beginning-of-line) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
806 (point)) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
807 (point))) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
808 (throw 'nesting 'caseblock)) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
809 (;--Nest block outwards |
5723 | 810 (looking-at pascal-beg-block-re) |
811 (if (= nest 0) | |
812 (cond ((looking-at "case\\>") | |
813 (throw 'nesting 'case)) | |
814 ((looking-at "record\\>") | |
815 (throw 'nesting 'declaration)) | |
6153
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
816 (t (throw 'nesting 'block))) |
5723 | 817 (setq nest (1- nest)))) |
818 (;--Nest block inwards | |
819 (looking-at pascal-end-block-re) | |
6153
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
820 (if (and (looking-at "end\\s ") |
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
821 elsed (not complete)) |
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
822 (throw 'nesting 'block)) |
5723 | 823 (setq complete t |
824 nest (1+ nest))) | |
825 (;--Defun (or parameter list) | |
826 (looking-at pascal-defun-re) | |
827 (if (= 0 par) | |
828 (throw 'nesting 'defun) | |
829 (setq par 0) | |
830 (let ((n 0)) | |
831 (while (re-search-forward | |
832 "\\(\\<record\\>\\)\\|\\<end\\>" | |
833 oldpos t) | |
834 (if (match-end 1) | |
835 (setq n (1+ n)) (setq n (1- n)))) | |
836 (if (> n 0) | |
837 (throw 'nesting 'declaration) | |
838 (throw 'nesting 'paramlist))))) | |
839 (;--Declaration part | |
840 (looking-at pascal-declaration-re) | |
6153
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
841 (if (save-excursion |
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
842 (goto-char oldpos) |
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
843 (forward-line -1) |
40e4038bd544
(pascal-calculate-indent): Fixed indentation bug
Richard M. Stallman <rms@gnu.org>
parents:
6123
diff
changeset
|
844 (looking-at "^[ \t]*$")) |
5723 | 845 (throw 'nesting 'unknown) |
846 (throw 'nesting 'declaration))) | |
847 (;--If, else or while statement | |
848 (and (not complete) | |
849 (looking-at pascal-sub-block-re)) | |
850 (throw 'nesting 'block)) | |
851 (;--Found complete statement | |
852 (save-excursion (forward-sexp 1) | |
853 (= (following-char) ?\;)) | |
854 (setq complete t)) | |
855 (;--No known statements | |
856 (bobp) | |
857 (throw 'nesting 'unknown)) | |
858 ))))) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
859 |
5723 | 860 ;; Return type of block and indent level. |
861 (if (> par 0) ; Unclosed Parenthesis | |
862 (list 'contexp par) | |
863 (list type (pascal-indent-level)))))) | |
4934 | 864 |
5723 | 865 (defun pascal-indent-level () |
866 "Return the indent-level the current statement has. | |
867 Do not count labels, case-statements or records." | |
4934 | 868 (save-excursion |
869 (beginning-of-line) | |
5723 | 870 (if (looking-at "[ \t]*[0-9a-zA-Z]+[ \t]*:[^=]") |
871 (search-forward ":" nil t) | |
872 (if (looking-at ".*=[ \t]*record\\>") | |
873 (search-forward "=" nil t))) | |
4934 | 874 (skip-chars-forward " \t") |
875 (current-column))) | |
876 | |
5723 | 877 (defun pascal-indent-comment (&optional arg) |
878 "Indent current line as comment. | |
879 If optional arg is non-nil, just return the | |
880 column number the line should be indented to." | |
881 (let* ((stcol (save-excursion | |
882 (re-search-backward "(\\*\\|{" nil t) | |
883 (1+ (current-column))))) | |
884 (if arg stcol | |
885 (delete-horizontal-space) | |
886 (indent-to stcol)))) | |
887 | |
888 (defun pascal-indent-case () | |
889 "Indent within case statements." | |
890 (skip-chars-forward ": \t") | |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
891 (let ((end (prog2 |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
892 (end-of-line) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
893 (point-marker) |
5723 | 894 (re-search-backward "\\<case\\>" nil t))) |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
895 (beg (point)) oldpos |
5723 | 896 (ind 0)) |
897 ;; Get right indent | |
898 (while (< (point) (marker-position end)) | |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
899 (if (re-search-forward |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
900 "^[ \t]*[^ \t,:]+[ \t]*\\(,[ \t]*[^ \t,:]+[ \t]*\\)*:" |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
901 (marker-position end) 'move) |
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
902 (forward-char -1)) |
5723 | 903 (delete-horizontal-space) |
904 (if (> (current-column) ind) | |
905 (setq ind (current-column))) | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
906 (pascal-end-of-statement)) |
5723 | 907 (goto-char beg) |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
908 (setq oldpos (marker-position end)) |
5723 | 909 ;; Indent all case statements |
910 (while (< (point) (marker-position end)) | |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
911 (if (re-search-forward |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
912 "^[ \t]*[^][ \t,\\.:]+[ \t]*\\(,[ \t]*[^ \t,:]+[ \t]*\\)*:" |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
913 (marker-position end) 'move) |
5723 | 914 (forward-char -1)) |
915 (indent-to (1+ ind)) | |
916 (if (/= (following-char) ?:) | |
917 () | |
918 (forward-char 1) | |
919 (delete-horizontal-space) | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
920 (insert " ")) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
921 (setq oldpos (point)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
922 (pascal-end-of-statement)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
923 (goto-char oldpos))) |
5723 | 924 |
925 (defun pascal-indent-paramlist (&optional arg) | |
926 "Indent current line in parameterlist. | |
927 If optional arg is non-nil, just return the | |
928 indent of the current line in parameterlist." | |
929 (save-excursion | |
930 (let* ((oldpos (point)) | |
931 (stpos (progn (goto-char (scan-lists (point) -1 1)) (point))) | |
932 (stcol (1+ (current-column))) | |
933 (edpos (progn (pascal-declaration-end) | |
934 (search-backward ")" (pascal-get-beg-of-line) t) | |
935 (point))) | |
936 (usevar (re-search-backward "\\<var\\>" stpos t))) | |
937 (if arg (progn | |
938 ;; If arg, just return indent | |
939 (goto-char oldpos) | |
940 (beginning-of-line) | |
941 (if (or (not usevar) (looking-at "[ \t]*var\\>")) | |
942 stcol (+ 4 stcol))) | |
943 (goto-char stpos) | |
944 (forward-char 1) | |
945 (delete-horizontal-space) | |
946 (if (and usevar (not (looking-at "var\\>"))) | |
947 (indent-to (+ 4 stcol))) | |
948 (pascal-indent-declaration nil stpos edpos))))) | |
949 | |
950 (defun pascal-indent-declaration (&optional arg start end) | |
951 "Indent current lines as declaration, lining up the `:'s or `='s." | |
952 (let ((pos (point-marker))) | |
953 (if (and (not (or arg start)) (not (pascal-declaration-beg))) | |
954 () | |
955 (let ((lineup (if (or (looking-at "\\<var\\>\\|\\<record\\>") arg start) | |
956 ":" "=")) | |
957 (stpos (if start start | |
958 (forward-word 2) (backward-word 1) (point))) | |
959 (edpos (set-marker (make-marker) | |
960 (if end end | |
961 (max (progn (pascal-declaration-end) | |
962 (point)) | |
963 pos)))) | |
964 ind) | |
965 | |
966 (goto-char stpos) | |
967 ;; Indent lines in record block | |
968 (if arg | |
969 (while (<= (point) (marker-position edpos)) | |
970 (beginning-of-line) | |
971 (delete-horizontal-space) | |
972 (if (looking-at "end\\>") | |
973 (indent-to arg) | |
974 (indent-to (+ arg pascal-indent-level))) | |
975 (forward-line 1))) | |
976 | |
977 ;; Do lineup | |
978 (setq ind (pascal-get-lineup-indent stpos edpos lineup)) | |
979 (goto-char stpos) | |
980 (while (<= (point) (marker-position edpos)) | |
981 (if (search-forward lineup (pascal-get-end-of-line) 'move) | |
982 (forward-char -1)) | |
983 (delete-horizontal-space) | |
984 (indent-to ind) | |
985 (if (not (looking-at lineup)) | |
986 (forward-line 1) ; No more indent if there is no : or = | |
987 (forward-char 1) | |
988 (delete-horizontal-space) | |
989 (insert " ") | |
990 ;; Indent record block | |
991 (if (looking-at "record\\>") | |
992 (pascal-indent-declaration (current-column))) | |
993 (forward-line 1))))) | |
994 | |
995 ;; If arg - move point | |
996 (if arg (forward-line -1) | |
997 (goto-char (marker-position pos))))) | |
998 | |
999 ; "Return the indent level that will line up several lines within the region | |
1000 ;from b to e nicely. The lineup string is str." | |
1001 (defun pascal-get-lineup-indent (b e str) | |
1002 (save-excursion | |
1003 (let ((ind 0) | |
1004 (reg (concat str "\\|\\(\\<record\\>\\)")) | |
1005 nest) | |
1006 (goto-char b) | |
1007 ;; Get rightmost position | |
1008 (while (< (point) e) | |
1009 (setq nest 1) | |
1010 (if (re-search-forward reg (min e (pascal-get-end-of-line 2)) 'move) | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1011 (progn |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1012 ;; Skip record blocks |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1013 (if (match-beginning 1) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1014 (pascal-declaration-end) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1015 (progn |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1016 (goto-char (match-beginning 0)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1017 (skip-chars-backward " \t") |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1018 (if (> (current-column) ind) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1019 (setq ind (current-column))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1020 (goto-char (match-end 0))))))) |
5723 | 1021 ;; In case no lineup was found |
1022 (if (> ind 0) | |
1023 (1+ ind) | |
1024 ;; No lineup-string found | |
1025 (goto-char b) | |
1026 (end-of-line) | |
1027 (skip-chars-backward " \t") | |
1028 (1+ (current-column)))))) | |
1029 | |
1030 | |
4934 | 1031 |
5723 | 1032 ;;; |
1033 ;;; Completion | |
1034 ;;; | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1035 (defvar pascal-str nil) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1036 (defvar pascal-all nil) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1037 (defvar pascal-pred nil) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1038 (defvar pascal-buffer-to-use nil) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1039 (defvar pascal-flag nil) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1040 |
5723 | 1041 (defun pascal-string-diff (str1 str2) |
1042 "Return index of first letter where STR1 and STR2 differs." | |
1043 (catch 'done | |
1044 (let ((diff 0)) | |
1045 (while t | |
1046 (if (or (> (1+ diff) (length str1)) | |
1047 (> (1+ diff) (length str2))) | |
1048 (throw 'done diff)) | |
1049 (or (equal (aref str1 diff) (aref str2 diff)) | |
1050 (throw 'done diff)) | |
1051 (setq diff (1+ diff)))))) | |
1052 | |
1053 ;; Calculate all possible completions for functions if argument is `function', | |
1054 ;; completions for procedures if argument is `procedure' or both functions and | |
1055 ;; procedures otherwise. | |
1056 | |
1057 (defun pascal-func-completion (type) | |
1058 ;; Build regular expression for function/procedure names | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1059 (if (string= pascal-str "") |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1060 (setq pascal-str "[a-zA-Z_]")) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1061 (let ((pascal-str (concat (cond |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1062 ((eq type 'procedure) "\\<\\(procedure\\)\\s +") |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1063 ((eq type 'function) "\\<\\(function\\)\\s +") |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1064 (t "\\<\\(function\\|procedure\\)\\s +")) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1065 "\\<\\(" pascal-str "[a-zA-Z0-9_.]*\\)\\>")) |
5723 | 1066 match) |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1067 |
5723 | 1068 (if (not (looking-at "\\<\\(function\\|procedure\\)\\>")) |
1069 (re-search-backward "\\<\\(function\\|procedure\\)\\>" nil t)) | |
1070 (forward-char 1) | |
1071 | |
1072 ;; Search through all reachable functions | |
1073 (while (pascal-beg-of-defun) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1074 (if (re-search-forward pascal-str (pascal-get-end-of-line) t) |
5723 | 1075 (progn (setq match (buffer-substring (match-beginning 2) |
1076 (match-end 2))) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1077 (if (or (null pascal-pred) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1078 (funcall pascal-pred match)) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1079 (setq pascal-all (cons match pascal-all))))) |
5723 | 1080 (goto-char (match-beginning 0))))) |
1081 | |
1082 (defun pascal-get-completion-decl () | |
1083 ;; Macro for searching through current declaration (var, type or const) | |
1084 ;; for matches of `str' and adding the occurence tp `all' | |
1085 (let ((end (save-excursion (pascal-declaration-end) | |
1086 (point))) | |
1087 match) | |
1088 ;; Traverse lines | |
1089 (while (< (point) end) | |
1090 (if (re-search-forward "[:=]" (pascal-get-end-of-line) t) | |
1091 ;; Traverse current line | |
1092 (while (and (re-search-backward | |
1093 (concat "\\((\\|\\<\\(var\\|type\\|const\\)\\>\\)\\|" | |
1094 pascal-symbol-re) | |
1095 (pascal-get-beg-of-line) t) | |
1096 (not (match-end 1))) | |
1097 (setq match (buffer-substring (match-beginning 0) (match-end 0))) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1098 (if (string-match (concat "\\<" pascal-str) match) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1099 (if (or (null pascal-pred) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1100 (funcall pascal-pred match)) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1101 (setq pascal-all (cons match pascal-all)))))) |
5723 | 1102 (if (re-search-forward "\\<record\\>" (pascal-get-end-of-line) t) |
1103 (pascal-declaration-end) | |
1104 (forward-line 1))))) | |
1105 | |
1106 (defun pascal-type-completion () | |
1107 "Calculate all possible completions for types." | |
1108 (let ((start (point)) | |
1109 goon) | |
1110 ;; Search for all reachable type declarations | |
1111 (while (or (pascal-beg-of-defun) | |
1112 (setq goon (not goon))) | |
1113 (save-excursion | |
1114 (if (and (< start (prog1 (save-excursion (pascal-end-of-defun) | |
1115 (point)) | |
1116 (forward-char 1))) | |
1117 (re-search-forward | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1118 "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>" |
5723 | 1119 start t) |
1120 (not (match-end 1))) | |
1121 ;; Check current type declaration | |
1122 (pascal-get-completion-decl)))))) | |
1123 | |
1124 (defun pascal-var-completion () | |
1125 "Calculate all possible completions for variables (or constants)." | |
1126 (let ((start (point)) | |
1127 goon twice) | |
1128 ;; Search for all reachable var declarations | |
1129 (while (or (pascal-beg-of-defun) | |
1130 (setq goon (not goon))) | |
1131 (save-excursion | |
1132 (if (> start (prog1 (save-excursion (pascal-end-of-defun) | |
1133 (point)))) | |
1134 () ; Declarations not reacable | |
1135 (if (search-forward "(" (pascal-get-end-of-line) t) | |
1136 ;; Check parameterlist | |
1137 (pascal-get-completion-decl)) | |
1138 (setq twice 2) | |
1139 (while (>= (setq twice (1- twice)) 0) | |
1140 (cond ((and (re-search-forward | |
1141 (concat "\\<\\(var\\|const\\)\\>\\|" | |
1142 "\\<\\(begin\\|function\\|procedure\\)\\>") | |
1143 start t) | |
1144 (not (match-end 2))) | |
1145 ;; Check var/const declarations | |
1146 (pascal-get-completion-decl)) | |
1147 ((match-end 2) | |
1148 (setq twice 0))))))))) | |
1149 | |
1150 | |
1151 (defun pascal-keyword-completion (keyword-list) | |
1152 "Give list of all possible completions of keywords in KEYWORD-LIST." | |
1153 (mapcar '(lambda (s) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1154 (if (string-match (concat "\\<" pascal-str) s) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1155 (if (or (null pascal-pred) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1156 (funcall pascal-pred s)) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1157 (setq pascal-all (cons s pascal-all))))) |
5723 | 1158 keyword-list)) |
1159 | |
1160 ;; Function passed to completing-read, try-completion or | |
1161 ;; all-completions to get completion on STR. If predicate is non-nil, | |
1162 ;; it must be a function to be called for every match to check if this | |
1163 ;; should really be a match. If flag is t, the function returns a list | |
1164 ;; of all possible completions. If it is nil it returns a string, the | |
1165 ;; longest possible completion, or t if STR is an exact match. If flag | |
1166 ;; is 'lambda, the function returns t if STR is an exact match, nil | |
1167 ;; otherwise. | |
1168 | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1169 (defun pascal-completion (pascal-str pascal-pred pascal-flag) |
4934 | 1170 (save-excursion |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1171 (let ((pascal-all nil)) |
5723 | 1172 ;; Set buffer to use for searching labels. This should be set |
1173 ;; within functins which use pascal-completions | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1174 (set-buffer pascal-buffer-to-use) |
5723 | 1175 |
1176 ;; Determine what should be completed | |
1177 (let ((state (car (pascal-calculate-indent)))) | |
1178 (cond (;--Within a declaration or parameterlist | |
1179 (or (eq state 'declaration) (eq state 'paramlist) | |
1180 (and (eq state 'defun) | |
1181 (save-excursion | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1182 (re-search-backward ")[ \t]*:" |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1183 (pascal-get-beg-of-line) t)))) |
5723 | 1184 (if (or (eq state 'paramlist) (eq state 'defun)) |
1185 (pascal-beg-of-defun)) | |
1186 (pascal-type-completion) | |
1187 (pascal-keyword-completion pascal-type-keywords)) | |
1188 (;--Starting a new statement | |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1189 (and (not (eq state 'contexp)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1190 (save-excursion |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1191 (skip-chars-backward "a-zA-Z0-9_.") |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1192 (backward-sexp 1) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1193 (or (looking-at pascal-nosemi-re) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1194 (progn |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1195 (forward-sexp 1) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1196 (looking-at "\\s *\\(;\\|:[^=]\\)"))))) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1197 (save-excursion (pascal-var-completion)) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1198 (pascal-func-completion 'procedure) |
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1199 (pascal-keyword-completion pascal-start-keywords)) |
5723 | 1200 (t;--Anywhere else |
1201 (save-excursion (pascal-var-completion)) | |
1202 (pascal-func-completion 'function) | |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
1203 (pascal-keyword-completion pascal-separator-keywords)))) |
8689
499bf32bfd9b
(pascal-auto-lineup): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
6942
diff
changeset
|
1204 |
5723 | 1205 ;; Now we have built a list of all matches. Give response to caller |
1206 (pascal-completion-response)))) | |
4934 | 1207 |
5723 | 1208 (defun pascal-completion-response () |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1209 (cond ((or (equal pascal-flag 'lambda) (null pascal-flag)) |
5723 | 1210 ;; This was not called by all-completions |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1211 (if (null pascal-all) |
5723 | 1212 ;; Return nil if there was no matching label |
1213 nil | |
1214 ;; Get longest string common in the labels | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1215 (let* ((elm (cdr pascal-all)) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1216 (match (car pascal-all)) |
5723 | 1217 (min (length match)) |
1218 exact tmp) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1219 (if (string= match pascal-str) |
5723 | 1220 ;; Return t if first match was an exact match |
1221 (setq match t) | |
1222 (while (not (null elm)) | |
1223 ;; Find longest common string | |
1224 (if (< (setq tmp (pascal-string-diff match (car elm))) min) | |
1225 (progn | |
1226 (setq min tmp) | |
1227 (setq match (substring match 0 min)))) | |
1228 ;; Terminate with match=t if this is an exact match | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1229 (if (string= (car elm) pascal-str) |
5723 | 1230 (progn |
1231 (setq match t) | |
1232 (setq elm nil)) | |
1233 (setq elm (cdr elm))))) | |
1234 ;; If this is a test just for exact match, return nil ot t | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1235 (if (and (equal pascal-flag 'lambda) (not (equal match 't))) |
5723 | 1236 nil |
1237 match)))) | |
1238 ;; If flag is t, this was called by all-completions. Return | |
1239 ;; list of all possible completions | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1240 (pascal-flag |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1241 pascal-all))) |
5723 | 1242 |
1243 (defvar pascal-last-word-numb 0) | |
1244 (defvar pascal-last-word-shown nil) | |
1245 (defvar pascal-last-completions nil) | |
1246 | |
1247 (defun pascal-complete-word () | |
1248 "Complete word at current point. | |
1249 \(See also `pascal-toggle-completions', `pascal-type-keywords', | |
6316
1032840397be
(pascal-indent-case): Handle comma separated list.
Richard M. Stallman <rms@gnu.org>
parents:
6153
diff
changeset
|
1250 `pascal-start-keywords' and `pascal-separator-keywords'.)" |
5723 | 1251 (interactive) |
1252 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
1253 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1254 (pascal-str (buffer-substring b e)) |
5723 | 1255 ;; The following variable is used in pascal-completion |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1256 (pascal-buffer-to-use (current-buffer)) |
5723 | 1257 (allcomp (if (and pascal-toggle-completions |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1258 (string= pascal-last-word-shown pascal-str)) |
5723 | 1259 pascal-last-completions |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1260 (all-completions pascal-str 'pascal-completion))) |
5723 | 1261 (match (if pascal-toggle-completions |
1262 "" (try-completion | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1263 pascal-str (mapcar '(lambda (elm) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1264 (cons elm 0)) allcomp))))) |
5723 | 1265 ;; Delete old string |
1266 (delete-region b e) | |
1267 | |
1268 ;; Toggle-completions inserts whole labels | |
1269 (if pascal-toggle-completions | |
4934 | 1270 (progn |
5723 | 1271 ;; Update entry number in list |
1272 (setq pascal-last-completions allcomp | |
1273 pascal-last-word-numb | |
1274 (if (>= pascal-last-word-numb (1- (length allcomp))) | |
1275 0 | |
1276 (1+ pascal-last-word-numb))) | |
1277 (setq pascal-last-word-shown (elt allcomp pascal-last-word-numb)) | |
1278 ;; Display next match or same string if no match was found | |
1279 (if (not (null allcomp)) | |
1280 (insert "" pascal-last-word-shown) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1281 (insert "" pascal-str) |
5723 | 1282 (message "(No match)"))) |
1283 ;; The other form of completion does not necessarly do that. | |
1284 | |
1285 ;; Insert match if found, or the original string if no match | |
1286 (if (or (null match) (equal match 't)) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1287 (progn (insert "" pascal-str) |
5723 | 1288 (message "(No match)")) |
1289 (insert "" match)) | |
1290 ;; Give message about current status of completion | |
1291 (cond ((equal match 't) | |
1292 (if (not (null (cdr allcomp))) | |
1293 (message "(Complete but not unique)") | |
1294 (message "(Sole completion)"))) | |
1295 ;; Display buffer if the current completion didn't help | |
1296 ;; on completing the label. | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1297 ((and (not (null (cdr allcomp))) (= (length pascal-str) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1298 (length match))) |
5723 | 1299 (with-output-to-temp-buffer "*Completions*" |
1300 (display-completion-list allcomp)) | |
1301 ;; Wait for a keypress. Then delete *Completion* window | |
1302 (momentary-string-display "" (point)) | |
1303 (delete-window (get-buffer-window (get-buffer "*Completions*"))) | |
1304 ))))) | |
1305 | |
1306 (defun pascal-show-completions () | |
1307 "Show all possible completions at current point." | |
1308 (interactive) | |
1309 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
1310 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1311 (pascal-str (buffer-substring b e)) |
5723 | 1312 ;; The following variable is used in pascal-completion |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1313 (pascal-buffer-to-use (current-buffer)) |
5723 | 1314 (allcomp (if (and pascal-toggle-completions |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1315 (string= pascal-last-word-shown pascal-str)) |
5723 | 1316 pascal-last-completions |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1317 (all-completions pascal-str 'pascal-completion)))) |
5723 | 1318 ;; Show possible completions in a temporary buffer. |
1319 (with-output-to-temp-buffer "*Completions*" | |
1320 (display-completion-list allcomp)) | |
1321 ;; Wait for a keypress. Then delete *Completion* window | |
1322 (momentary-string-display "" (point)) | |
1323 (delete-window (get-buffer-window (get-buffer "*Completions*"))))) | |
1324 | |
1325 | |
1326 (defun pascal-get-default-symbol () | |
1327 "Return symbol around current point as a string." | |
1328 (save-excursion | |
1329 (buffer-substring (progn | |
1330 (skip-chars-backward " \t") | |
1331 (skip-chars-backward "a-zA-Z0-9_") | |
1332 (point)) | |
1333 (progn | |
1334 (skip-chars-forward "a-zA-Z0-9_") | |
1335 (point))))) | |
1336 | |
1337 (defun pascal-build-defun-re (str &optional arg) | |
1338 "Return function/procedure starting with STR as regular expression. | |
1339 With optional second arg non-nil, STR is the complete name of the instruction." | |
1340 (if arg | |
1341 (concat "^\\(function\\|procedure\\)[ \t]+\\(" str "\\)\\>") | |
1342 (concat "^\\(function\\|procedure\\)[ \t]+\\(" str "[a-zA-Z0-9_]*\\)\\>"))) | |
1343 | |
1344 ;; Function passed to completing-read, try-completion or | |
1345 ;; all-completions to get completion on any function name. If | |
1346 ;; predicate is non-nil, it must be a function to be called for every | |
1347 ;; match to check if this should really be a match. If flag is t, the | |
1348 ;; function returns a list of all possible completions. If it is nil | |
1349 ;; it returns a string, the longest possible completion, or t if STR | |
1350 ;; is an exact match. If flag is 'lambda, the function returns t if | |
1351 ;; STR is an exact match, nil otherwise. | |
1352 | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1353 (defun pascal-comp-defun (pascal-str pascal-pred pascal-flag) |
5723 | 1354 (save-excursion |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1355 (let ((pascal-all nil) |
5723 | 1356 match) |
1357 | |
1358 ;; Set buffer to use for searching labels. This should be set | |
1359 ;; within functins which use pascal-completions | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1360 (set-buffer pascal-buffer-to-use) |
5723 | 1361 |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1362 (let ((pascal-str pascal-str)) |
5723 | 1363 ;; Build regular expression for functions |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1364 (if (string= pascal-str "") |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1365 (setq pascal-str (pascal-build-defun-re "[a-zA-Z_]")) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1366 (setq pascal-str (pascal-build-defun-re pascal-str))) |
5723 | 1367 (goto-char (point-min)) |
1368 | |
1369 ;; Build a list of all possible completions | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1370 (while (re-search-forward pascal-str nil t) |
5723 | 1371 (setq match (buffer-substring (match-beginning 2) (match-end 2))) |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1372 (if (or (null pascal-pred) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1373 (funcall pascal-pred match)) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1374 (setq pascal-all (cons match pascal-all))))) |
5723 | 1375 |
1376 ;; Now we have built a list of all matches. Give response to caller | |
1377 (pascal-completion-response)))) | |
1378 | |
1379 (defun pascal-goto-defun () | |
1380 "Move to specified Pascal function/procedure. | |
1381 The default is a name found in the buffer around point." | |
1382 (interactive) | |
1383 (let* ((default (pascal-get-default-symbol)) | |
1384 ;; The following variable is used in pascal-comp-function | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1385 (pascal-buffer-to-use (current-buffer)) |
5723 | 1386 (default (if (pascal-comp-defun default nil 'lambda) |
1387 default "")) | |
1388 (label (if (not (string= default "")) | |
1389 ;; Do completion with default | |
1390 (completing-read (concat "Label: (default " default ") ") | |
1391 'pascal-comp-defun nil t "") | |
1392 ;; There is no default value. Complete without it | |
1393 (completing-read "Label: " | |
1394 'pascal-comp-defun nil t "")))) | |
1395 ;; If there was no response on prompt, use default value | |
1396 (if (string= label "") | |
1397 (setq label default)) | |
1398 ;; Goto right place in buffer if label is not an empty string | |
1399 (or (string= label "") | |
1400 (progn | |
1401 (goto-char (point-min)) | |
1402 (re-search-forward (pascal-build-defun-re label t)) | |
1403 (beginning-of-line))))) | |
1404 | |
1405 | |
4934 | 1406 |
5723 | 1407 ;;; |
1408 ;;; Pascal-outline-mode | |
1409 ;;; | |
1410 (defvar pascal-outline-map nil "Keymap used in Pascal Outline mode.") | |
1411 | |
1412 (if pascal-outline-map | |
1413 nil | |
1414 (if (boundp 'set-keymap-name) | |
1415 (set-keymap-name pascal-outline-map 'pascal-outline-map)) | |
1416 (if (not (boundp 'set-keymap-parent)) | |
1417 (setq pascal-outline-map (copy-keymap pascal-mode-map)) | |
1418 (setq pascal-outline-map (make-sparse-keymap)) | |
1419 (set-keymap-parent pascal-outline-map pascal-mode-map)) | |
10446
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
1420 (define-key pascal-outline-map "\M-\C-a" 'pascal-outline-prev-defun) |
034609a036b1
(pascal-mode-map, pascal-outline-map):
Richard M. Stallman <rms@gnu.org>
parents:
9479
diff
changeset
|
1421 (define-key pascal-outline-map "\M-\C-e" 'pascal-outline-next-defun) |
6942
90305d5fe5aa
(pascal-outline-map): Move pascal-outline-goto-defun to C-c C-d.
Richard M. Stallman <rms@gnu.org>
parents:
6316
diff
changeset
|
1422 (define-key pascal-outline-map "\C-c\C-d" 'pascal-outline-goto-defun) |
5723 | 1423 (define-key pascal-outline-map "\C-c\C-s" 'pascal-show-all) |
1424 (define-key pascal-outline-map "\C-c\C-h" 'pascal-hide-other-defuns)) | |
1425 | |
1426 (defvar pascal-outline-mode nil "Non-nil while using Pascal Outline mode.") | |
1427 (make-variable-buffer-local 'pascal-outline-mode) | |
1428 (set-default 'pascal-outline-mode nil) | |
1429 (if (not (assoc 'pascal-outline-mode minor-mode-alist)) | |
1430 (setq minor-mode-alist (append minor-mode-alist | |
1431 (list '(pascal-outline-mode " Outl"))))) | |
1432 | |
1433 (defun pascal-outline (&optional arg) | |
1434 "Outline-line minor mode for Pascal mode. | |
1435 When in Pascal Outline mode, portions | |
1436 of the text being edited may be made invisible. \\<pascal-outline-map> | |
1437 | |
1438 Pascal Outline mode provides some additional commands. | |
1439 | |
1440 \\[pascal-outline-prev-defun]\ | |
1441 \t- Move to previous function/procedure, hiding everything else. | |
1442 \\[pascal-outline-next-defun]\ | |
1443 \t- Move to next function/procedure, hiding everything else. | |
1444 \\[pascal-outline-goto-defun]\ | |
1445 \t- Goto function/procedure prompted for in minibuffer, | |
1446 \t hide all other functions. | |
1447 \\[pascal-show-all]\t- Show the whole buffer. | |
1448 \\[pascal-hide-other-defuns]\ | |
1449 \t- Hide everything but the current function (function under the cursor). | |
1450 \\[pascal-outline]\t- Leave pascal-outline-mode." | |
1451 (interactive "P") | |
1452 (setq pascal-outline-mode | |
1453 (if (null arg) (not pascal-outline-mode) t)) | |
1454 (if (boundp 'redraw-mode-line) | |
1455 (redraw-mode-line)) | |
1456 (if pascal-outline-mode | |
1457 (progn | |
1458 (setq selective-display t) | |
1459 (use-local-map pascal-outline-map)) | |
1460 (progn | |
1461 (setq selective-display nil) | |
1462 (pascal-show-all) | |
1463 (use-local-map pascal-mode-map)))) | |
1464 | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1465 (defun pascal-outline-change (b e pascal-flag) |
5723 | 1466 (let ((modp (buffer-modified-p))) |
1467 (unwind-protect | |
10534
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1468 (subst-char-in-region b e (if (= pascal-flag ?\n) |
38b5efae433a
(pascal-*-completion, pascal-comp-defun)
Richard M. Stallman <rms@gnu.org>
parents:
10446
diff
changeset
|
1469 ?\^M ?\n) pascal-flag) |
5723 | 1470 (set-buffer-modified-p modp)))) |
1471 | |
1472 (defun pascal-show-all () | |
1473 "Show all of the text in the buffer." | |
1474 (interactive) | |
1475 (pascal-outline-change (point-min) (point-max) ?\n)) | |
1476 | |
1477 (defun pascal-hide-other-defuns () | |
1478 "Show only the current defun." | |
1479 (interactive) | |
1480 (save-excursion | |
1481 (let ((beg (progn (if (not (looking-at "\\(function\\|procedure\\)\\>")) | |
1482 (pascal-beg-of-defun)) | |
1483 (point))) | |
1484 (end (progn (pascal-end-of-defun) | |
1485 (backward-sexp 1) | |
1486 (search-forward "\n\\|\^M" nil t) | |
1487 (point))) | |
1488 (opoint (point-min))) | |
1489 (goto-char (point-min)) | |
1490 | |
1491 ;; Hide all functions before current function | |
1492 (while (re-search-forward "^\\(function\\|procedure\\)\\>" beg 'move) | |
1493 (pascal-outline-change opoint (1- (match-beginning 0)) ?\^M) | |
1494 (setq opoint (point)) | |
1495 ;; Functions may be nested | |
1496 (if (> (progn (pascal-end-of-defun) (point)) beg) | |
1497 (goto-char opoint))) | |
1498 (if (> beg opoint) | |
1499 (pascal-outline-change opoint (1- beg) ?\^M)) | |
1500 | |
1501 ;; Show current function | |
1502 (pascal-outline-change beg end ?\n) | |
1503 ;; Hide nested functions | |
1504 (forward-char 1) | |
1505 (while (re-search-forward "^\\(function\\|procedure\\)\\>" end 'move) | |
1506 (setq opoint (point)) | |
1507 (pascal-end-of-defun) | |
1508 (pascal-outline-change opoint (point) ?\^M)) | |
1509 | |
1510 (goto-char end) | |
1511 (setq opoint end) | |
1512 | |
1513 ;; Hide all function after current function | |
1514 (while (re-search-forward "^\\(function\\|procedure\\)\\>" nil 'move) | |
1515 (pascal-outline-change opoint (1- (match-beginning 0)) ?\^M) | |
1516 (setq opoint (point)) | |
1517 (pascal-end-of-defun)) | |
1518 (pascal-outline-change opoint (point-max) ?\^M) | |
1519 | |
1520 ;; Hide main program | |
1521 (if (< (progn (forward-line -1) (point)) end) | |
4934 | 1522 (progn |
5723 | 1523 (goto-char beg) |
1524 (pascal-end-of-defun) | |
1525 (backward-sexp 1) | |
1526 (pascal-outline-change (point) (point-max) ?\^M)))))) | |
1527 | |
1528 (defun pascal-outline-next-defun () | |
1529 "Move to next function/procedure, hiding all others." | |
1530 (interactive) | |
1531 (pascal-end-of-defun) | |
1532 (pascal-hide-other-defuns)) | |
4934 | 1533 |
5723 | 1534 (defun pascal-outline-prev-defun () |
1535 "Move to previous function/procedure, hiding all others." | |
1536 (interactive) | |
1537 (pascal-beg-of-defun) | |
1538 (pascal-hide-other-defuns)) | |
4934 | 1539 |
5723 | 1540 (defun pascal-outline-goto-defun () |
1541 "Move to specified function/procedure, hiding all others." | |
1542 (interactive) | |
1543 (pascal-goto-defun) | |
1544 (pascal-hide-other-defuns)) | |
1545 | |
1546 ;;; pascal.el ends here |