Mercurial > emacs
annotate lisp/progmodes/fortran.el @ 8518:44ff33b29c3e
(one-window-p): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 11 Aug 1994 20:25:20 +0000 |
parents | b26a8476561d |
children | 59901c9aa208 |
rev | line source |
---|---|
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
1 ;;; fortran.el --- Fortran mode for GNU Emacs |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
2 |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
3 ;;; Copyright (c) 1986, 1993, 1994 Free Software Foundation, Inc. |
845 | 4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
5 ;; Author: Michael D. Prange <prange@erl.mit.edu> |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
6 ;; Maintainer: bug-fortran-mode@erl.mit.edu |
7692
ce33fcd2ce22
(fortran-link-matching-do): Ignore DO statements with line numbers.
Richard M. Stallman <rms@gnu.org>
parents:
6731
diff
changeset
|
7 ;; Version 1.30.5 (May 20, 1994) |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
8 ;; Keywords: languages |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
9 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
11 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
15 ;; any later version. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
16 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
20 ;; GNU General Public License for more details. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
21 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
25 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
26 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
27 |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
28 ;; Fortran mode has been upgraded and is now maintained by Stephen A. Wood |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
29 ;; (saw@cebaf.gov). It now will use either fixed format continuation line |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
30 ;; markers (character in 6th column), or tab format continuation line style |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
31 ;; (digit after a TAB character.) A auto-fill mode has been added to |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
32 ;; automatically wrap fortran lines that get too long. |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
33 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
34 ;; We acknowledge many contributions and valuable suggestions by |
1548 | 35 ;; Lawrence R. Dodd, Ralf Fassel, Ralph Finch, Stephen Gildea, |
36 ;; Dr. Anil Gokhale, Ulrich Mueller, Mark Neale, Eric Prestemon, | |
37 ;; Gary Sabot and Richard Stallman. | |
38 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
39 ;;; This file may be used with GNU Emacs version 18.xx if the following |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
40 ;;; variable and function substitutions are made. |
1862
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
41 ;;; Replace: |
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
42 ;;; frame-width with screen-width |
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
43 ;;; auto-fill-function with auto-fill-hook |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
44 ;;; comment-indent-function with comment-indent-hook |
1862
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
45 ;;; (setq unread-command-events (list c)) with (setq unread-command-char c) |
332 | 46 |
47 ;;; Bugs to bug-fortran-mode@erl.mit.edu | |
48 | |
7692
ce33fcd2ce22
(fortran-link-matching-do): Ignore DO statements with line numbers.
Richard M. Stallman <rms@gnu.org>
parents:
6731
diff
changeset
|
49 (defconst fortran-mode-version "version 1.30.5") |
1548 | 50 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
51 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
778
diff
changeset
|
52 |
332 | 53 ;;;###autoload |
54 (defvar fortran-tab-mode-default nil | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
55 "*Default tabbing/carriage control style for empty files in Fortran mode. |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
56 A value of t specifies tab-digit style of continuation control. |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
57 A value of nil specifies that continuation lines are marked |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
58 with a character in column 6.") |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
59 |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
60 ;; Buffer local, used to display mode line. |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
61 (defvar fortran-tab-mode-string nil |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
62 "String to appear in mode line when TAB format mode is on.") |
332 | 63 |
64 (defvar fortran-do-indent 3 | |
1548 | 65 "*Extra indentation applied to DO blocks.") |
332 | 66 |
67 (defvar fortran-if-indent 3 | |
1548 | 68 "*Extra indentation applied to IF blocks.") |
69 | |
70 (defvar fortran-structure-indent 3 | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
71 "*Extra indentation applied to STRUCTURE, UNION, MAP and INTERFACE blocks.") |
332 | 72 |
73 (defvar fortran-continuation-indent 5 | |
1548 | 74 "*Extra indentation applied to Fortran continuation lines.") |
332 | 75 |
76 (defvar fortran-comment-indent-style 'fixed | |
77 "*nil forces comment lines not to be touched, | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
78 'fixed makes fixed comment indentation to `fortran-comment-line-extra-indent' |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
79 columns beyond `fortran-minimum-statement-indent-fixed' (for |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
80 `indent-tabs-mode' of nil) or `fortran-minimum-statement-indent-tab' (for |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
81 `indent-tabs-mode' of t), and 'relative indents to current |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
82 Fortran indentation plus `fortran-comment-line-extra-indent'.") |
332 | 83 |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
84 (defvar fortran-comment-line-extra-indent 0 |
1548 | 85 "*Amount of extra indentation for text within full-line comments.") |
332 | 86 |
87 (defvar comment-line-start nil | |
88 "*Delimiter inserted to start new full-line comment.") | |
89 | |
90 (defvar comment-line-start-skip nil | |
91 "*Regexp to match the start of a full-line comment.") | |
92 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
93 (defvar fortran-minimum-statement-indent-fixed 6 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
94 "*Minimum statement indentation for fixed format continuation style.") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
95 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
96 (defvar fortran-minimum-statement-indent-tab (max tab-width 6) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
97 "*Minimum statement indentation for TAB format continuation style.") |
332 | 98 |
99 ;; Note that this is documented in the v18 manuals as being a string | |
100 ;; of length one rather than a single character. | |
101 ;; The code in this file accepts either format for compatibility. | |
102 (defvar fortran-comment-indent-char " " | |
103 "*Single-character string inserted for Fortran comment indentation. | |
104 Normally a space.") | |
105 | |
106 (defvar fortran-line-number-indent 1 | |
107 "*Maximum indentation for Fortran line numbers. | |
108 5 means right-justify them within their five-column field.") | |
109 | |
110 (defvar fortran-check-all-num-for-matching-do nil | |
1548 | 111 "*Non-nil causes all numbered lines to be treated as possible DO loop ends.") |
332 | 112 |
113 (defvar fortran-blink-matching-if nil | |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
114 "*From a Fortran ENDIF statement, blink the matching IF statement. |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
115 Also, from an ENDDO statement, blink on matching DO [WHILE] statement.") |
332 | 116 |
117 (defvar fortran-continuation-string "$" | |
1548 | 118 "*Single-character string used for Fortran continuation lines. |
332 | 119 In fixed format continuation style, this character is inserted in |
120 column 6 by \\[fortran-split-line] to begin a continuation line. | |
121 Also, if \\[fortran-indent-line] finds this at the beginning of a line, it will | |
122 convert the line into a continuation line of the appropriate style. | |
123 Normally $.") | |
124 | |
125 (defvar fortran-comment-region "c$$$" | |
126 "*String inserted by \\[fortran-comment-region]\ | |
127 at start of each line in region.") | |
128 | |
129 (defvar fortran-electric-line-number t | |
130 "*Non-nil causes line number digits to be moved to the correct column as\ | |
131 typed.") | |
132 | |
133 (defvar fortran-startup-message t | |
134 "*Non-nil displays a startup message when Fortran mode is first called.") | |
135 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
136 (defvar fortran-column-ruler-fixed |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
137 "0 4 6 10 20 30 40 5\ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
138 0 60 70\n\ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
139 [ ]|{ | | | | | | | | \ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
140 | | | | |}\n" |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
141 "*String displayed above current line by \\[fortran-column-ruler]. |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
142 This variable used in fixed format mode.") |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
143 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
144 (defvar fortran-column-ruler-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
145 "0 810 20 30 40 5\ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
146 0 60 70\n\ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
147 [ ]| { | | | | | | | | \ |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
148 | | | | |}\n" |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
149 "*String displayed above current line by \\[fortran-column-ruler]. |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
150 This variable used in TAB format mode.") |
332 | 151 |
152 (defconst bug-fortran-mode "bug-fortran-mode@erl.mit.edu" | |
153 "Address of mailing list for Fortran mode bugs.") | |
154 | |
155 (defvar fortran-mode-syntax-table nil | |
156 "Syntax table in use in Fortran mode buffers.") | |
157 | |
158 (defvar fortran-analyze-depth 100 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
159 "Number of lines to scan to determine whether to use fixed or TAB format\ |
332 | 160 style.") |
161 | |
1548 | 162 (defvar fortran-break-before-delimiters t |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
163 "*Non-nil causes `fortran-do-auto-fill' to break lines before delimiters.") |
1548 | 164 |
332 | 165 (if fortran-mode-syntax-table |
166 () | |
167 (setq fortran-mode-syntax-table (make-syntax-table)) | |
168 (modify-syntax-entry ?\; "w" fortran-mode-syntax-table) | |
169 (modify-syntax-entry ?\r " " fortran-mode-syntax-table) | |
170 (modify-syntax-entry ?+ "." fortran-mode-syntax-table) | |
171 (modify-syntax-entry ?- "." fortran-mode-syntax-table) | |
172 (modify-syntax-entry ?= "." fortran-mode-syntax-table) | |
173 (modify-syntax-entry ?* "." fortran-mode-syntax-table) | |
174 (modify-syntax-entry ?/ "." fortran-mode-syntax-table) | |
175 (modify-syntax-entry ?\' "\"" fortran-mode-syntax-table) | |
176 (modify-syntax-entry ?\" "\"" fortran-mode-syntax-table) | |
177 (modify-syntax-entry ?\\ "/" fortran-mode-syntax-table) | |
178 (modify-syntax-entry ?. "w" fortran-mode-syntax-table) | |
1548 | 179 (modify-syntax-entry ?_ "w" fortran-mode-syntax-table) |
332 | 180 (modify-syntax-entry ?\n ">" fortran-mode-syntax-table)) |
181 | |
182 (defvar fortran-mode-map () | |
1548 | 183 "Keymap used in Fortran mode.") |
332 | 184 (if fortran-mode-map |
185 () | |
186 (setq fortran-mode-map (make-sparse-keymap)) | |
187 (define-key fortran-mode-map ";" 'fortran-abbrev-start) | |
188 (define-key fortran-mode-map "\C-c;" 'fortran-comment-region) | |
189 (define-key fortran-mode-map "\e\C-a" 'beginning-of-fortran-subprogram) | |
190 (define-key fortran-mode-map "\e\C-e" 'end-of-fortran-subprogram) | |
191 (define-key fortran-mode-map "\e;" 'fortran-indent-comment) | |
192 (define-key fortran-mode-map "\e\C-h" 'mark-fortran-subprogram) | |
193 (define-key fortran-mode-map "\e\n" 'fortran-split-line) | |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
194 (define-key fortran-mode-map "\n" 'fortran-indent-new-line) |
332 | 195 (define-key fortran-mode-map "\e\C-q" 'fortran-indent-subprogram) |
196 (define-key fortran-mode-map "\C-c\C-w" 'fortran-window-create-momentarily) | |
197 (define-key fortran-mode-map "\C-c\C-r" 'fortran-column-ruler) | |
198 (define-key fortran-mode-map "\C-c\C-p" 'fortran-previous-statement) | |
199 (define-key fortran-mode-map "\C-c\C-n" 'fortran-next-statement) | |
200 (define-key fortran-mode-map "\t" 'fortran-indent-line) | |
201 (define-key fortran-mode-map "0" 'fortran-electric-line-number) | |
202 (define-key fortran-mode-map "1" 'fortran-electric-line-number) | |
203 (define-key fortran-mode-map "2" 'fortran-electric-line-number) | |
204 (define-key fortran-mode-map "3" 'fortran-electric-line-number) | |
205 (define-key fortran-mode-map "4" 'fortran-electric-line-number) | |
206 (define-key fortran-mode-map "5" 'fortran-electric-line-number) | |
207 (define-key fortran-mode-map "6" 'fortran-electric-line-number) | |
208 (define-key fortran-mode-map "7" 'fortran-electric-line-number) | |
209 (define-key fortran-mode-map "8" 'fortran-electric-line-number) | |
210 (define-key fortran-mode-map "9" 'fortran-electric-line-number)) | |
211 | |
212 (defvar fortran-mode-abbrev-table nil) | |
213 (if fortran-mode-abbrev-table | |
214 () | |
215 (let ((ac abbrevs-changed)) | |
216 (define-abbrev-table 'fortran-mode-abbrev-table ()) | |
217 (define-abbrev fortran-mode-abbrev-table ";au" "automatic" nil) | |
218 (define-abbrev fortran-mode-abbrev-table ";b" "byte" nil) | |
1548 | 219 (define-abbrev fortran-mode-abbrev-table ";bd" "block data" nil) |
332 | 220 (define-abbrev fortran-mode-abbrev-table ";ch" "character" nil) |
221 (define-abbrev fortran-mode-abbrev-table ";cl" "close" nil) | |
222 (define-abbrev fortran-mode-abbrev-table ";c" "continue" nil) | |
223 (define-abbrev fortran-mode-abbrev-table ";cm" "common" nil) | |
224 (define-abbrev fortran-mode-abbrev-table ";cx" "complex" nil) | |
225 (define-abbrev fortran-mode-abbrev-table ";df" "define" nil) | |
226 (define-abbrev fortran-mode-abbrev-table ";di" "dimension" nil) | |
227 (define-abbrev fortran-mode-abbrev-table ";do" "double" nil) | |
228 (define-abbrev fortran-mode-abbrev-table ";dc" "double complex" nil) | |
229 (define-abbrev fortran-mode-abbrev-table ";dp" "double precision" nil) | |
230 (define-abbrev fortran-mode-abbrev-table ";dw" "do while" nil) | |
231 (define-abbrev fortran-mode-abbrev-table ";e" "else" nil) | |
232 (define-abbrev fortran-mode-abbrev-table ";ed" "enddo" nil) | |
233 (define-abbrev fortran-mode-abbrev-table ";el" "elseif" nil) | |
234 (define-abbrev fortran-mode-abbrev-table ";en" "endif" nil) | |
235 (define-abbrev fortran-mode-abbrev-table ";eq" "equivalence" nil) | |
1548 | 236 (define-abbrev fortran-mode-abbrev-table ";ew" "endwhere" nil) |
332 | 237 (define-abbrev fortran-mode-abbrev-table ";ex" "external" nil) |
238 (define-abbrev fortran-mode-abbrev-table ";ey" "entry" nil) | |
239 (define-abbrev fortran-mode-abbrev-table ";f" "format" nil) | |
240 (define-abbrev fortran-mode-abbrev-table ";fa" ".false." nil) | |
241 (define-abbrev fortran-mode-abbrev-table ";fu" "function" nil) | |
242 (define-abbrev fortran-mode-abbrev-table ";g" "goto" nil) | |
243 (define-abbrev fortran-mode-abbrev-table ";im" "implicit" nil) | |
244 (define-abbrev fortran-mode-abbrev-table ";ib" "implicit byte" nil) | |
245 (define-abbrev fortran-mode-abbrev-table ";ic" "implicit complex" nil) | |
246 (define-abbrev fortran-mode-abbrev-table ";ich" "implicit character" nil) | |
247 (define-abbrev fortran-mode-abbrev-table ";ii" "implicit integer" nil) | |
248 (define-abbrev fortran-mode-abbrev-table ";il" "implicit logical" nil) | |
249 (define-abbrev fortran-mode-abbrev-table ";ir" "implicit real" nil) | |
250 (define-abbrev fortran-mode-abbrev-table ";inc" "include" nil) | |
251 (define-abbrev fortran-mode-abbrev-table ";in" "integer" nil) | |
252 (define-abbrev fortran-mode-abbrev-table ";intr" "intrinsic" nil) | |
253 (define-abbrev fortran-mode-abbrev-table ";l" "logical" nil) | |
254 (define-abbrev fortran-mode-abbrev-table ";n" "namelist" nil) | |
255 (define-abbrev fortran-mode-abbrev-table ";o" "open" nil) ; was ;op | |
256 (define-abbrev fortran-mode-abbrev-table ";pa" "parameter" nil) | |
257 (define-abbrev fortran-mode-abbrev-table ";pr" "program" nil) | |
258 (define-abbrev fortran-mode-abbrev-table ";ps" "pause" nil) | |
259 (define-abbrev fortran-mode-abbrev-table ";p" "print" nil) | |
260 (define-abbrev fortran-mode-abbrev-table ";rc" "record" nil) | |
261 (define-abbrev fortran-mode-abbrev-table ";re" "real" nil) | |
262 (define-abbrev fortran-mode-abbrev-table ";r" "read" nil) | |
263 (define-abbrev fortran-mode-abbrev-table ";rt" "return" nil) | |
264 (define-abbrev fortran-mode-abbrev-table ";rw" "rewind" nil) | |
265 (define-abbrev fortran-mode-abbrev-table ";s" "stop" nil) | |
266 (define-abbrev fortran-mode-abbrev-table ";sa" "save" nil) | |
267 (define-abbrev fortran-mode-abbrev-table ";st" "structure" nil) | |
268 (define-abbrev fortran-mode-abbrev-table ";sc" "static" nil) | |
269 (define-abbrev fortran-mode-abbrev-table ";su" "subroutine" nil) | |
270 (define-abbrev fortran-mode-abbrev-table ";tr" ".true." nil) | |
271 (define-abbrev fortran-mode-abbrev-table ";ty" "type" nil) | |
272 (define-abbrev fortran-mode-abbrev-table ";vo" "volatile" nil) | |
273 (define-abbrev fortran-mode-abbrev-table ";w" "write" nil) | |
1548 | 274 (define-abbrev fortran-mode-abbrev-table ";wh" "where" nil) |
332 | 275 (setq abbrevs-changed ac))) |
276 | |
277 ;;;###autoload | |
278 (defun fortran-mode () | |
1548 | 279 "Major mode for editing Fortran code. |
280 \\[fortran-indent-line] indents the current Fortran line correctly. | |
281 DO statements must not share a common CONTINUE. | |
332 | 282 |
1548 | 283 Type ;? or ;\\[help-command] to display a list of built-in\ |
332 | 284 abbrevs for Fortran keywords. |
285 | |
286 Key definitions: | |
287 \\{fortran-mode-map} | |
288 | |
289 Variables controlling indentation style and extra features: | |
290 | |
291 comment-start | |
292 Normally nil in Fortran mode. If you want to use comments | |
293 starting with `!', set this to the string \"!\". | |
294 fortran-do-indent | |
295 Extra indentation within do blocks. (default 3) | |
296 fortran-if-indent | |
297 Extra indentation within if blocks. (default 3) | |
1548 | 298 fortran-structure-indent |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
299 Extra indentation within structure, union, map and interface blocks. |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
300 (default 3) |
332 | 301 fortran-continuation-indent |
1548 | 302 Extra indentation applied to continuation statements. (default 5) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
303 fortran-comment-line-extra-indent |
1548 | 304 Amount of extra indentation for text within full-line comments. (default 0) |
332 | 305 fortran-comment-indent-style |
306 nil means don't change indentation of text in full-line comments, | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
307 fixed means indent that text at `fortran-comment-line-extra-indent' beyond |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
308 the value of `fortran-minimum-statement-indent-fixed' (for fixed |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
309 format continuation style) or `fortran-minimum-statement-indent-tab' |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
310 (for TAB format continuation style). |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
311 relative means indent at `fortran-comment-line-extra-indent' beyond the |
332 | 312 indentation for a line of code. |
313 (default 'fixed) | |
314 fortran-comment-indent-char | |
1548 | 315 Single-character string to be inserted instead of space for |
332 | 316 full-line comment indentation. (default \" \") |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
317 fortran-minimum-statement-indent-fixed |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
318 Minimum indentation for Fortran statements in fixed format mode. (def.6) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
319 fortran-minimum-statement-indent-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
320 Minimum indentation for Fortran statements in TAB format mode. (default 9) |
332 | 321 fortran-line-number-indent |
322 Maximum indentation for line numbers. A line number will get | |
323 less than this much indentation if necessary to avoid reaching | |
324 column 5. (default 1) | |
325 fortran-check-all-num-for-matching-do | |
1548 | 326 Non-nil causes all numbered lines to be treated as possible \"continue\" |
332 | 327 statements. (default nil) |
328 fortran-blink-matching-if | |
1548 | 329 From a Fortran ENDIF statement, blink the matching IF statement. |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
330 Also, from an ENDDO statement, blink on matching DO [WHILE] statement. |
332 | 331 (default nil) |
332 fortran-continuation-string | |
333 Single-character string to be inserted in column 5 of a continuation | |
334 line. (default \"$\") | |
335 fortran-comment-region | |
336 String inserted by \\[fortran-comment-region] at start of each line in | |
337 region. (default \"c$$$\") | |
338 fortran-electric-line-number | |
339 Non-nil causes line number digits to be moved to the correct column | |
340 as typed. (default t) | |
1548 | 341 fortran-break-before-delimiters |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
342 Non-nil causes `fortran-do-auto-fill' breaks lines before delimiters. |
1548 | 343 (default t) |
332 | 344 fortran-startup-message |
345 Set to nil to inhibit message first time Fortran mode is used. | |
346 | |
1548 | 347 Turning on Fortran mode calls the value of the variable `fortran-mode-hook' |
332 | 348 with no args, if that value is non-nil." |
349 (interactive) | |
350 (kill-all-local-variables) | |
351 (if fortran-startup-message | |
1548 | 352 (message "Emacs Fortran mode %s. Bugs to %s" |
332 | 353 fortran-mode-version bug-fortran-mode)) |
354 (setq fortran-startup-message nil) | |
355 (setq local-abbrev-table fortran-mode-abbrev-table) | |
356 (set-syntax-table fortran-mode-syntax-table) | |
1548 | 357 (make-local-variable 'fortran-break-before-delimiters) |
358 (setq fortran-break-before-delimiters t) | |
332 | 359 (make-local-variable 'indent-line-function) |
360 (setq indent-line-function 'fortran-indent-line) | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2028
diff
changeset
|
361 (make-local-variable 'comment-indent-function) |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2028
diff
changeset
|
362 (setq comment-indent-function 'fortran-comment-hook) |
332 | 363 (make-local-variable 'comment-line-start-skip) |
364 (setq comment-line-start-skip | |
1548 | 365 "^[Cc*]\\(\\([^ \t\n]\\)\\2\\2*\\)?[ \t]*\\|^#.*") |
332 | 366 (make-local-variable 'comment-line-start) |
367 (setq comment-line-start "c") | |
368 (make-local-variable 'comment-start-skip) | |
369 (setq comment-start-skip "![ \t]*") | |
370 (make-local-variable 'comment-start) | |
371 (setq comment-start nil) | |
372 (make-local-variable 'require-final-newline) | |
373 (setq require-final-newline t) | |
374 (make-local-variable 'abbrev-all-caps) | |
375 (setq abbrev-all-caps t) | |
376 (make-local-variable 'indent-tabs-mode) | |
377 (setq indent-tabs-mode nil) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
378 ;;;(setq abbrev-mode t) ; ?? (abbrev-mode 1) instead?? |
1548 | 379 (setq fill-column 72) ; Already local? |
332 | 380 (use-local-map fortran-mode-map) |
381 (setq mode-name "Fortran") | |
382 (setq major-mode 'fortran-mode) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
383 ;;;(make-local-variable 'fortran-tab-mode) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
384 (make-local-variable 'fortran-comment-line-extra-indent) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
385 (make-local-variable 'fortran-minimum-statement-indent-fixed) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
386 (make-local-variable 'fortran-minimum-statement-indent-tab) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
387 (make-local-variable 'fortran-column-ruler-fixed) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
388 (make-local-variable 'fortran-column-ruler-tab) |
332 | 389 (make-local-variable 'fortran-tab-mode-string) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
390 (setq fortran-tab-mode-string " TAB-format") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
391 (setq indent-tabs-mode (fortran-analyze-file-format)) |
332 | 392 (run-hooks 'fortran-mode-hook)) |
393 | |
394 (defun fortran-comment-hook () | |
395 (save-excursion | |
396 (skip-chars-backward " \t") | |
397 (max (+ 1 (current-column)) | |
398 comment-column))) | |
399 | |
400 (defun fortran-indent-comment () | |
401 "Align or create comment on current line. | |
402 Existing comments of all types are recognized and aligned. | |
403 If the line has no comment, a side-by-side comment is inserted and aligned | |
404 if the value of comment-start is not nil. | |
405 Otherwise, a separate-line comment is inserted, on this line | |
406 or on a new line inserted before this line if this line is not blank." | |
407 (interactive) | |
408 (beginning-of-line) | |
409 ;; Recognize existing comments of either kind. | |
410 (cond ((looking-at comment-line-start-skip) | |
411 (fortran-indent-line)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
412 ((fortran-find-comment-start-skip) ; catches any inline comment and |
1548 | 413 ; leaves point after comment-start-skip |
414 (if comment-start-skip | |
415 (progn (goto-char (match-beginning 0)) | |
416 (if (not (= (current-column) (fortran-comment-hook))) | |
417 (progn (delete-horizontal-space) | |
418 (indent-to (fortran-comment-hook))))) | |
419 (end-of-line))) ; otherwise goto end of line or sth else? | |
332 | 420 ;; No existing comment. |
421 ;; If side-by-side comments are defined, insert one, | |
422 ;; unless line is now blank. | |
423 ((and comment-start (not (looking-at "^[ \t]*$"))) | |
424 (end-of-line) | |
425 (delete-horizontal-space) | |
426 (indent-to (fortran-comment-hook)) | |
427 (insert comment-start)) | |
428 ;; Else insert separate-line comment, making a new line if nec. | |
429 (t | |
430 (if (looking-at "^[ \t]*$") | |
431 (delete-horizontal-space) | |
432 (beginning-of-line) | |
433 (insert "\n") | |
434 (forward-char -1)) | |
435 (insert comment-line-start) | |
436 (insert-char (if (stringp fortran-comment-indent-char) | |
437 (aref fortran-comment-indent-char 0) | |
1548 | 438 fortran-comment-indent-char) |
332 | 439 (- (calculate-fortran-indent) (current-column)))))) |
440 | |
441 (defun fortran-comment-region (beg-region end-region arg) | |
442 "Comments every line in the region. | |
443 Puts fortran-comment-region at the beginning of every line in the region. | |
444 BEG-REGION and END-REGION are args which specify the region boundaries. | |
445 With non-nil ARG, uncomments the region." | |
446 (interactive "*r\nP") | |
447 (let ((end-region-mark (make-marker)) (save-point (point-marker))) | |
448 (set-marker end-region-mark end-region) | |
449 (goto-char beg-region) | |
450 (beginning-of-line) | |
451 (if (not arg) ;comment the region | |
452 (progn (insert fortran-comment-region) | |
453 (while (and (= (forward-line 1) 0) | |
454 (< (point) end-region-mark)) | |
455 (insert fortran-comment-region))) | |
456 (let ((com (regexp-quote fortran-comment-region))) ;uncomment the region | |
457 (if (looking-at com) | |
458 (delete-region (point) (match-end 0))) | |
459 (while (and (= (forward-line 1) 0) | |
460 (< (point) end-region-mark)) | |
461 (if (looking-at com) | |
462 (delete-region (point) (match-end 0)))))) | |
463 (goto-char save-point) | |
464 (set-marker end-region-mark nil) | |
465 (set-marker save-point nil))) | |
466 | |
467 (defun fortran-abbrev-start () | |
1548 | 468 "Typing ;\\[help-command] or ;? lists all the Fortran abbrevs. |
332 | 469 Any other key combination is executed normally." |
470 (interactive) | |
471 (let (c) | |
472 (insert last-command-char) | |
2028
87f2d4cbbaf4
(fortran-abbrev-start): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1862
diff
changeset
|
473 (if (or (eq (setq c (read-event)) ??) ;insert char if not equal to `?' |
87f2d4cbbaf4
(fortran-abbrev-start): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1862
diff
changeset
|
474 (eq c help-char)) |
332 | 475 (fortran-abbrev-help) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1633
diff
changeset
|
476 (setq unread-command-events (list c))))) |
332 | 477 |
478 (defun fortran-abbrev-help () | |
479 "List the currently defined abbrevs in Fortran mode." | |
480 (interactive) | |
481 (message "Listing abbrev table...") | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
482 (display-buffer (fortran-prepare-abbrev-list-buffer)) |
332 | 483 (message "Listing abbrev table...done")) |
484 | |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
485 (defun fortran-prepare-abbrev-list-buffer () |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
486 (save-excursion |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
487 (set-buffer (get-buffer-create "*Abbrevs*")) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
488 (erase-buffer) |
1862
f6a38dd2250b
* fortran.el (fortran-prepare-abbrev-list-buffer): Put quote in
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
489 (insert-abbrev-table-description 'fortran-mode-abbrev-table t) |
1485
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
490 (goto-char (point-min)) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
491 (set-buffer-modified-p nil) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
492 (edit-abbrevs-mode)) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
493 (get-buffer-create "*Abbrevs*")) |
a6da00e1c5ad
(fortran-tab-mode): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
1475
diff
changeset
|
494 |
332 | 495 (defun fortran-column-ruler () |
496 "Inserts a column ruler momentarily above current line, till next keystroke. | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
497 The ruler is defined by the value of `fortran-column-ruler-fixed' when in fixed |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
498 format mode, and `fortran-column-ruler-tab' when in TAB format mode. |
332 | 499 The key typed is executed unless it is SPC." |
500 (interactive) | |
501 (momentary-string-display | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
502 (if indent-tabs-mode |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
503 fortran-column-ruler-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
504 fortran-column-ruler-fixed) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
505 (save-excursion |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
506 (beginning-of-line) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
507 (if (eq (window-start (selected-window)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
508 (window-point (selected-window))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
509 (progn (forward-line) (point)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
510 (point))) |
332 | 511 nil "Type SPC or any command to erase ruler.")) |
512 | |
513 (defun fortran-window-create () | |
514 "Makes the window 72 columns wide. | |
1475 | 515 See also `fortran-window-create-momentarily'." |
332 | 516 (interactive) |
517 (condition-case error | |
518 (progn | |
519 (let ((window-min-width 2)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
520 (if (< (window-width) (frame-width)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
521 (enlarge-window-horizontally (- (frame-width) |
332 | 522 (window-width) 1))) |
523 (split-window-horizontally 73) | |
524 (other-window 1) | |
525 (switch-to-buffer " fortran-window-extra" t) | |
526 (select-window (previous-window)))) | |
1548 | 527 (error (message "No room for Fortran window.") |
332 | 528 'error))) |
529 | |
530 (defun fortran-window-create-momentarily (&optional arg) | |
531 "Momentarily makes the window 72 columns wide. | |
532 Optional ARG non-nil and non-unity disables the momentary feature. | |
1475 | 533 See also `fortran-window-create'." |
332 | 534 (interactive "p") |
535 (if (or (not arg) | |
536 (= arg 1)) | |
537 (save-window-excursion | |
538 (if (not (equal (fortran-window-create) 'error)) | |
539 (progn (message "Type SPC to continue editing.") | |
2028
87f2d4cbbaf4
(fortran-abbrev-start): Handle any kind of event.
Richard M. Stallman <rms@gnu.org>
parents:
1862
diff
changeset
|
540 (let ((char (read-event))) |
332 | 541 (or (equal char (string-to-char " ")) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1633
diff
changeset
|
542 (setq unread-command-events (list char))))))) |
332 | 543 (fortran-window-create))) |
544 | |
545 (defun fortran-split-line () | |
546 "Break line at point and insert continuation marker and alignment." | |
547 (interactive) | |
548 (delete-horizontal-space) | |
549 (if (save-excursion (beginning-of-line) (looking-at comment-line-start-skip)) | |
550 (insert "\n" comment-line-start " ") | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
551 (if indent-tabs-mode |
332 | 552 (progn |
553 (insert "\n\t") | |
554 (insert-char (fortran-numerical-continuation-char) 1)) | |
1548 | 555 (insert "\n " fortran-continuation-string)));Space after \n important |
556 (fortran-indent-line)) ;when the cont string is C, c or *. | |
332 | 557 |
558 (defun fortran-numerical-continuation-char () | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
559 "Return a digit for tab-digit style of continuation lines. |
332 | 560 If, previous line is a tab-digit continuation line, returns that digit |
561 plus one. Otherwise return 1. Zero not allowed." | |
562 (save-excursion | |
563 (forward-line -1) | |
564 (if (looking-at "\t[1-9]") | |
565 (+ ?1 (% (- (char-after (+ (point) 1)) ?0) 9)) | |
566 ?1))) | |
567 | |
568 (defun delete-horizontal-regexp (chars) | |
569 "Delete all characters in CHARS around point. | |
570 CHARS is like the inside of a [...] in a regular expression | |
571 except that ] is never special and \ quotes ^, - or \." | |
572 (interactive "*s") | |
573 (skip-chars-backward chars) | |
574 (delete-region (point) (progn (skip-chars-forward chars) (point)))) | |
575 | |
576 (defun fortran-electric-line-number (arg) | |
577 "Self insert, but if part of a Fortran line number indent it automatically. | |
578 Auto-indent does not happen if a numeric arg is used." | |
579 (interactive "P") | |
580 (if (or arg (not fortran-electric-line-number)) | |
581 (if arg | |
1548 | 582 (self-insert-command (prefix-numeric-value arg)) |
332 | 583 (self-insert-command 1)) |
584 (if (or (and (= 5 (current-column)) | |
585 (save-excursion | |
586 (beginning-of-line) | |
587 (looking-at " ")));In col 5 with only spaces to left. | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
588 (and (= (if indent-tabs-mode |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
589 fortran-minimum-statement-indent-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
590 fortran-minimum-statement-indent-fixed) (current-column)) |
332 | 591 (save-excursion |
592 (beginning-of-line) | |
593 (looking-at "\t"));In col 8 with a single tab to the left. | |
594 (not (or (eq last-command 'fortran-indent-line) | |
595 (eq last-command | |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
596 'fortran-indent-new-line)))) |
332 | 597 (save-excursion |
598 (re-search-backward "[^ \t0-9]" | |
599 (save-excursion | |
600 (beginning-of-line) | |
601 (point)) | |
602 t)) ;not a line number | |
603 (looking-at "[0-9]") ;within a line number | |
604 ) | |
1548 | 605 (self-insert-command (prefix-numeric-value arg)) |
332 | 606 (skip-chars-backward " \t") |
607 (insert last-command-char) | |
608 (fortran-indent-line)))) | |
609 | |
610 (defun beginning-of-fortran-subprogram () | |
1548 | 611 "Moves point to the beginning of the current Fortran subprogram." |
332 | 612 (interactive) |
613 (let ((case-fold-search t)) | |
614 (beginning-of-line -1) | |
615 (re-search-backward "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]" nil 'move) | |
616 (if (looking-at "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]") | |
617 (forward-line 1)))) | |
618 | |
619 (defun end-of-fortran-subprogram () | |
1548 | 620 "Moves point to the end of the current Fortran subprogram." |
332 | 621 (interactive) |
622 (let ((case-fold-search t)) | |
623 (beginning-of-line 2) | |
624 (re-search-forward "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]" nil 'move) | |
625 (goto-char (match-beginning 0)) | |
626 (forward-line 1))) | |
627 | |
628 (defun mark-fortran-subprogram () | |
1548 | 629 "Put mark at end of Fortran subprogram, point at beginning. |
332 | 630 The marks are pushed." |
631 (interactive) | |
632 (end-of-fortran-subprogram) | |
633 (push-mark (point)) | |
634 (beginning-of-fortran-subprogram)) | |
1548 | 635 |
332 | 636 (defun fortran-previous-statement () |
1548 | 637 "Moves point to beginning of the previous Fortran statement. |
638 Returns `first-statement' if that statement is the first | |
332 | 639 non-comment Fortran statement in the file, and nil otherwise." |
640 (interactive) | |
641 (let (not-first-statement continue-test) | |
642 (beginning-of-line) | |
643 (setq continue-test | |
1548 | 644 (and |
645 (not (looking-at comment-line-start-skip)) | |
646 (or (looking-at | |
332 | 647 (concat "[ \t]*" (regexp-quote fortran-continuation-string))) |
1548 | 648 (or (looking-at " [^ 0\n]") |
649 (looking-at "\t[1-9]"))))) | |
332 | 650 (while (and (setq not-first-statement (= (forward-line -1) 0)) |
651 (or (looking-at comment-line-start-skip) | |
652 (looking-at "[ \t]*$") | |
653 (looking-at " [^ 0\n]") | |
654 (looking-at "\t[1-9]") | |
655 (looking-at (concat "[ \t]*" comment-start-skip))))) | |
656 (cond ((and continue-test | |
657 (not not-first-statement)) | |
658 (message "Incomplete continuation statement.")) | |
659 (continue-test | |
660 (fortran-previous-statement)) | |
661 ((not not-first-statement) | |
662 'first-statement)))) | |
663 | |
664 (defun fortran-next-statement () | |
1548 | 665 "Moves point to beginning of the next Fortran statement. |
332 | 666 Returns `last-statement' if that statement is the last |
667 non-comment Fortran statement in the file, and nil otherwise." | |
668 (interactive) | |
669 (let (not-last-statement) | |
670 (beginning-of-line) | |
1548 | 671 (while (and (setq not-last-statement |
672 (and (= (forward-line 1) 0) | |
673 (not (eobp)))) | |
332 | 674 (or (looking-at comment-line-start-skip) |
675 (looking-at "[ \t]*$") | |
676 (looking-at " [^ 0\n]") | |
677 (looking-at "\t[1-9]") | |
678 (looking-at (concat "[ \t]*" comment-start-skip))))) | |
679 (if (not not-last-statement) | |
680 'last-statement))) | |
681 | |
682 (defun fortran-blink-matching-if () | |
1548 | 683 "From a Fortran ENDIF statement, blink the matching IF statement." |
332 | 684 (let ((count 1) (top-of-window (window-start)) matching-if |
685 (endif-point (point)) message) | |
686 (if (save-excursion (beginning-of-line) | |
687 (skip-chars-forward " \t0-9") | |
688 (looking-at "end[ \t]*if\\b")) | |
689 (progn | |
690 (save-excursion | |
691 (while (and (not (= count 0)) | |
692 (not (eq (fortran-previous-statement) | |
693 'first-statement)) | |
694 (not (looking-at | |
695 "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) | |
696 ; Keep local to subprogram | |
697 (skip-chars-forward " \t0-9") | |
698 (cond ((looking-at "if[ \t]*(") | |
1548 | 699 (save-excursion |
700 (if (or | |
701 (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t(=a-z0-9]") | |
702 (let (then-test);multi-line if-then | |
703 (while | |
704 (and (= (forward-line 1) 0) | |
332 | 705 ;search forward for then |
1548 | 706 (or (looking-at " [^ 0\n]") |
707 (looking-at "\t[1-9]")) | |
708 (not | |
709 (setq | |
710 then-test | |
711 (looking-at | |
712 ".*then\\b[ \t]*[^ \t(=a-z0-9]"))))) | |
713 then-test)) | |
714 (setq count (- count 1))))) | |
332 | 715 ((looking-at "end[ \t]*if\\b") |
716 (setq count (+ count 1))))) | |
717 (if (not (= count 0)) | |
718 (setq message "No matching if.") | |
719 (if (< (point) top-of-window) | |
720 (setq message (concat "Matches " (buffer-substring | |
721 (progn (beginning-of-line) | |
722 (point)) | |
723 (progn (end-of-line) | |
724 (point))))) | |
725 (setq matching-if (point))))) | |
726 (if message | |
1548 | 727 (message "%s" message) |
332 | 728 (goto-char matching-if) |
729 (sit-for 1) | |
730 (goto-char endif-point)))))) | |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
731 |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
732 (defun fortran-blink-matching-do () |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
733 ;; From a Fortran ENDDO statement, blink on the matching DO or DO WHILE |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
734 ;; statement. This is basically copied from fortran-blink-matching-if. |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
735 (let ((count 1) (top-of-window (window-start)) matching-do |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
736 (enddo-point (point)) message) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
737 (if (save-excursion (beginning-of-line) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
738 (skip-chars-forward " \t0-9") |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
739 (looking-at "end[ \t]*do\\b")) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
740 (progn |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
741 (save-excursion |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
742 (while (and (not (= count 0)) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
743 (not (eq (fortran-previous-statement) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
744 'first-statement)) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
745 (not (looking-at |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
746 "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
747 ; Keep local to subprogram |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
748 (skip-chars-forward " \t0-9") |
7888
b26a8476561d
(fortran-blink-matching-do): When looking for do,
Richard M. Stallman <rms@gnu.org>
parents:
7692
diff
changeset
|
749 (cond ((looking-at "do[ \t]+[^0-9]") |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
750 (setq count (- count 1))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
751 ((looking-at "end[ \t]*do\\b") |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
752 (setq count (+ count 1))))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
753 (if (not (= count 0)) |
7888
b26a8476561d
(fortran-blink-matching-do): When looking for do,
Richard M. Stallman <rms@gnu.org>
parents:
7692
diff
changeset
|
754 (setq message "No matching do") |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
755 (if (< (point) top-of-window) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
756 (setq message (concat "Matches " (buffer-substring |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
757 (progn (beginning-of-line) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
758 (point)) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
759 (progn (end-of-line) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
760 (point))))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
761 (setq matching-do (point))))) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
762 (if message |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
763 (message "%s" message) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
764 (goto-char matching-do) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
765 (sit-for 1) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
766 (goto-char enddo-point)))))) |
332 | 767 |
768 (defun fortran-indent-line () | |
1548 | 769 "Indents current Fortran line based on its contents and on previous lines." |
332 | 770 (interactive) |
771 (let ((cfi (calculate-fortran-indent))) | |
772 (save-excursion | |
773 (beginning-of-line) | |
774 (if (or (not (= cfi (fortran-current-line-indentation))) | |
775 (and (re-search-forward "^[ \t]*[0-9]+" (+ (point) 4) t) | |
776 (not (fortran-line-number-indented-correctly-p)))) | |
777 (fortran-indent-to-column cfi) | |
778 (beginning-of-line) | |
779 (if (and (not (looking-at comment-line-start-skip)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
780 (fortran-find-comment-start-skip)) |
332 | 781 (fortran-indent-comment)))) |
782 ;; Never leave point in left margin. | |
783 (if (< (current-column) cfi) | |
784 (move-to-column cfi)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
785 (if (and auto-fill-function |
1548 | 786 (> (save-excursion (end-of-line) (current-column)) fill-column)) |
787 (save-excursion | |
788 (end-of-line) | |
789 (fortran-do-auto-fill))) | |
332 | 790 (if fortran-blink-matching-if |
6731
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
791 (progn |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
792 (fortran-blink-matching-if) |
23d9c2bc097b
(fortran-blink-matching-do): New function,
Richard M. Stallman <rms@gnu.org>
parents:
5720
diff
changeset
|
793 (fortran-blink-matching-do))))) |
332 | 794 |
3567
2ca5f216e445
(fortran-indent-new-line): Renamed from
Richard M. Stallman <rms@gnu.org>
parents:
3400
diff
changeset
|
795 (defun fortran-indent-new-line () |
1548 | 796 "Reindent the current Fortran line, insert a newline and indent the newline. |
797 An abbrev before point is expanded if `abbrev-mode' is non-nil." | |
332 | 798 (interactive) |
799 (if abbrev-mode (expand-abbrev)) | |
800 (save-excursion | |
801 (beginning-of-line) | |
802 (skip-chars-forward " \t") | |
803 (if (or (looking-at "[0-9]") ;Reindent only where it is most | |
804 (looking-at "end") ;likely to be necessary | |
805 (looking-at "else") | |
806 (looking-at (regexp-quote fortran-continuation-string))) | |
807 (fortran-indent-line))) | |
1548 | 808 (newline) |
332 | 809 (fortran-indent-line)) |
1548 | 810 |
332 | 811 (defun fortran-indent-subprogram () |
812 "Properly indents the Fortran subprogram which contains point." | |
813 (interactive) | |
814 (save-excursion | |
815 (mark-fortran-subprogram) | |
816 (message "Indenting subprogram...") | |
817 (indent-region (point) (mark) nil)) | |
818 (message "Indenting subprogram...done.")) | |
819 | |
820 (defun calculate-fortran-indent () | |
1548 | 821 "Calculates the Fortran indent column based on previous lines." |
332 | 822 (let (icol first-statement (case-fold-search t) |
823 (fortran-minimum-statement-indent | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
824 (if indent-tabs-mode |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
825 fortran-minimum-statement-indent-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
826 fortran-minimum-statement-indent-fixed))) |
332 | 827 (save-excursion |
828 (setq first-statement (fortran-previous-statement)) | |
829 (if first-statement | |
830 (setq icol fortran-minimum-statement-indent) | |
831 (progn | |
832 (if (= (point) (point-min)) | |
833 (setq icol fortran-minimum-statement-indent) | |
834 (setq icol (fortran-current-line-indentation))) | |
835 (skip-chars-forward " \t0-9") | |
836 (cond ((looking-at "if[ \t]*(") | |
1548 | 837 (if (or (looking-at ".*)[ \t]*then\\b[ \t]*[^ \t_$(=a-z0-9]") |
332 | 838 (let (then-test) ;multi-line if-then |
839 (while (and (= (forward-line 1) 0) | |
1548 | 840 ;;search forward for then |
332 | 841 (or (looking-at " [^ 0\n]") |
842 (looking-at "\t[1-9]")) | |
843 (not (setq then-test (looking-at | |
1548 | 844 ".*then\\b[ \t]\ |
845 *[^ \t_$(=a-z0-9]"))))) | |
332 | 846 then-test)) |
847 (setq icol (+ icol fortran-if-indent)))) | |
848 ((looking-at "\\(else\\|elseif\\)\\b") | |
849 (setq icol (+ icol fortran-if-indent))) | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
850 ((looking-at "select[ \t]*case[ \t](.*)\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
851 (setq icol (+ icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
852 ((looking-at "case[ \t]*(.*)[ \t]*\n") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
853 (setq icol (+ icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
854 ((looking-at "case[ \t]*default\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
855 (setq icol (+ icol fortran-if-indent))) |
1548 | 856 ((looking-at "\\(otherwise\\|else[ \t]*where\\)\\b") |
857 (setq icol (+ icol fortran-if-indent))) | |
5065
cd3d59bc0b94
(calculate-fortran-indent): Fixup regexp for where statements.
Richard M. Stallman <rms@gnu.org>
parents:
3591
diff
changeset
|
858 ((looking-at "where[ \t]*(.*)[ \t]*\n") |
1548 | 859 (setq icol (+ icol fortran-if-indent))) |
332 | 860 ((looking-at "do\\b") |
861 (setq icol (+ icol fortran-do-indent))) | |
1548 | 862 ((looking-at |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
863 "\\(structure\\|union\\|map\\|interface\\)\\b[ \t]*[^ \t=(a-z]") |
1548 | 864 (setq icol (+ icol fortran-structure-indent))) |
332 | 865 ((looking-at "end\\b[ \t]*[^ \t=(a-z]") |
1548 | 866 ;; Previous END resets indent to minimum |
332 | 867 (setq icol fortran-minimum-statement-indent)))))) |
868 (save-excursion | |
869 (beginning-of-line) | |
870 (cond ((looking-at "[ \t]*$")) | |
871 ((looking-at comment-line-start-skip) | |
872 (cond ((eq fortran-comment-indent-style 'relative) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
873 (setq icol (+ icol fortran-comment-line-extra-indent))) |
332 | 874 ((eq fortran-comment-indent-style 'fixed) |
1548 | 875 (setq icol (+ fortran-minimum-statement-indent |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
876 fortran-comment-line-extra-indent)))) |
1548 | 877 (setq fortran-minimum-statement-indent 0)) |
332 | 878 ((or (looking-at (concat "[ \t]*" |
1548 | 879 (regexp-quote |
880 fortran-continuation-string))) | |
332 | 881 (looking-at " [^ 0\n]") |
882 (looking-at "\t[1-9]")) | |
883 (setq icol (+ icol fortran-continuation-indent))) | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
884 ((looking-at "[ \t]*#") ; Check for cpp directive. |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
885 (setq fortran-minimum-statement-indent 0 icol 0)) |
332 | 886 (first-statement) |
887 ((and fortran-check-all-num-for-matching-do | |
888 (looking-at "[ \t]*[0-9]+") | |
889 (fortran-check-for-matching-do)) | |
890 (setq icol (- icol fortran-do-indent))) | |
891 (t | |
892 (skip-chars-forward " \t0-9") | |
893 (cond ((looking-at "end[ \t]*if\\b") | |
894 (setq icol (- icol fortran-if-indent))) | |
895 ((looking-at "\\(else\\|elseif\\)\\b") | |
896 (setq icol (- icol fortran-if-indent))) | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
897 ((looking-at "case[ \t]*(.*)[ \t]*\n") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
898 (setq icol (- icol fortran-if-indent))) |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
899 ((looking-at "case[ \t]*default\\b") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
900 (setq icol (- icol fortran-if-indent))) |
1548 | 901 ((looking-at "\\(otherwise\\|else[ \t]*where\\)\\b") |
902 (setq icol (- icol fortran-if-indent))) | |
903 ((looking-at "end[ \t]*where\\b") | |
904 (setq icol (- icol fortran-if-indent))) | |
332 | 905 ((and (looking-at "continue\\b") |
906 (fortran-check-for-matching-do)) | |
907 (setq icol (- icol fortran-do-indent))) | |
908 ((looking-at "end[ \t]*do\\b") | |
909 (setq icol (- icol fortran-do-indent))) | |
1548 | 910 ((looking-at |
911 "end[ \t]*\ | |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
912 \\(structure\\|union\\|map\\|interface\\)\\b[ \t]*[^ \t=(a-z]") |
1548 | 913 (setq icol (- icol fortran-structure-indent))) |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
914 ((looking-at |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
915 "end[ \t]*select\\b[ \t]*[^ \t=(a-z]") |
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
916 (setq icol (- icol fortran-if-indent))) |
332 | 917 ((and (looking-at "end\\b[ \t]*[^ \t=(a-z]") |
918 (not (= icol fortran-minimum-statement-indent))) | |
919 (message "Warning: `end' not in column %d. Probably\ | |
920 an unclosed block." fortran-minimum-statement-indent)))))) | |
921 (max fortran-minimum-statement-indent icol))) | |
922 | |
923 (defun fortran-current-line-indentation () | |
924 "Indentation of current line, ignoring Fortran line number or continuation. | |
925 This is the column position of the first non-whitespace character | |
926 aside from the line number and/or column 5/8 line-continuation character. | |
927 For comment lines, returns indentation of the first | |
928 non-indentation text within the comment." | |
929 (save-excursion | |
930 (beginning-of-line) | |
931 (cond ((looking-at comment-line-start-skip) | |
932 (goto-char (match-end 0)) | |
933 (skip-chars-forward | |
1548 | 934 (if (stringp fortran-comment-indent-char) |
935 fortran-comment-indent-char | |
936 (char-to-string fortran-comment-indent-char)))) | |
332 | 937 ((or (looking-at " [^ 0\n]") |
1548 | 938 (looking-at "\t[1-9]")) |
332 | 939 (goto-char (match-end 0))) |
940 (t | |
941 ;; Move past line number. | |
1548 | 942 (skip-chars-forward "[ \t0-9]");From Uli |
943 )) | |
332 | 944 ;; Move past whitespace. |
945 (skip-chars-forward " \t") | |
946 (current-column))) | |
947 | |
948 (defun fortran-indent-to-column (col) | |
949 "Indents current line with spaces to column COL. | |
950 notes: 1) A non-zero/non-blank character in column 5 indicates a continuation | |
951 line, and this continuation character is retained on indentation; | |
1548 | 952 2) If `fortran-continuation-string' is the first non-whitespace |
953 character, this is a continuation line; | |
332 | 954 3) A non-continuation line which has a number as the first |
955 non-whitespace character is a numbered line. | |
1548 | 956 4) A TAB followed by a digit indicates a continuation line." |
332 | 957 (save-excursion |
958 (beginning-of-line) | |
959 (if (looking-at comment-line-start-skip) | |
960 (if fortran-comment-indent-style | |
961 (let ((char (if (stringp fortran-comment-indent-char) | |
962 (aref fortran-comment-indent-char 0) | |
1548 | 963 fortran-comment-indent-char))) |
332 | 964 (goto-char (match-end 0)) |
965 (delete-horizontal-regexp (concat " \t" (char-to-string char))) | |
966 (insert-char char (- col (current-column))))) | |
967 (if (looking-at "\t[1-9]") | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
968 (if indent-tabs-mode |
332 | 969 (goto-char (match-end 0)) |
970 (delete-char 2) | |
971 (insert " ") | |
972 (insert fortran-continuation-string)) | |
973 (if (looking-at " [^ 0\n]") | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
974 (if indent-tabs-mode |
332 | 975 (progn (delete-char 6) |
976 (insert "\t") | |
977 (insert-char (fortran-numerical-continuation-char) 1)) | |
978 (forward-char 6)) | |
979 (delete-horizontal-space) | |
1548 | 980 ;; Put line number in columns 0-4 |
981 ;; or put continuation character in column 5. | |
332 | 982 (cond ((eobp)) |
983 ((looking-at (regexp-quote fortran-continuation-string)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
984 (if indent-tabs-mode |
332 | 985 (progn |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
986 (indent-to |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
987 (if indent-tabs-mode |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
988 fortran-minimum-statement-indent-tab |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
989 fortran-minimum-statement-indent-fixed)) |
332 | 990 (delete-char 1) |
991 (insert-char (fortran-numerical-continuation-char) 1)) | |
1548 | 992 (indent-to 5) |
993 (forward-char 1))) | |
332 | 994 ((looking-at "[0-9]+") |
995 (let ((extra-space (- 5 (- (match-end 0) (point))))) | |
996 (if (< extra-space 0) | |
997 (message "Warning: line number exceeds 5-digit limit.") | |
998 (indent-to (min fortran-line-number-indent extra-space)))) | |
999 (skip-chars-forward "0-9"))))) | |
1000 ;; Point is now after any continuation character or line number. | |
1001 ;; Put body of statement where specified. | |
1002 (delete-horizontal-space) | |
1003 (indent-to col) | |
1004 ;; Indent any comment following code on the same line. | |
1005 (if (and comment-start-skip | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1006 (fortran-find-comment-start-skip)) |
332 | 1007 (progn (goto-char (match-beginning 0)) |
1008 (if (not (= (current-column) (fortran-comment-hook))) | |
1009 (progn (delete-horizontal-space) | |
1010 (indent-to (fortran-comment-hook))))))))) | |
1011 | |
1012 (defun fortran-line-number-indented-correctly-p () | |
1013 "Return t if current line's line number is correctly indented. | |
1014 Do not call if there is no line number." | |
1015 (save-excursion | |
1016 (beginning-of-line) | |
1017 (skip-chars-forward " \t") | |
1018 (and (<= (current-column) fortran-line-number-indent) | |
1019 (or (= (current-column) fortran-line-number-indent) | |
1020 (progn (skip-chars-forward "0-9") | |
1021 (= (current-column) 5)))))) | |
1022 | |
1023 (defun fortran-check-for-matching-do () | |
1548 | 1024 "When called from a numbered statement, returns t if matching DO is found. |
332 | 1025 Otherwise return a nil." |
1026 (let (charnum | |
1027 (case-fold-search t)) | |
1028 (save-excursion | |
1029 (beginning-of-line) | |
1030 (if (looking-at "[ \t]*[0-9]+") | |
1031 (progn | |
1032 (skip-chars-forward " \t") | |
1033 (skip-chars-forward "0") ;skip past leading zeros | |
1034 (setq charnum (buffer-substring (point) | |
1035 (progn (skip-chars-forward "0-9") | |
1036 (point)))) | |
1037 (beginning-of-line) | |
1038 (and (re-search-backward | |
1039 (concat | |
1548 | 1040 "\\(^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]\\)\\|\\(^[ \t0-9]*do\ |
1041 [ \t]*0*" | |
1042 charnum "\\b\\)\\|\\(^[ \t]*0*" charnum "\\b\\)") | |
332 | 1043 nil t) |
1044 (looking-at (concat "^[ \t0-9]*do[ \t]*0*" charnum)))))))) | |
1045 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1046 (defun fortran-find-comment-start-skip () |
1548 | 1047 "Move to past `comment-start-skip' found on current line. |
1048 Return t if `comment-start-skip' found, nil if not." | |
1049 ;;; In order to move point only if comment-start-skip is found, | |
1050 ;;; this one uses a lot of save-excursions. Note that re-search-forward | |
1051 ;;; moves point even if comment-start-skip is inside a string-constant. | |
1052 ;;; Some code expects certain values for match-beginning and end | |
1053 (interactive) | |
1054 (let ((save-match-beginning) (save-match-end)) | |
1055 (if (save-excursion | |
1056 (re-search-forward comment-start-skip | |
1057 (save-excursion (end-of-line) (point)) t)) | |
1058 (progn | |
1059 (setq save-match-beginning (match-beginning 0)) | |
1060 (setq save-match-end (match-end 0)) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1061 (if (fortran-is-in-string-p (match-beginning 0)) |
1548 | 1062 (progn |
1063 (save-excursion | |
1064 (goto-char save-match-end) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1065 (fortran-find-comment-start-skip)) ; recurse for rest of line |
1548 | 1066 ) |
1067 (goto-char save-match-beginning) | |
1068 (re-search-forward comment-start-skip | |
1069 (save-excursion (end-of-line) (point)) t) | |
1070 (goto-char (match-end 0)) | |
1071 t)) | |
1072 nil))) | |
1073 | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1074 ;;;From: ralf@up3aud1.gwdg.de (Ralf Fassel) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1075 ;;; Test if TAB format continuation lines work. |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1076 (defun fortran-is-in-string-p (where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1077 "Return non-nil if POS (a buffer position) is inside a Fortran string, |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1078 nil else." |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1079 (save-excursion |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1080 (goto-char where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1081 (cond |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1082 ((bolp) nil) ; bol is never inside a string |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1083 ((save-excursion ; comment lines too |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1084 (beginning-of-line)(looking-at comment-line-start-skip)) nil) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1085 (t (let (;; ok, serious now. Init some local vars: |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1086 (parse-state '(0 nil nil nil nil nil 0)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1087 (quoted-comment-start (if comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1088 (regexp-quote comment-start))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1089 (not-done t) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1090 parse-limit |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1091 end-of-line |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1092 ) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1093 ;; move to start of current statement |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1094 (fortran-next-statement) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1095 (fortran-previous-statement) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1096 ;; now parse up to WHERE |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1097 (while not-done |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1098 (if (or ;; skip to next line if: |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1099 ;; - comment line? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1100 (looking-at comment-line-start-skip) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1101 ;; - at end of line? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1102 (eolp) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1103 ;; - not in a string and after comment-start? |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1104 (and (not (nth 3 parse-state)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1105 comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1106 (equal comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1107 (char-to-string (preceding-char))))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1108 ;; get around a bug in forward-line in versions <= 18.57 |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1109 (if (or (> (forward-line 1) 0) (eobp)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1110 (setq not-done nil)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1111 ;; else: |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1112 ;; if we are at beginning of code line, skip any |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1113 ;; whitespace, labels and tab continuation markers. |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1114 (if (bolp) (skip-chars-forward " \t0-9")) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1115 ;; if we are in column <= 5 now, check for continuation char |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1116 (cond ((= 5 (current-column)) (forward-char 1)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1117 ((and (< (current-column) 5) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1118 (equal fortran-continuation-string |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1119 (char-to-string (following-char))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1120 (forward-char 1)))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1121 ;; find out parse-limit from here |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1122 (setq end-of-line (save-excursion (end-of-line)(point))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1123 (setq parse-limit (min where end-of-line)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1124 ;; parse max up to comment-start, if non-nil and in current line |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1125 (if comment-start |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1126 (save-excursion |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1127 (if (re-search-forward quoted-comment-start end-of-line t) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1128 (setq parse-limit (min (point) parse-limit))))) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1129 ;; now parse if still in limits |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1130 (if (< (point) where) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1131 (setq parse-state (parse-partial-sexp |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1132 (point) parse-limit nil nil parse-state)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1133 (setq not-done nil)) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1134 )) |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1135 ;; result is |
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1136 (nth 3 parse-state)))))) |
1548 | 1137 |
1138 (defun fortran-auto-fill-mode (arg) | |
1139 "Toggle fortran-auto-fill mode. | |
1140 With ARG, turn `fortran-auto-fill' mode on iff ARG is positive. | |
1141 In `fortran-auto-fill' mode, inserting a space at a column beyond `fill-column' | |
1142 automatically breaks the line at a previous space." | |
1143 (interactive "P") | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1144 (prog1 (setq auto-fill-function |
1548 | 1145 (if (if (null arg) |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1146 (not auto-fill-function) |
1548 | 1147 (> (prefix-numeric-value arg) 0)) |
1148 'fortran-indent-line | |
1149 nil)) | |
1150 ;; update mode-line | |
1151 (set-buffer-modified-p (buffer-modified-p)))) | |
1152 | |
1153 (defun fortran-do-auto-fill () | |
1154 (interactive) | |
1155 (let* ((opoint (point)) | |
1156 (bol (save-excursion (beginning-of-line) (point))) | |
1157 (eol (save-excursion (end-of-line) (point))) | |
1158 (bos (min eol (+ bol (fortran-current-line-indentation)))) | |
1159 (quote | |
1160 (save-excursion | |
1161 (goto-char bol) | |
1162 (if (looking-at comment-line-start-skip) | |
1163 nil ; OK to break quotes on comment lines. | |
1164 (move-to-column fill-column) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1165 (cond ((fortran-is-in-string-p (point)) |
1548 | 1166 (save-excursion (re-search-backward "[^']'[^']" bol t) |
1167 (if fortran-break-before-delimiters | |
1168 (point) | |
1169 (1+ (point))))) | |
1170 (t nil))))) | |
1171 ;; | |
1172 ;; decide where to split the line. If a position for a quoted | |
1173 ;; string was found above then use that, else break the line | |
1174 ;; before the last delimiter. | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3567
diff
changeset
|
1175 ;; Delimiters are whitespace, commas, and operators. |
1548 | 1176 ;; Will break before a pair of *'s. |
1177 ;; | |
1178 (fill-point | |
1179 (or quote | |
1180 (save-excursion | |
1181 (move-to-column (1+ fill-column)) | |
1182 (skip-chars-backward "^ \t\n,'+-/*=)" | |
1183 ;;; (if fortran-break-before-delimiters | |
1184 ;;; "^ \t\n,'+-/*=" "^ \t\n,'+-/*=)") | |
1185 ) | |
1186 (if (<= (point) (1+ bos)) | |
1187 (progn | |
1188 (move-to-column (1+ fill-column)) | |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1189 ;;;what is this doing??? |
1548 | 1190 (if (not (re-search-forward "[\t\n,'+-/*)=]" eol t)) |
1191 (goto-char bol)))) | |
1192 (if (bolp) | |
1193 (re-search-forward "[ \t]" opoint t) | |
1194 (forward-char -1) | |
1195 (if (looking-at "'") | |
1196 (forward-char 1) | |
1197 (skip-chars-backward " \t\*"))) | |
1198 (if fortran-break-before-delimiters | |
1199 (point) | |
1200 (1+ (point)))))) | |
1201 ) | |
1202 ;; if we are in an in-line comment, don't break unless the | |
1203 ;; line of code is longer than it should be. Otherwise | |
1204 ;; break the line at the column computed above. | |
1205 ;; | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1206 ;; Need to use fortran-find-comment-start-skip to make sure that quoted !'s |
1548 | 1207 ;; don't prevent a break. |
1208 (if (not (or (save-excursion | |
1209 (if (and (re-search-backward comment-start-skip bol t) | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1210 (not (fortran-is-in-string-p (point)))) |
1548 | 1211 (progn |
1212 (skip-chars-backward " \t") | |
1213 (< (current-column) (1+ fill-column))))) | |
1214 (save-excursion | |
1215 (goto-char fill-point) | |
1216 (bolp)))) | |
1217 (if (> (save-excursion | |
1218 (goto-char fill-point) (current-column)) | |
1219 (1+ fill-column)) | |
1220 (progn (goto-char fill-point) | |
1221 (fortran-break-line)) | |
1222 (save-excursion | |
1223 (if (> (save-excursion | |
1224 (goto-char fill-point) | |
1225 (current-column)) | |
1226 (+ (calculate-fortran-indent) fortran-continuation-indent)) | |
1227 (progn | |
1228 (goto-char fill-point) | |
1229 (fortran-break-line)))))) | |
1230 )) | |
1231 (defun fortran-break-line () | |
1232 (let ((opoint (point)) | |
1233 (bol (save-excursion (beginning-of-line) (point))) | |
1234 (eol (save-excursion (end-of-line) (point))) | |
1235 (comment-string nil)) | |
1236 | |
1237 (save-excursion | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1238 (if (and comment-start-skip (fortran-find-comment-start-skip)) |
1548 | 1239 (progn |
1240 (re-search-backward comment-start-skip bol t) | |
1241 (setq comment-string (buffer-substring (point) eol)) | |
1242 (delete-region (point) eol)))) | |
1243 ;;; Forward line 1 really needs to go to next non white line | |
1244 (if (save-excursion (forward-line 1) | |
1245 (or (looking-at " [^ 0\n]") | |
1246 (looking-at "\t[1-9]"))) | |
1247 (progn | |
1248 (forward-line 1) | |
1249 (delete-indentation) | |
1250 (delete-char 2) | |
1251 (delete-horizontal-space) | |
1252 (fortran-do-auto-fill)) | |
1253 (fortran-split-line)) | |
1254 (if comment-string | |
1255 (save-excursion | |
1256 (goto-char bol) | |
1257 (end-of-line) | |
1258 (delete-horizontal-space) | |
1259 (indent-to (fortran-comment-hook)) | |
1260 (insert comment-string))))) | |
1261 | |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1262 (defun fortran-analyze-file-format () |
5720
fe1a71db966f
(calculate-fortran-indent): Handle
Richard M. Stallman <rms@gnu.org>
parents:
5065
diff
changeset
|
1263 "Returns nil if fixed format is used, t if TAB formatting is used. |
1633
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1264 Use `fortran-tab-mode-default' if no non-comment statements are found in the |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1265 file before the end or the first `fortran-analyze-depth' lines." |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1266 (let ((i 0)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1267 (save-excursion |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1268 (goto-char (point-min)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1269 (setq i 0) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1270 (while (not (or |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1271 (eobp) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1272 (looking-at "\t") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1273 (looking-at " ") |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1274 (> i fortran-analyze-depth))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1275 (forward-line) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1276 (setq i (1+ i))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1277 (cond |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1278 ((looking-at "\t") t) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1279 ((looking-at " ") nil) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1280 (fortran-tab-mode-default t) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1281 (t nil))))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1282 |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1283 (or (assq 'fortran-tab-mode-string minor-mode-alist) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1284 (setq minor-mode-alist (cons |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1285 '(fortran-tab-mode-string |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1286 (indent-tabs-mode fortran-tab-mode-string)) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1287 minor-mode-alist))) |
65af7bcd5e31
* fortran.el: New version of version 1.30 (!) from Stephen A. Wood
Jim Blandy <jimb@redhat.com>
parents:
1611
diff
changeset
|
1288 |
584 | 1289 (provide 'fortran) |
1290 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1291 ;;; fortran.el ends here |
3400
927c3d8374ef
(fortran-mode): Replace comment-indent-hook with
Richard M. Stallman <rms@gnu.org>
parents:
2307
diff
changeset
|
1292 |