Mercurial > emacs
comparison lisp/progmodes/f90.el @ 50597:2e53f070cbc3
Whitespace changes, trivial commentary changes.
(f90, f90-indent, f90-program-indent, f90-continuation-indent)
(f90-indented-comment-re, f90-imenu-generic-expression)
(f90-mark-subprogram, f90-join-lines): Minor doc changes.
(f90-menu): Shift definition to initialization of f90-mode-map.
Add customization section.
(f90-mode): Minor doc change. Do not call easy-menu-add.
Set `beginning-of-defun-function' and `end-of-defun-function' to
appropriate F90 functions.
(f90-indent-line, f90-indent-line, f90-indent-subprogram)
(f90-break-line, f90-do-auto-fill, f90-insert-end)
(f90-upcase-keywords, f90-capitalize-keywords)
(f90-downcase-keywords): Change interactive spec.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 15 Apr 2003 19:18:23 +0000 |
parents | 9d10c32adde2 |
children | a8eb65a987d7 |
comparison
equal
deleted
inserted
replaced
50596:201ff32466bc | 50597:2e53f070cbc3 |
---|---|
63 ;; ![^!] as code comment-column | 63 ;; ![^!] as code comment-column |
64 ;; Trailing comments are indented to comment-column with indent-for-comment. | 64 ;; Trailing comments are indented to comment-column with indent-for-comment. |
65 ;; The function f90-comment-region toggles insertion of | 65 ;; The function f90-comment-region toggles insertion of |
66 ;; the variable f90-comment-region in every line of the region. | 66 ;; the variable f90-comment-region in every line of the region. |
67 | 67 |
68 ;; 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 |
69 ;; have the ending .f90 or .f95 while fixed format files have the ending .f. | 69 ;; have the ending .f90 or .f95 while fixed format files have the ending .f. |
70 ;; Emacs automatically loads Fortran files in the appropriate mode based | 70 ;; Emacs automatically loads Fortran files in the appropriate mode based |
71 ;; on extension. You can modify this by adjusting the variable auto-mode-alist. | 71 ;; on extension. You can modify this by adjusting the variable auto-mode-alist. |
72 ;; For example: | 72 ;; For example: |
73 ;; (add-to-list 'auto-mode-alist '("\\.f\\'" . f90-mode)) | 73 ;; (add-to-list 'auto-mode-alist '("\\.f\\'" . f90-mode)) |
148 ;; Bloch Helmers for encouraging me to write this code, for creative | 148 ;; Bloch Helmers for encouraging me to write this code, for creative |
149 ;; suggestions as well as for the lists of hpf-commands. | 149 ;; suggestions as well as for the lists of hpf-commands. |
150 ;; 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 |
151 ;; of this code is built. | 151 ;; of this code is built. |
152 | 152 |
153 ;;; Code: | |
154 | |
153 ;; TODO | 155 ;; TODO |
154 ;; Support for hideshow, align. | 156 ;; Support for hideshow, align. |
155 ;; OpenMP, preprocessor highlighting. | 157 ;; OpenMP, preprocessor highlighting. |
156 | 158 |
157 ;;; Code: | |
158 | |
159 (defvar comment-auto-fill-only-comments) | 159 (defvar comment-auto-fill-only-comments) |
160 (defvar font-lock-keywords) | 160 (defvar font-lock-keywords) |
161 | 161 |
162 ;; User options | 162 ;; User options |
163 | 163 |
164 (defgroup f90 nil | 164 (defgroup f90 nil |
165 "Major mode for editing Fortran 90,95 code." | 165 "Major mode for editing free format Fortran 90,95 code." |
166 :group 'languages) | 166 :group 'languages) |
167 | 167 |
168 (defgroup f90-indent nil | 168 (defgroup f90-indent nil |
169 "Indentation in free-format Fortran." | 169 "Indentation in free format Fortran." |
170 :prefix "f90-" | 170 :prefix "f90-" |
171 :group 'f90) | 171 :group 'f90) |
172 | 172 |
173 | 173 |
174 (defcustom f90-do-indent 3 | 174 (defcustom f90-do-indent 3 |
175 "*Extra indentation applied to DO blocks." | 175 "*Extra indentation applied to DO blocks." |
176 :type 'integer | 176 :type 'integer |
177 :group 'f90-indent) | 177 :group 'f90-indent) |
178 | 178 |
179 (defcustom f90-if-indent 3 | 179 (defcustom f90-if-indent 3 |
180 "*Extra indentation applied to IF, SELECT CASE, WHERE and FORALL blocks." | 180 "*Extra indentation applied to IF, SELECT CASE, WHERE and FORALL blocks." |
181 :type 'integer | 181 :type 'integer |
182 :group 'f90-indent) | 182 :group 'f90-indent) |
183 | 183 |
184 (defcustom f90-type-indent 3 | 184 (defcustom f90-type-indent 3 |
185 "*Extra indentation applied to TYPE, INTERFACE and BLOCK DATA blocks." | 185 "*Extra indentation applied to TYPE, INTERFACE and BLOCK DATA blocks." |
186 :type 'integer | 186 :type 'integer |
187 :group 'f90-indent) | 187 :group 'f90-indent) |
188 | 188 |
189 (defcustom f90-program-indent 2 | 189 (defcustom f90-program-indent 2 |
190 "*Extra indentation applied to PROGRAM/MODULE/SUBROUTINE/FUNCTION blocks." | 190 "*Extra indentation applied to PROGRAM, MODULE, SUBROUTINE, FUNCTION blocks." |
191 :type 'integer | 191 :type 'integer |
192 :group 'f90-indent) | 192 :group 'f90-indent) |
193 | 193 |
194 (defcustom f90-continuation-indent 5 | 194 (defcustom f90-continuation-indent 5 |
195 "*Extra indentation applied to F90 continuation lines." | 195 "*Extra indentation applied to continuation lines." |
196 :type 'integer | 196 :type 'integer |
197 :group 'f90-indent) | 197 :group 'f90-indent) |
198 | 198 |
199 (defcustom f90-comment-region "!!$" | 199 (defcustom f90-comment-region "!!$" |
200 "*String inserted by \\[f90-comment-region] at start of each line in region." | 200 "*String inserted by \\[f90-comment-region] at start of each line in region." |
201 :type 'string | 201 :type 'string |
202 :group 'f90-indent) | 202 :group 'f90-indent) |
203 | 203 |
204 (defcustom f90-indented-comment-re "!" | 204 (defcustom f90-indented-comment-re "!" |
205 "*Regexp saying which comments to indent like code." | 205 "*Regexp matching comments to indent as code." |
206 :type 'regexp | 206 :type 'regexp |
207 :group 'f90-indent) | 207 :group 'f90-indent) |
208 | 208 |
209 (defcustom f90-directive-comment-re "!hpf\\$" | 209 (defcustom f90-directive-comment-re "!hpf\\$" |
210 "*Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented." | 210 "*Regexp of comment-like directive like \"!HPF\\\\$\", not to be indented." |
211 :type 'regexp | 211 :type 'regexp |
212 :group 'f90-indent) | 212 :group 'f90-indent) |
213 | 213 |
214 (defcustom f90-beginning-ampersand t | 214 (defcustom f90-beginning-ampersand t |
215 "*Non-nil gives automatic insertion of \& at start of continuation line." | 215 "*Non-nil gives automatic insertion of \& at start of continuation line." |
216 :type 'boolean | 216 :type 'boolean |
217 :group 'f90) | 217 :group 'f90) |
218 | 218 |
219 (defcustom f90-smart-end 'blink | 219 (defcustom f90-smart-end 'blink |
220 "*From an END statement, check and fill the end using matching block start. | 220 "*From an END statement, check and fill the end using matching block start. |
221 Allowed values are 'blink, 'no-blink, and nil, which determine | 221 Allowed values are 'blink, 'no-blink, and nil, which determine |
222 whether to blink the matching beginning." | 222 whether to blink the matching beginning." |
223 :type '(choice (const blink) (const no-blink) (const nil)) | 223 :type '(choice (const blink) (const no-blink) (const nil)) |
224 :group 'f90) | 224 :group 'f90) |
225 | 225 |
226 (defcustom f90-break-delimiters "[-+\\*/><=,% \t]" | 226 (defcustom f90-break-delimiters "[-+\\*/><=,% \t]" |
227 "*Regexp holding list of delimiters at which lines may be broken." | 227 "*Regexp holding list of delimiters at which lines may be broken." |
228 :type 'regexp | 228 :type 'regexp |
229 :group 'f90) | 229 :group 'f90) |
230 | 230 |
231 (defcustom f90-break-before-delimiters t | 231 (defcustom f90-break-before-delimiters t |
232 "*Non-nil causes `f90-do-auto-fill' to break lines before delimiters." | 232 "*Non-nil causes `f90-do-auto-fill' to break lines before delimiters." |
233 :type 'boolean | 233 :type 'boolean |
234 :group 'f90) | 234 :group 'f90) |
235 | 235 |
236 (defcustom f90-auto-keyword-case nil | 236 (defcustom f90-auto-keyword-case nil |
237 "*Automatic case conversion of keywords. | 237 "*Automatic case conversion of keywords. |
238 The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil." | 238 The options are 'downcase-word, 'upcase-word, 'capitalize-word and nil." |
239 :type '(choice (const downcase-word) (const upcase-word) | 239 :type '(choice (const downcase-word) (const upcase-word) |
240 (const capitalize-word) (const nil)) | 240 (const capitalize-word) (const nil)) |
241 :group 'f90) | 241 :group 'f90) |
242 | 242 |
243 (defcustom f90-leave-line-no nil | 243 (defcustom f90-leave-line-no nil |
244 "*If non-nil, line numbers are not left justified." | 244 "*If non-nil, line numbers are not left justified." |
245 :type 'boolean | 245 :type 'boolean |
246 :group 'f90) | 246 :group 'f90) |
247 | 247 |
248 (defcustom f90-mode-hook nil | 248 (defcustom f90-mode-hook nil |
249 "Hook run when entering F90 mode." | 249 "Hook run when entering F90 mode." |
250 :type 'hook | 250 :type 'hook |
251 :options '(f90-add-imenu-menu) | 251 :options '(f90-add-imenu-menu) |
252 :group 'f90) | 252 :group 'f90) |
253 | 253 |
254 ;; User options end here. | 254 ;; User options end here. |
255 | 255 |
256 (defconst f90-keywords-re | 256 (defconst f90-keywords-re |
257 (regexp-opt '("allocatable" "allocate" "assign" "assignment" "backspace" | 257 (regexp-opt '("allocatable" "allocate" "assign" "assignment" "backspace" |
453 (define-key map "," 'f90-electric-insert) | 453 (define-key map "," 'f90-electric-insert) |
454 (define-key map "+" 'f90-electric-insert) | 454 (define-key map "+" 'f90-electric-insert) |
455 (define-key map "-" 'f90-electric-insert) | 455 (define-key map "-" 'f90-electric-insert) |
456 (define-key map "*" 'f90-electric-insert) | 456 (define-key map "*" 'f90-electric-insert) |
457 (define-key map "/" 'f90-electric-insert) | 457 (define-key map "/" 'f90-electric-insert) |
458 | |
459 (easy-menu-define f90-menu map "Menu for F90 mode." | |
460 `("F90" | |
461 ("Customization" | |
462 ,(custom-menu-create 'f90) | |
463 ["Set" Custom-set t] | |
464 ["Save" Custom-save t] | |
465 ["Reset to Current" Custom-reset-current t] | |
466 ["Reset to Saved" Custom-reset-saved t] | |
467 ["Reset to Standard Settings" Custom-reset-standard t] | |
468 ) | |
469 "--" | |
470 ["Indent Subprogram" f90-indent-subprogram t] | |
471 ["Mark Subprogram" f90-mark-subprogram t] | |
472 ["Beginning of Subprogram" f90-beginning-of-subprogram t] | |
473 ["End of Subprogram" f90-end-of-subprogram t] | |
474 "--" | |
475 ["(Un)Comment Region" f90-comment-region mark-active] | |
476 ["Indent Region" f90-indent-region mark-active] | |
477 ["Fill Region" f90-fill-region mark-active] | |
478 "--" | |
479 ["Break Line at Point" f90-break-line t] | |
480 ["Join with Previous Line" f90-join-lines t] | |
481 ["Insert Block End" f90-insert-end t] | |
482 "--" | |
483 ("Highlighting" | |
484 ["Toggle font-lock-mode" font-lock-mode :selected font-lock-mode | |
485 :style toggle] | |
486 "--" | |
487 ["Light highlighting (level 1)" f90-font-lock-1 t] | |
488 ["Moderate highlighting (level 2)" f90-font-lock-2 t] | |
489 ["Heavy highlighting (level 3)" f90-font-lock-3 t] | |
490 ["Maximum highlighting (level 4)" f90-font-lock-4 t] | |
491 ) | |
492 ("Change Keyword Case" | |
493 ["Upcase Keywords (buffer)" f90-upcase-keywords t] | |
494 ["Capitalize Keywords (buffer)" f90-capitalize-keywords t] | |
495 ["Downcase Keywords (buffer)" f90-downcase-keywords t] | |
496 "--" | |
497 ["Upcase Keywords (region)" f90-upcase-region-keywords | |
498 mark-active] | |
499 ["Capitalize Keywords (region)" f90-capitalize-region-keywords | |
500 mark-active] | |
501 ["Downcase Keywords (region)" f90-downcase-region-keywords | |
502 mark-active] | |
503 ) | |
504 "--" | |
505 ["Toggle auto-fill" auto-fill-mode :selected auto-fill-function | |
506 :style toggle] | |
507 ["Toggle abbrev-mode" abbrev-mode :selected abbrev-mode | |
508 :style toggle] | |
509 ["Add imenu Menu" f90-add-imenu-menu | |
510 :active (not (lookup-key (current-local-map) [menu-bar index])) | |
511 :included (fboundp 'imenu-add-to-menubar)])) | |
458 map) | 512 map) |
459 "Keymap used in F90 mode.") | 513 "Keymap used in F90 mode.") |
460 | 514 |
461 | |
462 (easy-menu-define f90-menu f90-mode-map "Menu for F90 mode." | |
463 '("F90" | |
464 ["Indent Subprogram" f90-indent-subprogram t] | |
465 ["Mark Subprogram" f90-mark-subprogram t] | |
466 ["Beginning of Subprogram" f90-beginning-of-subprogram t] | |
467 ["End of Subprogram" f90-end-of-subprogram t] | |
468 "--" | |
469 ["(Un)Comment Region" f90-comment-region mark-active] | |
470 ["Indent Region" f90-indent-region mark-active] | |
471 ["Fill Region" f90-fill-region mark-active] | |
472 "--" | |
473 ["Break Line at Point" f90-break-line t] | |
474 ["Join with Previous Line" f90-join-lines t] | |
475 ["Insert Block End" f90-insert-end t] | |
476 "--" | |
477 ("Highlighting" | |
478 ["Toggle font-lock-mode" font-lock-mode :selected font-lock-mode | |
479 :style toggle] | |
480 "--" | |
481 ["Light highlighting (level 1)" f90-font-lock-1 t] | |
482 ["Moderate highlighting (level 2)" f90-font-lock-2 t] | |
483 ["Heavy highlighting (level 3)" f90-font-lock-3 t] | |
484 ["Maximum highlighting (level 4)" f90-font-lock-4 t] | |
485 ) | |
486 ("Change Keyword Case" | |
487 ["Upcase Keywords (buffer)" f90-upcase-keywords t] | |
488 ["Capitalize Keywords (buffer)" f90-capitalize-keywords t] | |
489 ["Downcase Keywords (buffer)" f90-downcase-keywords t] | |
490 "--" | |
491 ["Upcase Keywords (region)" f90-upcase-region-keywords mark-active] | |
492 ["Capitalize Keywords (region)" f90-capitalize-region-keywords | |
493 mark-active] | |
494 ["Downcase Keywords (region)" f90-downcase-region-keywords mark-active] | |
495 ) | |
496 "--" | |
497 ["Toggle auto-fill" auto-fill-mode :selected auto-fill-function | |
498 :style toggle] | |
499 ["Toggle abbrev-mode" abbrev-mode :selected abbrev-mode :style toggle] | |
500 ["Add imenu Menu" f90-add-imenu-menu | |
501 :active (not (lookup-key (current-local-map) [menu-bar index])) | |
502 :included (fboundp 'imenu-add-to-menubar)] | |
503 )) | |
504 | 515 |
505 (defun f90-font-lock-1 () | 516 (defun f90-font-lock-1 () |
506 "Set `font-lock-keywords' to `f90-font-lock-keywords-1'." | 517 "Set `font-lock-keywords' to `f90-font-lock-keywords-1'." |
507 (interactive) | 518 (interactive) |
508 (font-lock-mode 1) | 519 (font-lock-mode 1) |
593 ;; Less than three non-space characters before function/subroutine. | 604 ;; Less than three non-space characters before function/subroutine. |
594 good-char "?" good-char "?" | 605 good-char "?" good-char "?" |
595 "\\)" | 606 "\\)" |
596 "[ \t]*\\(function\\|subroutine\\)[ \t]+\\(\\sw+\\)") | 607 "[ \t]*\\(function\\|subroutine\\)[ \t]+\\(\\sw+\\)") |
597 4))) | 608 4))) |
598 "Generic imenu expression for F90 mode.") | 609 "Value for `imenu-generic-expression' in F90 mode.") |
599 | 610 |
600 (defun f90-add-imenu-menu () | 611 (defun f90-add-imenu-menu () |
601 "Add an imenu menu to the menubar." | 612 "Add an imenu menu to the menubar." |
602 (interactive) | 613 (interactive) |
603 (if (lookup-key (current-local-map) [menu-bar index]) | 614 (if (lookup-key (current-local-map) [menu-bar index]) |
678 | 689 |
679 | 690 |
680 ;;;###autoload | 691 ;;;###autoload |
681 (defun f90-mode () | 692 (defun f90-mode () |
682 "Major mode for editing Fortran 90,95 code in free format. | 693 "Major mode for editing Fortran 90,95 code in free format. |
683 | 694 For fixed format code, use `fortran-mode'. |
695 | |
696 \\[f90-indent-line] indents the current line. | |
684 \\[f90-indent-new-line] indents current line and creates a new\ | 697 \\[f90-indent-new-line] indents current line and creates a new\ |
685 indented line. | 698 indented line. |
686 \\[f90-indent-line] indents the current line. | |
687 \\[f90-indent-subprogram] indents the current subprogram. | 699 \\[f90-indent-subprogram] indents the current subprogram. |
688 | 700 |
689 Type `? or `\\[help-command] to display a list of built-in\ | 701 Type `? or `\\[help-command] to display a list of built-in\ |
690 abbrevs for F90 keywords. | 702 abbrevs for F90 keywords. |
691 | 703 |
750 (set (make-local-variable 'comment-start-skip) "!+ *") | 762 (set (make-local-variable 'comment-start-skip) "!+ *") |
751 (set (make-local-variable 'comment-indent-function) 'f90-comment-indent) | 763 (set (make-local-variable 'comment-indent-function) 'f90-comment-indent) |
752 (set (make-local-variable 'abbrev-all-caps) t) | 764 (set (make-local-variable 'abbrev-all-caps) t) |
753 (set (make-local-variable 'normal-auto-fill-function) 'f90-do-auto-fill) | 765 (set (make-local-variable 'normal-auto-fill-function) 'f90-do-auto-fill) |
754 (setq indent-tabs-mode nil) ; auto buffer local | 766 (setq indent-tabs-mode nil) ; auto buffer local |
755 (easy-menu-add f90-menu) | |
756 ;; Setting up things for font-lock. | |
757 (set (make-local-variable 'font-lock-defaults) | 767 (set (make-local-variable 'font-lock-defaults) |
758 '((f90-font-lock-keywords f90-font-lock-keywords-1 | 768 '((f90-font-lock-keywords f90-font-lock-keywords-1 |
759 f90-font-lock-keywords-2 | 769 f90-font-lock-keywords-2 |
760 f90-font-lock-keywords-3 | 770 f90-font-lock-keywords-3 |
761 f90-font-lock-keywords-4) | 771 f90-font-lock-keywords-4) |
762 nil t)) | 772 nil t)) |
763 ;; Tell imenu how to handle f90. | 773 ;; Tell imenu how to handle f90. |
764 (set (make-local-variable 'imenu-case-fold-search) t) | 774 (set (make-local-variable 'imenu-case-fold-search) t) |
765 (set (make-local-variable 'imenu-generic-expression) | 775 (set (make-local-variable 'imenu-generic-expression) |
766 f90-imenu-generic-expression) | 776 f90-imenu-generic-expression) |
777 (set (make-local-variable 'beginning-of-defun-function) | |
778 'f90-beginning-of-subprogram) | |
779 (set (make-local-variable 'end-of-defun-function) 'f90-end-of-subprogram) | |
767 (set (make-local-variable 'add-log-current-defun-function) | 780 (set (make-local-variable 'add-log-current-defun-function) |
768 #'f90-current-defun) | 781 #'f90-current-defun) |
769 (run-hooks 'f90-mode-hook)) | 782 (run-hooks 'f90-mode-hook)) |
770 | 783 |
771 | 784 |
1280 (interactive "p") | 1293 (interactive "p") |
1281 (f90-next-block (- (or num 1)))) | 1294 (f90-next-block (- (or num 1)))) |
1282 | 1295 |
1283 | 1296 |
1284 (defun f90-mark-subprogram () | 1297 (defun f90-mark-subprogram () |
1285 "Put mark at end of F90 subprogram, point at beginning, push marks." | 1298 "Put mark at end of F90 subprogram, point at beginning, push mark." |
1286 (interactive) | 1299 (interactive) |
1287 (let ((pos (point)) program) | 1300 (let ((pos (point)) program) |
1288 (f90-end-of-subprogram) | 1301 (f90-end-of-subprogram) |
1289 (push-mark) | 1302 (push-mark) |
1290 (goto-char pos) | 1303 (goto-char pos) |
1316 | 1329 |
1317 (defun f90-indent-line (&optional no-update) | 1330 (defun f90-indent-line (&optional no-update) |
1318 "Indent current line as F90 code. | 1331 "Indent current line as F90 code. |
1319 Unless optional argument NO-UPDATE is non-nil, call `f90-update-line' | 1332 Unless optional argument NO-UPDATE is non-nil, call `f90-update-line' |
1320 after indenting." | 1333 after indenting." |
1321 (interactive) | 1334 (interactive "*P") |
1322 (let (indent no-line-number (pos (make-marker)) (case-fold-search t)) | 1335 (let (indent no-line-number (pos (make-marker)) (case-fold-search t)) |
1323 (set-marker pos (point)) | 1336 (set-marker pos (point)) |
1324 (beginning-of-line) ; digits after & \n are not line-nos | 1337 (beginning-of-line) ; digits after & \n are not line-nos |
1325 (if (save-excursion (and (f90-previous-statement) (f90-line-continued))) | 1338 (if (save-excursion (and (f90-previous-statement) (f90-line-continued))) |
1326 (progn (setq no-line-number t) (skip-chars-forward " \t")) | 1339 (progn (setq no-line-number t) (skip-chars-forward " \t")) |
1340 (f90-do-auto-fill) ; also updates line | 1353 (f90-do-auto-fill) ; also updates line |
1341 (if (not no-update) (f90-update-line))) | 1354 (if (not no-update) (f90-update-line))) |
1342 (set-marker pos nil))) | 1355 (set-marker pos nil))) |
1343 | 1356 |
1344 (defun f90-indent-new-line () | 1357 (defun f90-indent-new-line () |
1345 "Reindent current line, insert a newline and indent the newline. | 1358 "Re-indent current line, insert a newline and indent the newline. |
1346 An abbrev before point is expanded if the variable `abbrev-mode' is non-nil. | 1359 An abbrev before point is expanded if the variable `abbrev-mode' is non-nil. |
1347 If run in the middle of a line, the line is not broken." | 1360 If run in the middle of a line, the line is not broken." |
1348 (interactive) | 1361 (interactive "*") |
1349 (let (string cont (case-fold-search t)) | 1362 (let (string cont (case-fold-search t)) |
1350 (if abbrev-mode (expand-abbrev)) | 1363 (if abbrev-mode (expand-abbrev)) |
1351 (beginning-of-line) ; reindent where likely to be needed | 1364 (beginning-of-line) ; reindent where likely to be needed |
1352 (f90-indent-line-no) | 1365 (f90-indent-line-no) |
1353 (f90-indent-line 'no-update) | 1366 (f90-indent-line 'no-update) |
1471 (zmacs-deactivate-region) | 1484 (zmacs-deactivate-region) |
1472 (deactivate-mark)))) | 1485 (deactivate-mark)))) |
1473 | 1486 |
1474 (defun f90-indent-subprogram () | 1487 (defun f90-indent-subprogram () |
1475 "Properly indent the subprogram containing point." | 1488 "Properly indent the subprogram containing point." |
1476 (interactive) | 1489 (interactive "*") |
1477 (save-excursion | 1490 (save-excursion |
1478 (let ((program (f90-mark-subprogram))) | 1491 (let ((program (f90-mark-subprogram))) |
1479 (if program | 1492 (if program |
1480 (progn | 1493 (progn |
1481 (message "Indenting %s %s..." | 1494 (message "Indenting %s %s..." |
1489 | 1502 |
1490 (defun f90-break-line (&optional no-update) | 1503 (defun f90-break-line (&optional no-update) |
1491 "Break line at point, insert continuation marker(s) and indent. | 1504 "Break line at point, insert continuation marker(s) and indent. |
1492 Unless in a string or comment, or if the optional argument NO-UPDATE | 1505 Unless in a string or comment, or if the optional argument NO-UPDATE |
1493 is non-nil, call `f90-update-line' after inserting the continuation marker." | 1506 is non-nil, call `f90-update-line' after inserting the continuation marker." |
1494 (interactive) | 1507 (interactive "*P") |
1495 (cond ((f90-in-string) | 1508 (cond ((f90-in-string) |
1496 (insert "&\n&")) | 1509 (insert "&\n&")) |
1497 ((f90-in-comment) | 1510 ((f90-in-comment) |
1498 (insert "\n" (f90-get-present-comment-type))) | 1511 (insert "\n" (f90-get-present-comment-type))) |
1499 (t (insert "&") | 1512 (t (insert "&") |
1515 (forward-char))))) | 1528 (forward-char))))) |
1516 | 1529 |
1517 (defun f90-do-auto-fill () | 1530 (defun f90-do-auto-fill () |
1518 "Break line if non-white characters beyond `fill-column'. | 1531 "Break line if non-white characters beyond `fill-column'. |
1519 Update keyword case first." | 1532 Update keyword case first." |
1520 (interactive) | 1533 (interactive "*") |
1521 ;; Break line before or after last delimiter (non-word char) if | 1534 ;; Break line before or after last delimiter (non-word char) if |
1522 ;; position is beyond fill-column. | 1535 ;; position is beyond fill-column. |
1523 ;; Will not break **, //, or => (as specified by f90-no-break-re). | 1536 ;; Will not break **, //, or => (as specified by f90-no-break-re). |
1524 (f90-update-line) | 1537 (f90-update-line) |
1525 ;; Need this for `f90-electric-insert' and other f90- callers. | 1538 ;; Need this for `f90-electric-insert' and other f90- callers. |
1534 (goto-char pos-mark) | 1547 (goto-char pos-mark) |
1535 (set-marker pos-mark nil))))) | 1548 (set-marker pos-mark nil))))) |
1536 | 1549 |
1537 (defun f90-join-lines (&optional arg) | 1550 (defun f90-join-lines (&optional arg) |
1538 "Join current line to previous, fix whitespace, continuation, comments. | 1551 "Join current line to previous, fix whitespace, continuation, comments. |
1539 With an argument, join current line to following line. | 1552 With optional argument ARG, join current line to following line. |
1540 Like `join-line', but handles F90 syntax." | 1553 Like `join-line', but handles F90 syntax." |
1541 (interactive "*P") | 1554 (interactive "*P") |
1542 (beginning-of-line) | 1555 (beginning-of-line) |
1543 (if arg (forward-line 1)) | 1556 (if arg (forward-line 1)) |
1544 (when (eq (preceding-char) ?\n) | 1557 (when (eq (preceding-char) ?\n) |
1562 f90-smart-end f90-auto-keyword-case auto-fill-function) | 1575 f90-smart-end f90-auto-keyword-case auto-fill-function) |
1563 (set-marker end-region-mark end-region) | 1576 (set-marker end-region-mark end-region) |
1564 (goto-char beg-region) | 1577 (goto-char beg-region) |
1565 (while go-on | 1578 (while go-on |
1566 ;; Join as much as possible. | 1579 ;; Join as much as possible. |
1567 (while (progn | 1580 (while (progn |
1568 (end-of-line) | 1581 (end-of-line) |
1569 (skip-chars-backward " \t") | 1582 (skip-chars-backward " \t") |
1570 (eq (preceding-char) ?&)) | 1583 (eq (preceding-char) ?&)) |
1571 (f90-join-lines 'forward)) | 1584 (f90-join-lines 'forward)) |
1572 ;; Chop the line if necessary. | 1585 ;; Chop the line if necessary. |
1660 (beginning-of-line) | 1673 (beginning-of-line) |
1661 (f90-block-match beg-block beg-name end-block end-name)))))) | 1674 (f90-block-match beg-block beg-name end-block end-name)))))) |
1662 | 1675 |
1663 (defun f90-insert-end () | 1676 (defun f90-insert-end () |
1664 "Insert a complete end statement matching beginning of present block." | 1677 "Insert a complete end statement matching beginning of present block." |
1665 (interactive) | 1678 (interactive "*") |
1666 (let ((f90-smart-end (or f90-smart-end 'blink))) | 1679 (let ((f90-smart-end (or f90-smart-end 'blink))) |
1667 (insert "end") | 1680 (insert "end") |
1668 (f90-indent-new-line))) | 1681 (f90-indent-new-line))) |
1669 | 1682 |
1670 ;; Abbrevs and keywords. | 1683 ;; Abbrevs and keywords. |
1701 (edit-abbrevs-mode)) | 1714 (edit-abbrevs-mode)) |
1702 (get-buffer-create "*Abbrevs*")) | 1715 (get-buffer-create "*Abbrevs*")) |
1703 | 1716 |
1704 (defun f90-upcase-keywords () | 1717 (defun f90-upcase-keywords () |
1705 "Upcase all F90 keywords in the buffer." | 1718 "Upcase all F90 keywords in the buffer." |
1706 (interactive) | 1719 (interactive "*") |
1707 (f90-change-keywords 'upcase-word)) | 1720 (f90-change-keywords 'upcase-word)) |
1708 | 1721 |
1709 (defun f90-capitalize-keywords () | 1722 (defun f90-capitalize-keywords () |
1710 "Capitalize all F90 keywords in the buffer." | 1723 "Capitalize all F90 keywords in the buffer." |
1711 (interactive) | 1724 (interactive "*") |
1712 (f90-change-keywords 'capitalize-word)) | 1725 (f90-change-keywords 'capitalize-word)) |
1713 | 1726 |
1714 (defun f90-downcase-keywords () | 1727 (defun f90-downcase-keywords () |
1715 "Downcase all F90 keywords in the buffer." | 1728 "Downcase all F90 keywords in the buffer." |
1716 (interactive) | 1729 (interactive "*") |
1717 (f90-change-keywords 'downcase-word)) | 1730 (f90-change-keywords 'downcase-word)) |
1718 | 1731 |
1719 (defun f90-upcase-region-keywords (beg end) | 1732 (defun f90-upcase-region-keywords (beg end) |
1720 "Upcase all F90 keywords in the region." | 1733 "Upcase all F90 keywords in the region." |
1721 (interactive "*r") | 1734 (interactive "*r") |