aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorDave Love1998-01-30 17:49:37 +0000
committerDave Love1998-01-30 17:49:37 +0000
commit7977773d3fa03d439eb931013656f6114cb21ac4 (patch)
treef617d655ae059cb710135b8bc1f63014a57b0f2c /lisp
parent8d6179dc27330de09dff25ec54e21d57ac7db6e4 (diff)
downloademacs-7977773d3fa03d439eb931013656f6114cb21ac4.tar.gz
emacs-7977773d3fa03d439eb931013656f6114cb21ac4.zip
Various docstring and commentary fixes, including
note of current maintainer. (fortran-mode): Use imenu-syntax-alist. (fortran-imenu-generic-expression): Use fortran-continuation-string, not always `+'. (fortran-font-lock-keywords-1): Include symbol syntax as well as word, following syntax table changes. (fortran-imenu-generic-expression): Likewise. (fortran-mode-map): Add a menu. (fortran-mode-version, fortran-startup-message): Delete misleading variables. (fortran-mode): Don't use them. (fortran-column-ruler-fixed, fortran-column-ruler-tab): Fix leading \ which made `0' into null. (fortran-join-lines): New function and key binding. (fortran-narrow-to-subprogram): New function and key binding. (fortran-mode-syntax-table): Make ?., ?_, ?$ symbol, not word.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/fortran.el191
1 files changed, 128 insertions, 63 deletions
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index ae2c5ece903..58495fbf541 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -1,10 +1,9 @@
1;;; fortran.el --- Fortran mode for GNU Emacs 1;;; fortran.el --- Fortran mode for GNU Emacs
2 2
3;; Copyright (c) 1986, 1993, 1994, 1995, 1997 Free Software Foundation, Inc. 3;; Copyright (c) 1986, 1993, 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
4 4
5;; Author: Michael D. Prange <prange@erl.mit.edu> 5;; Author: Michael D. Prange <prange@erl.mit.edu>
6;; Maintainer: bug-fortran-mode@erl.mit.edu (Steve Gildea and others) 6;; Maintainer: Dave Love <fx@gnu.org>
7;; Version 1.30.6 (July 27, 1995)
8;; Keywords: languages 7;; Keywords: languages
9 8
10;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
@@ -26,30 +25,24 @@
26 25
27;;; Commentary: 26;;; Commentary:
28 27
29;; Fortran mode has been upgraded and is now maintained by Stephen A. Wood 28;; This mode is documented in the Emacs manual.
30;; (saw@cebaf.gov). It now will use either fixed format continuation line 29;;
31;; markers (character in 6th column), or tab format continuation line style 30;; Note that it is for editing Fortran77 or Fortran90 fixed source
32;; (digit after a TAB character.) A auto-fill mode has been added to 31;; form. For editing Fortran90 free format source, use `f90-mode'
33;; automatically wrap fortran lines that get too long. 32;; (f90.el).
33
34;;; History:
35
36;; Fortran mode was upgraded by Stephen A. Wood (saw@cebaf.gov).
34 37
35;; We acknowledge many contributions and valuable suggestions by 38;; We acknowledge many contributions and valuable suggestions by
36;; Lawrence R. Dodd, Ralf Fassel, Ralph Finch, Stephen Gildea, 39;; Lawrence R. Dodd, Ralf Fassel, Ralph Finch, Stephen Gildea,
37;; Dr. Anil Gokhale, Ulrich Mueller, Mark Neale, Eric Prestemon, 40;; Dr. Anil Gokhale, Ulrich Mueller, Mark Neale, Eric Prestemon,
38;; Gary Sabot and Richard Stallman. 41;; Gary Sabot and Richard Stallman.
39 42
40;; This file may be used with GNU Emacs version 18.xx if the following
41;; variable and function substitutions are made.
42;; Replace:
43;; frame-width with screen-width
44;; auto-fill-function with auto-fill-hook
45;; comment-indent-function with comment-indent-hook
46;; (setq unread-command-events (list c)) with (setq unread-command-char c)
47
48;; Bugs to bug-fortran-mode@erl.mit.edu
49
50;;; Code: 43;;; Code:
51 44
52(defconst fortran-mode-version "version 1.30.6") 45(require 'easymenu)
53 46
54(defgroup fortran nil 47(defgroup fortran nil
55 "Fortran mode for Emacs" 48 "Fortran mode for Emacs"
@@ -102,7 +95,8 @@ with a character in column 6."
102 :group 'fortran-indent) 95 :group 'fortran-indent)
103 96
104(defcustom fortran-comment-indent-style 'fixed 97(defcustom fortran-comment-indent-style 'fixed
105 "*nil forces comment lines not to be touched, 98 "*How to indent comments.
99nil forces comment lines not to be touched,
106'fixed makes fixed comment indentation to `fortran-comment-line-extra-indent' 100'fixed makes fixed comment indentation to `fortran-comment-line-extra-indent'
107columns beyond `fortran-minimum-statement-indent-fixed' (for 101columns beyond `fortran-minimum-statement-indent-fixed' (for
108`indent-tabs-mode' of nil) or `fortran-minimum-statement-indent-tab' (for 102`indent-tabs-mode' of nil) or `fortran-minimum-statement-indent-tab' (for
@@ -175,13 +169,13 @@ Normally $."
175 169
176(defcustom fortran-comment-region "c$$$" 170(defcustom fortran-comment-region "c$$$"
177 "*String inserted by \\[fortran-comment-region]\ 171 "*String inserted by \\[fortran-comment-region]\
178 at start of each line in region." 172at start of each line in region."
179 :type 'string 173 :type 'string
180 :group 'fortran-comment) 174 :group 'fortran-comment)
181 175
182(defcustom fortran-electric-line-number t 176(defcustom fortran-electric-line-number t
183 "*Non-nil causes line number digits to be moved to the correct column as\ 177 "*Non-nil causes line number digits to be moved to the correct column as\
184 typed." 178typed."
185 :type 'boolean 179 :type 'boolean
186 :group 'fortran) 180 :group 'fortran)
187 181
@@ -192,7 +186,7 @@ Normally $."
192 186
193(defvar fortran-column-ruler-fixed 187(defvar fortran-column-ruler-fixed
194 "0 4 6 10 20 30 40 5\ 188 "0 4 6 10 20 30 40 5\
195\0 60 70\n\ 1890 60 70\n\
196\[ ]|{ | | | | | | | | \ 190\[ ]|{ | | | | | | | | \
197\| | | | |}\n" 191\| | | | |}\n"
198 "*String displayed above current line by \\[fortran-column-ruler]. 192 "*String displayed above current line by \\[fortran-column-ruler].
@@ -200,7 +194,7 @@ This variable used in fixed format mode.")
200 194
201(defvar fortran-column-ruler-tab 195(defvar fortran-column-ruler-tab
202 "0 810 20 30 40 5\ 196 "0 810 20 30 40 5\
203\0 60 70\n\ 1970 60 70\n\
204\[ ]| { | | | | | | | | \ 198\[ ]| { | | | | | | | | \
205\| | | | |}\n" 199\| | | | |}\n"
206 "*String displayed above current line by \\[fortran-column-ruler]. 200 "*String displayed above current line by \\[fortran-column-ruler].
@@ -214,7 +208,7 @@ This variable used in TAB format mode.")
214 208
215(defvar fortran-analyze-depth 100 209(defvar fortran-analyze-depth 100
216 "Number of lines to scan to determine whether to use fixed or TAB format\ 210 "Number of lines to scan to determine whether to use fixed or TAB format\
217 style.") 211style.")
218 212
219(defcustom fortran-break-before-delimiters t 213(defcustom fortran-break-before-delimiters t
220 "*Non-nil causes `fortran-fill' to break lines before delimiters." 214 "*Non-nil causes `fortran-fill' to break lines before delimiters."
@@ -224,6 +218,8 @@ This variable used in TAB format mode.")
224(if fortran-mode-syntax-table 218(if fortran-mode-syntax-table
225 () 219 ()
226 (setq fortran-mode-syntax-table (make-syntax-table)) 220 (setq fortran-mode-syntax-table (make-syntax-table))
221 ;; We might like `;' to be punctuation (g77 multi-statement lines),
222 ;; but that screws abbrevs.
227 (modify-syntax-entry ?\; "w" fortran-mode-syntax-table) 223 (modify-syntax-entry ?\; "w" fortran-mode-syntax-table)
228 (modify-syntax-entry ?\r " " fortran-mode-syntax-table) 224 (modify-syntax-entry ?\r " " fortran-mode-syntax-table)
229 (modify-syntax-entry ?+ "." fortran-mode-syntax-table) 225 (modify-syntax-entry ?+ "." fortran-mode-syntax-table)
@@ -234,8 +230,11 @@ This variable used in TAB format mode.")
234 (modify-syntax-entry ?\' "\"" fortran-mode-syntax-table) 230 (modify-syntax-entry ?\' "\"" fortran-mode-syntax-table)
235 (modify-syntax-entry ?\" "\"" fortran-mode-syntax-table) 231 (modify-syntax-entry ?\" "\"" fortran-mode-syntax-table)
236 (modify-syntax-entry ?\\ "/" fortran-mode-syntax-table) 232 (modify-syntax-entry ?\\ "/" fortran-mode-syntax-table)
237 (modify-syntax-entry ?. "w" fortran-mode-syntax-table) 233 ;; This might be better as punctuation, as for C, but this way you
238 (modify-syntax-entry ?_ "w" fortran-mode-syntax-table) 234 ;; can treat floating-point numbers as symbols.
235 (modify-syntax-entry ?. "_" fortran-mode-syntax-table) ; e.g. `a.ne.b'
236 (modify-syntax-entry ?_ "_" fortran-mode-syntax-table)
237 (modify-syntax-entry ?$ "_" fortran-mode-syntax-table) ; esp. VMSisms
239 (modify-syntax-entry ?\! "<" fortran-mode-syntax-table) 238 (modify-syntax-entry ?\! "<" fortran-mode-syntax-table)
240 (modify-syntax-entry ?\n ">" fortran-mode-syntax-table)) 239 (modify-syntax-entry ?\n ">" fortran-mode-syntax-table))
241 240
@@ -372,20 +371,22 @@ This variable used in TAB format mode.")
372(defvar fortran-imenu-generic-expression 371(defvar fortran-imenu-generic-expression
373 ;; These patterns could be confused by sequence nos. in cols 72+ and 372 ;; These patterns could be confused by sequence nos. in cols 72+ and
374 ;; don't allow continuations everywhere. 373 ;; don't allow continuations everywhere.
375 '((nil 374 (list
376 ;; Lines below are: 1. leading whitespace; 2. function 375 (list
377 ;; declaration with optional type, e.g. `real', `real*4', 376 nil
378 ;; character(*), `double precision' and possible statement 377 ;; Lines below are: 1. leading whitespace; 2. function
379 ;; continuation; 3. untyped declarations; 4. the variable to 378 ;; declaration with optional type, e.g. `real', `real*4',
380 ;; index. [This will be fooled by `end function' allowed by G77. 379 ;; character(*), `double precision' and possible statement
381 ;; Also, it assumes sensible whitespace is employed.] 380 ;; continuation; 3. untyped declarations; 4. the variable to
382 "^\\s-+\\(\ 381 ;; index. [This will be fooled by `end function' allowed by G77.
382 ;; Also, it assumes sensible whitespace is employed.]
383 (concat "^\\s-+\\(\
383\\(\\sw\\|\\s-\\|[*()+]\\)*\\<function\\|\ 384\\(\\sw\\|\\s-\\|[*()+]\\)*\\<function\\|\
384subroutine\\|entry\\|block\\s-*data\\|program\\)[ \t+]+\ 385subroutine\\|entry\\|block\\s-*data\\|program\\)[ \t" fortran-continuation-string "]+\
385\\(\\sw+\\)" 386\\(\\sw+\\)")
386 3) 387 3)
387 ;; Un-named block data 388 ;; Un-named block data
388 (nil "^\\s-+\\(block\\s-*data\\)\\s-*$" 1)) 389 (list nil "^\\s-+\\(block\\s-*data\\)\\s-*$" 1))
389 "imenu generic expression for `imenu-default-create-index-function'.") 390 "imenu generic expression for `imenu-default-create-index-function'.")
390 391
391(defvar fortran-mode-map () 392(defvar fortran-mode-map ()
@@ -406,6 +407,7 @@ subroutine\\|entry\\|block\\s-*data\\|program\\)[ \t+]+\
406 (define-key fortran-mode-map "\C-c\C-r" 'fortran-column-ruler) 407 (define-key fortran-mode-map "\C-c\C-r" 'fortran-column-ruler)
407 (define-key fortran-mode-map "\C-c\C-p" 'fortran-previous-statement) 408 (define-key fortran-mode-map "\C-c\C-p" 'fortran-previous-statement)
408 (define-key fortran-mode-map "\C-c\C-n" 'fortran-next-statement) 409 (define-key fortran-mode-map "\C-c\C-n" 'fortran-next-statement)
410 (define-key fortran-mode-map "\C-c\C-d" 'fortran-join-line)
409 (define-key fortran-mode-map "\t" 'fortran-indent-line) 411 (define-key fortran-mode-map "\t" 'fortran-indent-line)
410 (define-key fortran-mode-map "0" 'fortran-electric-line-number) 412 (define-key fortran-mode-map "0" 'fortran-electric-line-number)
411 (define-key fortran-mode-map "1" 'fortran-electric-line-number) 413 (define-key fortran-mode-map "1" 'fortran-electric-line-number)
@@ -416,7 +418,48 @@ subroutine\\|entry\\|block\\s-*data\\|program\\)[ \t+]+\
416 (define-key fortran-mode-map "6" 'fortran-electric-line-number) 418 (define-key fortran-mode-map "6" 'fortran-electric-line-number)
417 (define-key fortran-mode-map "7" 'fortran-electric-line-number) 419 (define-key fortran-mode-map "7" 'fortran-electric-line-number)
418 (define-key fortran-mode-map "8" 'fortran-electric-line-number) 420 (define-key fortran-mode-map "8" 'fortran-electric-line-number)
419 (define-key fortran-mode-map "9" 'fortran-electric-line-number)) 421 (define-key fortran-mode-map "9" 'fortran-electric-line-number)
422
423 ;; Menu
424 (unless (boundp 'fortran-mode-menu)
425 (easy-menu-define
426 fortran-mode-menu fortran-mode-map ""
427 '("Fortran"
428 ["Toggle Auto-fill" fortran-auto-fill-mode :style toggle
429 :selected (eq auto-fill-function 'fortran-do-auto-fill)]
430 ["Toggle abbrev-mode" abbrev-mode :style toggle :selected abbrev-mode]
431 "----"
432 ["Comment-out Region" fortran-comment-region mark-active]
433 ["Uncomment-out region"
434 (fortran-comment-region (region-beginning) (region-end) 1)
435 mark-active]
436 ["Indent Region" indent-region mark-active]
437 ["Indent Subprogram" fortran-indent-subprogram t]
438 "----"
439 ["Beginning of Subprogram" beginning-of-fortran-subprogram t]
440 ["End of Subprogram" end-of-fortran-subprogram t]
441 ("Mark"
442 ["Subprogram" mark-fortran-subprogram t]
443 ["IF Block" fortran-mark-if t]
444 ["DO Block" fortran-mark-do t])
445 ["Narrow to Subprogram" fortran-narrow-to-subprogram t]
446 ["Widen" widen t]
447 "----"
448 ["Temporary column ruler" fortran-column-ruler t]
449 ["72-column window" fortran-window-create t]
450 ["Full Width Window"
451 (enlarge-window-horizontally (- (frame-width) (window-width)))
452 (< (window-width) (frame-width))]
453 ["Momentary 72-column window" fortran-window-create-momentarily t]
454 "----"
455 ["Break Line at Point" fortran-split-line t]
456 ["Join Continuation Line" fortran-join-line t]
457 "----"
458 ["Add imenu menu"
459 (progn (imenu-add-to-menubar "Index")
460 ;; Prod menu bar to update -- is this the right way?
461 (menu-bar-mode 1))
462 t]))))
420 463
421(defvar fortran-mode-abbrev-table nil) 464(defvar fortran-mode-abbrev-table nil)
422(if fortran-mode-abbrev-table 465(if fortran-mode-abbrev-table
@@ -483,6 +526,8 @@ subroutine\\|entry\\|block\\s-*data\\|program\\)[ \t+]+\
483 (define-abbrev fortran-mode-abbrev-table ";wh" "where" nil) 526 (define-abbrev fortran-mode-abbrev-table ";wh" "where" nil)
484 (setq abbrevs-changed ac))) 527 (setq abbrevs-changed ac)))
485 528
529(eval-when-compile (defvar imenu-syntax-alist nil)) ; silence compiler
530
486;;;###autoload 531;;;###autoload
487(defun fortran-mode () 532(defun fortran-mode ()
488 "Major mode for editing Fortran code. 533 "Major mode for editing Fortran code.
@@ -550,17 +595,11 @@ Variables controlling indentation style and extra features:
550 fortran-break-before-delimiters 595 fortran-break-before-delimiters
551 Non-nil causes `fortran-fill' breaks lines before delimiters. 596 Non-nil causes `fortran-fill' breaks lines before delimiters.
552 (default t) 597 (default t)
553 fortran-startup-message
554 Set to nil to inhibit message first time Fortran mode is used.
555 598
556Turning on Fortran mode calls the value of the variable `fortran-mode-hook' 599Turning on Fortran mode calls the value of the variable `fortran-mode-hook'
557with no args, if that value is non-nil." 600with no args, if that value is non-nil."
558 (interactive) 601 (interactive)
559 (kill-all-local-variables) 602 (kill-all-local-variables)
560 (if fortran-startup-message
561 (message "Emacs Fortran mode %s. Bugs to %s"
562 fortran-mode-version bug-fortran-mode))
563 (setq fortran-startup-message nil)
564 (setq local-abbrev-table fortran-mode-abbrev-table) 603 (setq local-abbrev-table fortran-mode-abbrev-table)
565 (set-syntax-table fortran-mode-syntax-table) 604 (set-syntax-table fortran-mode-syntax-table)
566 ;; Font Lock mode support. 605 ;; Font Lock mode support.
@@ -569,7 +608,7 @@ with no args, if that value is non-nil."
569 fortran-font-lock-keywords-1 608 fortran-font-lock-keywords-1
570 fortran-font-lock-keywords-2 609 fortran-font-lock-keywords-2
571 fortran-font-lock-keywords-3) 610 fortran-font-lock-keywords-3)
572 t t ((?/ . "$/")))) 611 t t ((?/ . "$/") ("_$" . "w"))))
573 (make-local-variable 'fortran-break-before-delimiters) 612 (make-local-variable 'fortran-break-before-delimiters)
574 (setq fortran-break-before-delimiters t) 613 (setq fortran-break-before-delimiters t)
575 (make-local-variable 'indent-line-function) 614 (make-local-variable 'indent-line-function)
@@ -605,8 +644,10 @@ with no args, if that value is non-nil."
605 (make-local-variable 'fortran-tab-mode-string) 644 (make-local-variable 'fortran-tab-mode-string)
606 (setq fortran-tab-mode-string " TAB-format") 645 (setq fortran-tab-mode-string " TAB-format")
607 (setq indent-tabs-mode (fortran-analyze-file-format)) 646 (setq indent-tabs-mode (fortran-analyze-file-format))
647 (setq imenu-case-fold-search t)
608 (make-local-variable 'imenu-generic-expression) 648 (make-local-variable 'imenu-generic-expression)
609 (setq imenu-generic-expression fortran-imenu-generic-expression) 649 (setq imenu-generic-expression fortran-imenu-generic-expression)
650 (setq imenu-syntax-alist '(("_$" . "w")))
610 (run-hooks 'fortran-mode-hook)) 651 (run-hooks 'fortran-mode-hook))
611 652
612(defun fortran-comment-hook () 653(defun fortran-comment-hook ()
@@ -619,7 +660,7 @@ with no args, if that value is non-nil."
619 "Align or create comment on current line. 660 "Align or create comment on current line.
620Existing comments of all types are recognized and aligned. 661Existing comments of all types are recognized and aligned.
621If the line has no comment, a side-by-side comment is inserted and aligned 662If the line has no comment, a side-by-side comment is inserted and aligned
622if the value of comment-start is not nil. 663if the value of `comment-start' is not nil.
623Otherwise, a separate-line comment is inserted, on this line 664Otherwise, a separate-line comment is inserted, on this line
624or on a new line inserted before this line if this line is not blank." 665or on a new line inserted before this line if this line is not blank."
625 (interactive) 666 (interactive)
@@ -658,7 +699,7 @@ or on a new line inserted before this line if this line is not blank."
658 699
659(defun fortran-comment-region (beg-region end-region arg) 700(defun fortran-comment-region (beg-region end-region arg)
660 "Comments every line in the region. 701 "Comments every line in the region.
661Puts fortran-comment-region at the beginning of every line in the region. 702Puts `fortran-comment-region' at the beginning of every line in the region.
662BEG-REGION and END-REGION are args which specify the region boundaries. 703BEG-REGION and END-REGION are args which specify the region boundaries.
663With non-nil ARG, uncomments the region." 704With non-nil ARG, uncomments the region."
664 (interactive "*r\nP") 705 (interactive "*r\nP")
@@ -711,7 +752,7 @@ Any other key combination is executed normally."
711 (get-buffer-create "*Abbrevs*")) 752 (get-buffer-create "*Abbrevs*"))
712 753
713(defun fortran-column-ruler () 754(defun fortran-column-ruler ()
714 "Inserts a column ruler momentarily above current line, till next keystroke. 755 "Insert a column ruler momentarily above current line, till next keystroke.
715The ruler is defined by the value of `fortran-column-ruler-fixed' when in fixed 756The ruler is defined by the value of `fortran-column-ruler-fixed' when in fixed
716format mode, and `fortran-column-ruler-tab' when in TAB format mode. 757format mode, and `fortran-column-ruler-tab' when in TAB format mode.
717The key typed is executed unless it is SPC." 758The key typed is executed unless it is SPC."
@@ -729,7 +770,7 @@ The key typed is executed unless it is SPC."
729 nil "Type SPC or any command to erase ruler.")) 770 nil "Type SPC or any command to erase ruler."))
730 771
731(defun fortran-window-create () 772(defun fortran-window-create ()
732 "Makes the window 72 columns wide. 773 "Make the window 72 columns wide.
733See also `fortran-window-create-momentarily'." 774See also `fortran-window-create-momentarily'."
734 (interactive) 775 (interactive)
735 (condition-case error 776 (condition-case error
@@ -746,7 +787,7 @@ See also `fortran-window-create-momentarily'."
746 'error))) 787 'error)))
747 788
748(defun fortran-window-create-momentarily (&optional arg) 789(defun fortran-window-create-momentarily (&optional arg)
749 "Momentarily makes the window 72 columns wide. 790 "Momentarily make the window 72 columns wide.
750Optional ARG non-nil and non-unity disables the momentary feature. 791Optional ARG non-nil and non-unity disables the momentary feature.
751See also `fortran-window-create'." 792See also `fortran-window-create'."
752 (interactive "p") 793 (interactive "p")
@@ -773,6 +814,22 @@ See also `fortran-window-create'."
773 (insert "\n " fortran-continuation-string)));Space after \n important 814 (insert "\n " fortran-continuation-string)));Space after \n important
774 (fortran-indent-line)) ;when the cont string is C, c or *. 815 (fortran-indent-line)) ;when the cont string is C, c or *.
775 816
817(defun fortran-join-line ()
818 "Join a continuation line to the previous one and re-indent."
819 (interactive)
820 (save-excursion
821 (beginning-of-line)
822 (cond ((looking-at " \\S-")
823 (delete-region (1- (point)) (+ (point) 7)))
824 ((looking-at "&")
825 (delete-region (1- (point)) (1+ (point))))
826 ((looking-at " *\t[1-9]")
827 (apply 'delete-region (match-data))
828 (delete-backward-char 1))
829 (t (error "This isn't a continuation line")))
830 (just-one-space)
831 (fortran-indent-line)))
832
776(defun fortran-numerical-continuation-char () 833(defun fortran-numerical-continuation-char ()
777 "Return a digit for tab-digit style of continuation lines. 834 "Return a digit for tab-digit style of continuation lines.
778If, previous line is a tab-digit continuation line, returns that digit 835If, previous line is a tab-digit continuation line, returns that digit
@@ -793,7 +850,7 @@ except that ] is never special and \ quotes ^, - or \."
793 850
794(defun fortran-electric-line-number (arg) 851(defun fortran-electric-line-number (arg)
795 "Self insert, but if part of a Fortran line number indent it automatically. 852 "Self insert, but if part of a Fortran line number indent it automatically.
796Auto-indent does not happen if a numeric arg is used." 853Auto-indent does not happen if a numeric ARG is used."
797 (interactive "P") 854 (interactive "P")
798 (if (or arg (not fortran-electric-line-number)) 855 (if (or arg (not fortran-electric-line-number))
799 (if arg 856 (if arg
@@ -896,6 +953,15 @@ non-comment Fortran statement in the file, and nil otherwise."
896 (looking-at (concat "[ \t]*" comment-start-skip))))) 953 (looking-at (concat "[ \t]*" comment-start-skip)))))
897 (if (not not-last-statement) 954 (if (not not-last-statement)
898 'last-statement))) 955 'last-statement)))
956
957(defun fortran-narrow-to-subprogram ()
958 "Make text outside the current subprogram invisible.
959The subprogram visible is the one that contains or follows point."
960 (interactive)
961 (save-excursion
962 (mark-fortran-subprogram)
963 (narrow-to-region (region-beginning)
964 (region-end))))
899 965
900(defun fortran-blink-matching-if () 966(defun fortran-blink-matching-if ()
901 ;; From a Fortran ENDIF statement, blink the matching IF statement. 967 ;; From a Fortran ENDIF statement, blink the matching IF statement.
@@ -1125,7 +1191,7 @@ The marks are pushed."
1125 (point)))))) 1191 (point))))))
1126 1192
1127(defun fortran-indent-line () 1193(defun fortran-indent-line ()
1128 "Indents current Fortran line based on its contents and on previous lines." 1194 "Indent current Fortran line based on its contents and on previous lines."
1129 (interactive) 1195 (interactive)
1130 (let ((cfi (calculate-fortran-indent))) 1196 (let ((cfi (calculate-fortran-indent)))
1131 (save-excursion 1197 (save-excursion
@@ -1147,7 +1213,7 @@ The marks are pushed."
1147 (end-of-line) 1213 (end-of-line)
1148 (fortran-fill))) 1214 (fortran-fill)))
1149 (if fortran-blink-matching-if 1215 (if fortran-blink-matching-if
1150 (progn 1216 (progn
1151 (fortran-blink-matching-if) 1217 (fortran-blink-matching-if)
1152 (fortran-blink-matching-do))))) 1218 (fortran-blink-matching-do)))))
1153 1219
@@ -1168,7 +1234,7 @@ An abbrev before point is expanded if `abbrev-mode' is non-nil."
1168 (fortran-indent-line)) 1234 (fortran-indent-line))
1169 1235
1170(defun fortran-indent-subprogram () 1236(defun fortran-indent-subprogram ()
1171 "Properly indents the Fortran subprogram which contains point." 1237 "Properly indent the Fortran subprogram which contains point."
1172 (interactive) 1238 (interactive)
1173 (save-excursion 1239 (save-excursion
1174 (mark-fortran-subprogram) 1240 (mark-fortran-subprogram)
@@ -1305,7 +1371,7 @@ non-indentation text within the comment."
1305 (current-column))) 1371 (current-column)))
1306 1372
1307(defun fortran-indent-to-column (col) 1373(defun fortran-indent-to-column (col)
1308 "Indents current line with spaces to column COL. 1374 "Indent current line with spaces to column COL.
1309notes: 1) A non-zero/non-blank character in column 5 indicates a continuation 1375notes: 1) A non-zero/non-blank character in column 5 indicates a continuation
1310 line, and this continuation character is retained on indentation; 1376 line, and this continuation character is retained on indentation;
1311 2) If `fortran-continuation-string' is the first non-whitespace 1377 2) If `fortran-continuation-string' is the first non-whitespace
@@ -1380,8 +1446,8 @@ Do not call if there is no line number."
1380 (= (current-column) 5)))))) 1446 (= (current-column) 5))))))
1381 1447
1382(defun fortran-check-for-matching-do () 1448(defun fortran-check-for-matching-do ()
1383 "When called from a numbered statement, returns t if matching DO is found. 1449 "When called from a numbered statement, return t if matching DO is found.
1384Otherwise return a nil." 1450Otherwise return nil."
1385 (let (charnum 1451 (let (charnum
1386 (case-fold-search t)) 1452 (case-fold-search t))
1387 (save-excursion 1453 (save-excursion
@@ -1448,8 +1514,7 @@ Return t if `comment-start-skip' found, nil if not."
1448;;;From: ralf@up3aud1.gwdg.de (Ralf Fassel) 1514;;;From: ralf@up3aud1.gwdg.de (Ralf Fassel)
1449;;; Test if TAB format continuation lines work. 1515;;; Test if TAB format continuation lines work.
1450(defun fortran-is-in-string-p (where) 1516(defun fortran-is-in-string-p (where)
1451 "Return non-nil if POS (a buffer position) is inside a Fortran string, 1517 "Return non-nil iff WHERE (a buffer position) is inside a Fortran string."
1452nil else."
1453 (save-excursion 1518 (save-excursion
1454 (goto-char where) 1519 (goto-char where)
1455 (cond 1520 (cond
@@ -1636,7 +1701,7 @@ automatically breaks the line at a previous space."
1636 (insert comment-string))))) 1701 (insert comment-string)))))
1637 1702
1638(defun fortran-analyze-file-format () 1703(defun fortran-analyze-file-format ()
1639 "Returns nil if fixed format is used, t if TAB formatting is used. 1704 "Return nil if fixed format is used, t if TAB formatting is used.
1640Use `fortran-tab-mode-default' if no non-comment statements are found in the 1705Use `fortran-tab-mode-default' if no non-comment statements are found in the
1641file before the end or the first `fortran-analyze-depth' lines." 1706file before the end or the first `fortran-analyze-depth' lines."
1642 (let ((i 0)) 1707 (let ((i 0))