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