Mercurial > emacs
comparison lisp/progmodes/f90.el @ 44866:582f083ed579
General tidy-up of commentary and some doc strings.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 25 Apr 2002 21:55:39 +0000 |
parents | 82abaa8dbf18 |
children | 972dc81abf82 |
comparison
equal
deleted
inserted
replaced
44865:590c97430876 | 44866:582f083ed579 |
---|---|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
24 ;; Boston, MA 02111-1307, USA. | 24 ;; Boston, MA 02111-1307, USA. |
25 | 25 |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;; Smart mode for editing F90 programs in FREE FORMAT. | 28 ;; Major mode for editing F90 programs in FREE FORMAT. |
29 ;; The minor language revision F95 is also supported (with font-locking). | |
30 | |
29 ;; Knows about continuation lines, named structured statements, and other | 31 ;; Knows about continuation lines, named structured statements, and other |
30 ;; new features in F90 including HPF (High Performance Fortran) structures. | 32 ;; features in F90 including HPF (High Performance Fortran) structures. |
31 ;; The basic feature is to provide an accurate indentation of F90 programs. | 33 ;; The basic feature provides accurate indentation of F90 programs. |
32 ;; In addition, there are many more features like automatic matching of all | 34 ;; In addition, there are many more features like automatic matching of all |
33 ;; end statements, an auto-fill function to break long lines, a join-lines | 35 ;; end statements, an auto-fill function to break long lines, a join-lines |
34 ;; function which joins continued lines etc etc. | 36 ;; function which joins continued lines, etc. |
35 ;; To facilitate typing, a fairly complete list of abbreviations is provided. | 37 |
36 ;; For example, `i is short-hand for integer (if abbrev-mode is on). | 38 ;; To facilitate typing, a fairly complete list of abbreviations is provided. |
37 | 39 ;; All abbreviations begin with the backquote character "`" |
38 ;; There are two separate features for highlighting the code. | 40 ;; (this requires modification of the syntax-table). |
41 ;; For example, `i expands to integer (if abbrev-mode is on). | |
42 | |
43 ;; There are two separate features for altering the appearance of code: | |
39 ;; 1) Upcasing or capitalizing of all keywords. | 44 ;; 1) Upcasing or capitalizing of all keywords. |
40 ;; 2) Colors/fonts using font-lock-mode. (only when using X-windows) | 45 ;; 2) Colors/fonts using font-lock-mode. |
41 ;; Automatic upcase of downcase of keywords is controlled by the parameter | 46 ;; Automatic upcase or downcase of keywords is controlled by the variable |
42 ;; f90-auto-keyword-case. | 47 ;; f90-auto-keyword-case. |
43 | 48 |
44 ;; The indentations of lines starting with ! is determined by the first of the | 49 ;; The indentations of lines starting with ! is determined by the first of the |
45 ;; following matches (the values in the left column are the default values): | 50 ;; following matches (values in the left column are the defaults): |
46 | 51 |
47 ;; start-string/regexp indent variable holding start-string/regexp | 52 ;; start-string/regexp indent variable holding start-string/regexp |
48 ;; !!! 0 | 53 ;; !!! 0 |
49 ;; !hpf\\$ (re) 0 f90-directive-comment-re | 54 ;; !hpf\\$ (re) 0 f90-directive-comment-re |
50 ;; !!$ 0 f90-comment-region | 55 ;; !!$ 0 f90-comment-region |
54 ;; Ex: Here is the result of 3 different settings of f90-indented-comment-re | 59 ;; Ex: Here is the result of 3 different settings of f90-indented-comment-re |
55 ;; f90-indented-comment-re !-indentation !!-indentation | 60 ;; f90-indented-comment-re !-indentation !!-indentation |
56 ;; ! as code as code | 61 ;; ! as code as code |
57 ;; !! comment-column as code | 62 ;; !! comment-column as code |
58 ;; ![^!] as code comment-column | 63 ;; ![^!] as code comment-column |
59 ;; Trailing comments are indented to comment-column with indent-for-comment M-; | 64 ;; Trailing comments are indented to comment-column with indent-for-comment. |
60 ;; f90-comment-region (C-c;) toggles insertion of f90-comment-region in region. | 65 ;; The function f90-comment-region toggles insertion of |
66 ;; the variable f90-comment-region in every line of the region. | |
61 | 67 |
62 ;; One common convention for free vs. fixed format is that free-format files | 68 ;; One common convention for free vs. fixed format is that free-format files |
63 ;; have the ending .f90 while the fixed format files have the ending .f. | 69 ;; have the ending .f90 or .f95 while fixed format files have the ending .f. |
64 ;; To make f90-mode work, put this file in, for example, your directory | 70 ;; Emacs automatically loads Fortran files in the appropriate mode based |
65 ;; ~/lisp, and be sure that you have the following in your .emacs-file | 71 ;; on extension. You can modify this by adjusting the variable auto-mode-alist. |
66 ;; (setq load-path (append load-path '("~/lisp"))) | 72 ;; For example: |
67 ;; (autoload 'f90-mode "f90" | 73 ;; (add-to-list 'auto-mode-alist '("\\.f\\'" . f90-mode)) |
68 ;; "Major mode for editing Fortran 90 code in free format." t) | 74 |
69 ;; (setq auto-mode-alist (append auto-mode-alist | |
70 ;; (list '("\\.f90$" . f90-mode)))) | |
71 ;; Once you have entered f90-mode, you may get more info by using | 75 ;; Once you have entered f90-mode, you may get more info by using |
72 ;; the command describe-mode (C-h m). For online help describing various | 76 ;; the command describe-mode (C-h m). For online help use |
73 ;; functions use C-h f <Name of function you want described> | 77 ;; C-h f <Name of function you want described>, or |
74 | 78 ;; C-h v <Name of variable you want described>. |
75 ;; To customize the f90-mode for your taste, use, for example: | 79 |
76 ;; (you don't have to specify values for all the parameters below) | 80 ;; To customize f90-mode for your taste, use, for example: |
81 ;; (you don't have to specify values for all the parameters below) | |
82 ;; | |
77 ;;(add-hook 'f90-mode-hook | 83 ;;(add-hook 'f90-mode-hook |
84 ;; ;; These are the default values. | |
78 ;; '(lambda () (setq f90-do-indent 3 | 85 ;; '(lambda () (setq f90-do-indent 3 |
79 ;; f90-if-indent 3 | 86 ;; f90-if-indent 3 |
80 ;; f90-type-indent 3 | 87 ;; f90-type-indent 3 |
81 ;; f90-program-indent 2 | 88 ;; f90-program-indent 2 |
82 ;; f90-continuation-indent 5 | 89 ;; f90-continuation-indent 5 |
83 ;; f90-comment-region "!!$" | 90 ;; f90-comment-region "!!$" |
84 ;; f90-directive-comment-re "!hpf\\$" | 91 ;; f90-directive-comment-re "!hpf\\$" |
85 ;; f90-indented-comment-re "!" | 92 ;; f90-indented-comment-re "!" |
86 ;; f90-break-delimiters "[-+\\*/,><=% \t]" | 93 ;; f90-break-delimiters "[-+\\*/><=,% \t]" |
87 ;; f90-break-before-delimiters t | 94 ;; f90-break-before-delimiters t |
88 ;; f90-beginning-ampersand t | 95 ;; f90-beginning-ampersand t |
89 ;; f90-smart-end 'blink | 96 ;; f90-smart-end 'blink |
90 ;; f90-auto-keyword-case nil | 97 ;; f90-auto-keyword-case nil |
91 ;; f90-leave-line-no nil | 98 ;; f90-leave-line-no nil |
92 ;; indent-tabs-mode nil | 99 ;; indent-tabs-mode nil |
93 ;; f90-font-lock-keywords f90-font-lock-keywords-2 | 100 ;; f90-font-lock-keywords f90-font-lock-keywords-2 |
94 ;; ) | 101 ;; ) |
95 ;; ;;The rest is not default. | 102 ;; ;; These are not default. |
96 ;; (abbrev-mode 1) ; turn on abbreviation mode | 103 ;; (abbrev-mode 1) ; turn on abbreviation mode |
97 ;; (f90-add-imenu-menu) ; extra menu with functions etc. | 104 ;; (f90-add-imenu-menu) ; extra menu with functions etc. |
98 ;; (if f90-auto-keyword-case ; change case of all keywords on startup | 105 ;; (if f90-auto-keyword-case ; change case of all keywords on startup |
99 ;; (f90-change-keywords f90-auto-keyword-case)) | 106 ;; (f90-change-keywords f90-auto-keyword-case)) |
100 ;; )) | 107 ;; )) |
101 ;; in your .emacs file (the shown values are the defaults). You can also | 108 ;; |
102 ;; change the values of the lists f90-keywords etc. | 109 ;; in your .emacs file. You can also customize the lists |
103 ;; The auto-fill and abbreviation minor modes are accessible from the menu, | 110 ;; f90-font-lock-keywords, etc. |
111 ;; | |
112 ;; The auto-fill and abbreviation minor modes are accessible from the F90 menu, | |
104 ;; or by using M-x auto-fill-mode and M-x abbrev-mode, respectively. | 113 ;; or by using M-x auto-fill-mode and M-x abbrev-mode, respectively. |
105 | 114 |
106 ;; Remarks | 115 ;; Remarks |
107 ;; 1) Line numbers are by default left-justified. If f90-leave-line-no is | 116 ;; 1) Line numbers are by default left-justified. If f90-leave-line-no is |
108 ;; non-nil, the line numbers are never touched. | 117 ;; non-nil, the line numbers are never touched. |
109 ;; 2) Multi-; statements like > do i=1,20 ; j=j+i ; end do < are not handled | 118 ;; 2) Multi-; statements like "do i=1,20 ; j=j+i ; end do" are not handled |
110 ;; correctly, but I imagine them to be rare. | 119 ;; correctly, but I imagine them to be rare. |
111 ;; 3) Regexps for hilit19 are no longer supported. | 120 ;; 3) Regexps for hilit19 are no longer supported. |
112 ;; 4) For FIXED FORMAT code, use the ordinary fortran mode. | 121 ;; 4) For FIXED FORMAT code, use fortran mode. |
113 ;; 5) This mode does not work under emacs-18.x. | 122 ;; 5) This mode does not work under emacs-18.x. |
114 ;; 6) Preprocessor directives, i.e., lines starting with # are left-justified | 123 ;; 6) Preprocessor directives, i.e., lines starting with # are left-justified |
115 ;; and are untouched by all case-changing commands. There is, at present, no | 124 ;; and are untouched by all case-changing commands. There is, at present, no |
116 ;; mechanism for treating multi-line directives (continued by \ ). | 125 ;; mechanism for treating multi-line directives (continued by \ ). |
117 ;; 7) f77 do-loops do 10 i=.. ; ; 10 continue are not correctly indented. | 126 ;; 7) f77 do-loops do 10 i=.. ; ; 10 continue are not correctly indented. |
132 ;; f90-downcase-keywords f90-downcase-region-keywords | 141 ;; f90-downcase-keywords f90-downcase-region-keywords |
133 ;; f90-capitalize-keywords f90-capitalize-region-keywords | 142 ;; f90-capitalize-keywords f90-capitalize-region-keywords |
134 ;; f90-add-imenu-menu | 143 ;; f90-add-imenu-menu |
135 ;; f90-font-lock-1, f90-font-lock-2, f90-font-lock-3, f90-font-lock-4 | 144 ;; f90-font-lock-1, f90-font-lock-2, f90-font-lock-3, f90-font-lock-4 |
136 | 145 |
146 ;; Original author's thanks | |
137 ;; Thanks to all the people who have tested the mode. Special thanks to Jens | 147 ;; Thanks to all the people who have tested the mode. Special thanks to Jens |
138 ;; Bloch Helmers for encouraging me to write this code, for creative | 148 ;; Bloch Helmers for encouraging me to write this code, for creative |
139 ;; suggestions as well as for the lists of hpf-commands. | 149 ;; suggestions as well as for the lists of hpf-commands. |
140 ;; Also thanks to the authors of the fortran and pascal modes, on which some | 150 ;; Also thanks to the authors of the fortran and pascal modes, on which some |
141 ;; of this code is built. | 151 ;; of this code is built. |
142 | 152 |
153 ;; TODO | |
154 ;; Support for hideshow, align. | |
155 ;; OpenMP, preprocessor highlighting. | |
156 | |
143 ;;; Code: | 157 ;;; Code: |
144 | 158 |
145 ;; User options | 159 ;; User options |
146 | 160 |
147 (defgroup f90 nil | 161 (defgroup f90 nil |
148 "Fortran-90 mode" | 162 "Major mode for editing Fortran 90,95 code." |
149 :group 'languages) | 163 :group 'languages) |
150 | 164 |
151 (defgroup f90-indent nil | 165 (defgroup f90-indent nil |
152 "Fortran-90 indentation" | 166 "Indentation in free-format Fortran." |
153 :prefix "f90-" | 167 :prefix "f90-" |
154 :group 'f90) | 168 :group 'f90) |
155 | 169 |
156 | 170 |
157 (defcustom f90-do-indent 3 | 171 (defcustom f90-do-indent 3 |
178 "*Extra indentation applied to F90 continuation lines." | 192 "*Extra indentation applied to F90 continuation lines." |
179 :type 'integer | 193 :type 'integer |
180 :group 'f90-indent) | 194 :group 'f90-indent) |
181 | 195 |
182 (defcustom f90-comment-region "!!$" | 196 (defcustom f90-comment-region "!!$" |
183 "*String inserted by \\[f90-comment-region]\ | 197 "*String inserted by \\[f90-comment-region] at start of each line in region." |
184 at start of each line in region." | |
185 :type 'string | 198 :type 'string |
186 :group 'f90-indent) | 199 :group 'f90-indent) |
187 | 200 |
188 (defcustom f90-indented-comment-re "!" | 201 (defcustom f90-indented-comment-re "!" |
189 "*Regexp saying which comments to be indented like code." | 202 "*Regexp saying which comments to indent like code." |
190 :type 'regexp | 203 :type 'regexp |
191 :group 'f90-indent) | 204 :group 'f90-indent) |
192 | 205 |
193 (defcustom f90-directive-comment-re "!hpf\\$" | 206 (defcustom f90-directive-comment-re "!hpf\\$" |
194 "*Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented." | 207 "*Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented." |
195 :type 'regexp | 208 :type 'regexp |
196 :group 'f90-indent) | 209 :group 'f90-indent) |
197 | 210 |
198 (defcustom f90-beginning-ampersand t | 211 (defcustom f90-beginning-ampersand t |
199 "*t makes automatic insertion of \& at beginning of continuation line." | 212 "*Non-nil gives automatic insertion of \& at start of continuation line." |
200 :type 'boolean | 213 :type 'boolean |
201 :group 'f90) | 214 :group 'f90) |
202 | 215 |
203 (defcustom f90-smart-end 'blink | 216 (defcustom f90-smart-end 'blink |
204 "*From an END statement, check and fill the end using matching block start. | 217 "*From an END statement, check and fill the end using matching block start. |
217 :type 'boolean | 230 :type 'boolean |
218 :group 'f90) | 231 :group 'f90) |
219 | 232 |
220 (defcustom f90-auto-keyword-case nil | 233 (defcustom f90-auto-keyword-case nil |
221 "*Automatic case conversion of keywords. | 234 "*Automatic case conversion of keywords. |
222 The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil" | 235 The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil." |
223 :type '(choice (const downcase-word) (const upcase-word) | 236 :type '(choice (const downcase-word) (const upcase-word) |
224 (const capitalize-word) (const nil)) | 237 (const capitalize-word) (const nil)) |
225 :group 'f90) | 238 :group 'f90) |
226 | 239 |
227 (defcustom f90-leave-line-no nil | 240 (defcustom f90-leave-line-no nil |
228 "*If nil, left-justify linenumbers." | 241 "*If non-nil, line numbers are not left justified." |
229 :type 'boolean | 242 :type 'boolean |
230 :group 'f90) | 243 :group 'f90) |
231 | 244 |
232 (defconst f90-keywords-re | 245 (defconst f90-keywords-re |
233 (regexp-opt '("allocatable" "allocate" "assign" "assignment" "backspace" | 246 (regexp-opt '("allocatable" "allocate" "assign" "assignment" "backspace" |
256 "public" "read" "recursive" "result" "rewind" "save" "select" | 269 "public" "read" "recursive" "result" "rewind" "save" "select" |
257 "sequence" "target" "write" | 270 "sequence" "target" "write" |
258 ;; F95 keywords. | 271 ;; F95 keywords. |
259 "elemental" "pure") 'words) | 272 "elemental" "pure") 'words) |
260 "Keyword-regexp for font-lock level >= 3.") | 273 "Keyword-regexp for font-lock level >= 3.") |
261 | |
262 | 274 |
263 (defconst f90-procedures-re | 275 (defconst f90-procedures-re |
264 (concat "\\<" | 276 (concat "\\<" |
265 (regexp-opt | 277 (regexp-opt |
266 '("abs" "achar" "acos" "adjustl" "adjustr" "aimag" "aint" | 278 '("abs" "achar" "acos" "adjustl" "adjustr" "aimag" "aint" |
354 '("\\<\\(case\\)[ \t]*\\(default\\|(\\)" . 1) | 366 '("\\<\\(case\\)[ \t]*\\(default\\|(\\)" . 1) |
355 '("\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)" | 367 '("\\<\\(do\\|go *to\\)\\>[ \t]*\\([0-9]+\\)" |
356 (1 font-lock-keyword-face) (2 font-lock-constant-face)) | 368 (1 font-lock-keyword-face) (2 font-lock-constant-face)) |
357 ;; line numbers (lines whose first character after number is letter) | 369 ;; line numbers (lines whose first character after number is letter) |
358 '("^[ \t]*\\([0-9]+\\)[ \t]*[a-z]+" (1 font-lock-constant-face t)))) | 370 '("^[ \t]*\\([0-9]+\\)[ \t]*[a-z]+" (1 font-lock-constant-face t)))) |
359 "Highlights declarations, do-loops and other constructions") | 371 "Highlights declarations, do-loops and other constructs.") |
360 | 372 |
361 (defvar f90-font-lock-keywords-3 | 373 (defvar f90-font-lock-keywords-3 |
362 (append f90-font-lock-keywords-2 | 374 (append f90-font-lock-keywords-2 |
363 (list | 375 (list |
364 f90-keywords-level-3-re | 376 f90-keywords-level-3-re |
372 (append f90-font-lock-keywords-3 | 384 (append f90-font-lock-keywords-3 |
373 (list f90-hpf-keywords-re)) | 385 (list f90-hpf-keywords-re)) |
374 "Highlights all F90 and HPF keywords.") | 386 "Highlights all F90 and HPF keywords.") |
375 | 387 |
376 (defvar f90-font-lock-keywords | 388 (defvar f90-font-lock-keywords |
377 f90-font-lock-keywords-2 | 389 f90-font-lock-keywords-2 |
378 "*Default expressions to highlight in F90 mode.") | 390 "*Default expressions to highlight in F90 mode.") |
379 | 391 |
380 ;; syntax table | 392 ;; syntax table |
381 (defvar f90-mode-syntax-table nil | 393 (defvar f90-mode-syntax-table nil |
382 "Syntax table in use in F90 mode buffers.") | 394 "Syntax table in use in F90 mode buffers.") |
642 ;; Less than three non-space characters before function/subroutine | 654 ;; Less than three non-space characters before function/subroutine |
643 good-char "?" good-char "?" | 655 good-char "?" good-char "?" |
644 "\\)" | 656 "\\)" |
645 "[ \t]*\\(function\\|subroutine\\)[ \t]+\\(\\sw+\\)") | 657 "[ \t]*\\(function\\|subroutine\\)[ \t]+\\(\\sw+\\)") |
646 4))) | 658 4))) |
647 "imenu generic expression for F90 mode.") | 659 "Generic imenu expression for F90 mode.") |
648 | 660 |
649 (defun f90-add-imenu-menu () | 661 (defun f90-add-imenu-menu () |
650 (interactive) | |
651 "Add an imenu menu to the menubar." | 662 "Add an imenu menu to the menubar." |
663 (interactive) | |
652 (if (not f90-imenu) | 664 (if (not f90-imenu) |
653 (progn | 665 (progn |
654 (imenu-add-to-menubar "F90-imenu") | 666 (imenu-add-to-menubar "F90-imenu") |
655 (redraw-frame (selected-frame)) | 667 (redraw-frame (selected-frame)) |
656 (setq f90-imenu t)) | 668 (setq f90-imenu t)) |
733 :options '(f90-add-imenu-menu) | 745 :options '(f90-add-imenu-menu) |
734 :group 'f90) | 746 :group 'f90) |
735 | 747 |
736 ;;;###autoload | 748 ;;;###autoload |
737 (defun f90-mode () | 749 (defun f90-mode () |
738 "Major mode for editing Fortran 90 code in free format. | 750 "Major mode for editing Fortran 90,95 code in free format. |
739 | 751 |
740 \\[f90-indent-new-line] corrects current indentation and creates new\ | 752 \\[f90-indent-new-line] corrects current indentation and creates new\ |
741 indented line. | 753 indented line. |
742 \\[f90-indent-line] indents the current line correctly. | 754 \\[f90-indent-line] indents the current line correctly. |
743 \\[f90-indent-subprogram] indents the current subprogram. | 755 \\[f90-indent-subprogram] indents the current subprogram. |
744 | 756 |
745 Type `? or `\\[help-command] to display a list of built-in\ | 757 Type `? or `\\[help-command] to display a list of built-in\ |
746 abbrevs for F90 keywords. | 758 abbrevs for F90 keywords. |
747 | 759 |
748 Key definitions: | 760 Key definitions: |
749 \\{f90-mode-map} | 761 \\{f90-mode-map} |
750 | 762 |
751 Variables controlling indentation style and extra features: | 763 Variables controlling indentation style and extra features: |
752 | 764 |
753 f90-do-indent | 765 `f90-do-indent' |
754 Extra indentation within do blocks. (default 3) | 766 Extra indentation within do blocks. (default 3) |
755 f90-if-indent | 767 `f90-if-indent' |
756 Extra indentation within if/select case/where/forall blocks. (default 3) | 768 Extra indentation within if/select case/where/forall blocks. (default 3) |
757 f90-type-indent | 769 `f90-type-indent' |
758 Extra indentation within type/interface/block-data blocks. (default 3) | 770 Extra indentation within type/interface/block-data blocks. (default 3) |
759 f90-program-indent | 771 `f90-program-indent' |
760 Extra indentation within program/module/subroutine/function blocks. | 772 Extra indentation within program/module/subroutine/function blocks. |
761 (default 2) | 773 (default 2) |
762 f90-continuation-indent | 774 `f90-continuation-indent' |
763 Extra indentation applied to continuation lines. (default 5) | 775 Extra indentation applied to continuation lines. (default 5) |
764 f90-comment-region | 776 `f90-comment-region' |
765 String inserted by \\[f90-comment-region] at start of each line in | 777 String inserted by \\[f90-comment-region] at start of each line in |
766 region. (default \"!!!$\") | 778 region. (default \"!!!$\") |
767 f90-indented-comment-re | 779 `f90-indented-comment-re' |
768 Regexp determining the type of comment to be intended like code. | 780 Regexp determining the type of comment to be intended like code. |
769 (default \"!\") | 781 (default \"!\") |
770 f90-directive-comment-re | 782 `f90-directive-comment-re' |
771 Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented. | 783 Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented. |
772 (default \"!hpf\\\\$\") | 784 (default \"!hpf\\\\$\") |
773 f90-break-delimiters | 785 `f90-break-delimiters' |
774 Regexp holding list of delimiters at which lines may be broken. | 786 Regexp holding list of delimiters at which lines may be broken. |
775 (default \"[-+*/><=,% \\t]\") | 787 (default \"[-+*/><=,% \\t]\") |
776 f90-break-before-delimiters | 788 `f90-break-before-delimiters' |
777 Non-nil causes `f90-do-auto-fill' to break lines before delimiters. | 789 Non-nil causes `f90-do-auto-fill' to break lines before delimiters. |
778 (default t) | 790 (default t) |
779 f90-beginning-ampersand | 791 `f90-beginning-ampersand' |
780 Automatic insertion of \& at beginning of continuation lines. (default t) | 792 Automatic insertion of \& at beginning of continuation lines. (default t) |
781 f90-smart-end | 793 `f90-smart-end' |
782 From an END statement, check and fill the end using matching block start. | 794 From an END statement, check and fill the end using matching block start. |
783 Allowed values are 'blink, 'no-blink, and nil, which determine | 795 Allowed values are 'blink, 'no-blink, and nil, which determine |
784 whether to blink the matching beginning.) (default 'blink) | 796 whether to blink the matching beginning. (default 'blink) |
785 f90-auto-keyword-case | 797 `f90-auto-keyword-case' |
786 Automatic change of case of keywords. (default nil) | 798 Automatic change of case of keywords. (default nil) |
787 The possibilities are 'downcase-word, 'upcase-word, 'capitalize-word. | 799 The possibilities are 'downcase-word, 'upcase-word, 'capitalize-word. |
788 f90-leave-line-no | 800 `f90-leave-line-no' |
789 Do not left-justify line numbers. (default nil) | 801 Do not left-justify line numbers. (default nil) |
790 f90-keywords-re | 802 `f90-keywords-re' |
791 List of keywords used for highlighting/upcase-keywords etc. | 803 List of keywords used for highlighting/upcase-keywords etc. |
792 | 804 |
793 Turning on F90 mode calls the value of the variable `f90-mode-hook' | 805 Turning on F90 mode calls the value of the variable `f90-mode-hook' |
794 with no args, if that value is non-nil." | 806 with no args, if that value is non-nil." |
795 (interactive) | 807 (interactive) |
875 (save-excursion | 887 (save-excursion |
876 (beginning-of-line) (skip-chars-forward " \t0-9"))) | 888 (beginning-of-line) (skip-chars-forward " \t0-9"))) |
877 | 889 |
878 (defsubst f90-indent-to (col &optional no-line-number) | 890 (defsubst f90-indent-to (col &optional no-line-number) |
879 "Indent current line to column COL. | 891 "Indent current line to column COL. |
880 If no-line-number nil, jump over a possible line-number." | 892 If optional argument NO-LINE-NUMBER is nil, jump over a possible line-number." |
881 (beginning-of-line) | 893 (beginning-of-line) |
882 (if (not no-line-number) | 894 (if (not no-line-number) |
883 (skip-chars-forward " \t0-9")) | 895 (skip-chars-forward " \t0-9")) |
884 (delete-horizontal-space) | 896 (delete-horizontal-space) |
885 (if (zerop (current-column)) | 897 (if (zerop (current-column)) |
1038 eol (line-end-position)) | 1050 eol (line-end-position)) |
1039 (if f90-auto-keyword-case | 1051 (if f90-auto-keyword-case |
1040 (f90-change-keywords f90-auto-keyword-case bol eol)))))) | 1052 (f90-change-keywords f90-auto-keyword-case bol eol)))))) |
1041 | 1053 |
1042 (defun f90-electric-insert () | 1054 (defun f90-electric-insert () |
1043 (interactive) | 1055 "Call `f90-do-auto-fill' at each operator insertion." |
1044 "Calls f90-do-auto-fill at each operator insertion." | 1056 (interactive) |
1045 (self-insert-command 1) | 1057 (self-insert-command 1) |
1046 (f90-update-line) | 1058 (f90-update-line) |
1047 (if auto-fill-function (f90-do-auto-fill))) | 1059 (if auto-fill-function (f90-do-auto-fill))) |
1048 | 1060 |
1049 (defun f90-get-correct-indent () | 1061 (defun f90-get-correct-indent () |
1239 (delete-region (point) (match-end 0)) | 1251 (delete-region (point) (match-end 0)) |
1240 (insert f90-comment-region))) | 1252 (insert f90-comment-region))) |
1241 (set-marker end nil))) | 1253 (set-marker end nil))) |
1242 | 1254 |
1243 (defun f90-indent-line (&optional no-update) | 1255 (defun f90-indent-line (&optional no-update) |
1244 "Indent current line as F90 code." | 1256 "Indent current line as F90 code. |
1257 Unless optional argument NO-UPDATE is non-nil, call `f90-update-line' | |
1258 after indenting." | |
1245 (interactive) | 1259 (interactive) |
1246 (let (indent (no-line-number nil) (pos (make-marker)) (case-fold-search t)) | 1260 (let (indent (no-line-number nil) (pos (make-marker)) (case-fold-search t)) |
1247 (set-marker pos (point)) | 1261 (set-marker pos (point)) |
1248 (beginning-of-line) ; Digits after & \n are not line-no | 1262 (beginning-of-line) ; Digits after & \n are not line-no |
1249 (if (save-excursion (and (f90-previous-statement) (f90-line-continued))) | 1263 (if (save-excursion (and (f90-previous-statement) (f90-line-continued))) |
1264 (if (not no-update) (f90-update-line)) | 1278 (if (not no-update) (f90-update-line)) |
1265 (if auto-fill-function (f90-do-auto-fill)) | 1279 (if auto-fill-function (f90-do-auto-fill)) |
1266 (set-marker pos nil))) | 1280 (set-marker pos nil))) |
1267 | 1281 |
1268 (defun f90-indent-new-line () | 1282 (defun f90-indent-new-line () |
1269 "Reindent the current F90 line, insert a newline and indent the newline. | 1283 "Reindent current line, insert a newline and indent the newline. |
1270 An abbrev before point is expanded if `abbrev-mode' is non-nil. | 1284 An abbrev before point is expanded if the variable `abbrev-mode' is non-nil. |
1271 If run in the middle of a line, the line is not broken." | 1285 If run in the middle of a line, the line is not broken." |
1272 (interactive) | 1286 (interactive) |
1273 (let (string cont (case-fold-search t)) | 1287 (let (string cont (case-fold-search t)) |
1274 (if abbrev-mode (expand-abbrev)) | 1288 (if abbrev-mode (expand-abbrev)) |
1275 (beginning-of-line) ; Reindent where likely to be needed. | 1289 (beginning-of-line) ; Reindent where likely to be needed. |
1406 (indent-region (point) (mark) nil) | 1420 (indent-region (point) (mark) nil) |
1407 (message "Indenting the whole file...done"))))) | 1421 (message "Indenting the whole file...done"))))) |
1408 | 1422 |
1409 ;; autofill and break-line | 1423 ;; autofill and break-line |
1410 (defun f90-break-line (&optional no-update) | 1424 (defun f90-break-line (&optional no-update) |
1411 "Break line at point, insert continuation marker(s) and indent." | 1425 "Break line at point, insert continuation marker(s) and indent. |
1426 Unless in a string or comment, or if the optional argument NO-UPDATE | |
1427 is non-nil, call `f90-update-line' after inserting the continuation marker." | |
1412 (interactive) | 1428 (interactive) |
1413 (let (ctype) | 1429 (let (ctype) |
1414 (cond ((f90-in-string) | 1430 (cond ((f90-in-string) |
1415 (insert "&") (newline 1) (insert "&")) | 1431 (insert "&") (newline 1) (insert "&")) |
1416 ((f90-in-comment) | 1432 ((f90-in-comment) |
1422 (newline 1) | 1438 (newline 1) |
1423 (if f90-beginning-ampersand (insert "&"))))) | 1439 (if f90-beginning-ampersand (insert "&"))))) |
1424 (indent-according-to-mode)) | 1440 (indent-according-to-mode)) |
1425 | 1441 |
1426 (defun f90-find-breakpoint () | 1442 (defun f90-find-breakpoint () |
1427 "From fill-column, search backward for break-delimiter." | 1443 "From `fill-column', search backward for break-delimiter." |
1428 (let ((bol (line-beginning-position))) | 1444 (let ((bol (line-beginning-position))) |
1429 (re-search-backward f90-break-delimiters bol) | 1445 (re-search-backward f90-break-delimiters bol) |
1430 (if f90-break-before-delimiters | 1446 (if f90-break-before-delimiters |
1431 (progn (backward-char) | 1447 (progn (backward-char) |
1432 (if (not (looking-at f90-no-break-re)) | 1448 (if (not (looking-at f90-no-break-re)) |
1434 (if (looking-at f90-no-break-re) | 1450 (if (looking-at f90-no-break-re) |
1435 (forward-char 2) | 1451 (forward-char 2) |
1436 (forward-char))))) | 1452 (forward-char))))) |
1437 | 1453 |
1438 (defun f90-do-auto-fill () | 1454 (defun f90-do-auto-fill () |
1439 "Break line if non-white characters beyond fill-column. Also, update line. " | 1455 "Break line if non-white characters beyond `fill-column'. Also, update line." |
1440 (interactive) | 1456 (interactive) |
1441 ;; Break the line before or after the last delimiter (non-word char) if | 1457 ;; Break the line before or after the last delimiter (non-word char) if |
1442 ;; position is beyond fill-column. | 1458 ;; position is beyond fill-column. |
1443 ;; Will not break **, //, or => (specified by f90-no-break-re). | 1459 ;; Will not break **, //, or => (specified by f90-no-break-re). |
1444 (f90-update-line) | 1460 (f90-update-line) |
1583 (goto-char end-point) | 1599 (goto-char end-point) |
1584 (beginning-of-line) | 1600 (beginning-of-line) |
1585 (f90-block-match beg-block beg-name end-block end-name))))))) | 1601 (f90-block-match beg-block beg-name end-block end-name))))))) |
1586 | 1602 |
1587 (defun f90-insert-end () | 1603 (defun f90-insert-end () |
1588 "Inserts an complete end statement matching beginning of present block." | 1604 "Insert a complete end statement matching beginning of present block." |
1589 (interactive) | 1605 (interactive) |
1590 (let ((f90-smart-end (if f90-smart-end f90-smart-end 'blink))) | 1606 (let ((f90-smart-end (if f90-smart-end f90-smart-end 'blink))) |
1591 (insert "end") | 1607 (insert "end") |
1592 (f90-indent-new-line))) | 1608 (f90-indent-new-line))) |
1593 | 1609 |