diff options
| author | Dave Love | 1998-11-15 15:50:30 +0000 |
|---|---|---|
| committer | Dave Love | 1998-11-15 15:50:30 +0000 |
| commit | 823ab5da19928a86f6747ad2f3d47bc5a92e46bd (patch) | |
| tree | d4d11b348840a760ed99263e567a048716fc15ca | |
| parent | 3ec46dba9af68c9f2b2ffcf8e7419598dc6ce047 (diff) | |
| download | emacs-823ab5da19928a86f6747ad2f3d47bc5a92e46bd.tar.gz emacs-823ab5da19928a86f6747ad2f3d47bc5a92e46bd.zip | |
Fix previous change:
(fortran-end-prog-re1): Changed.
(fortran-check-end-prog-re): New function.
(beginning-of-fortran-subprogram, end-of-fortran-subprogram): Use
it.
| -rw-r--r-- | lisp/progmodes/fortran.el | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index af5f6db9097..e8083455953 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el | |||
| @@ -908,22 +908,35 @@ Auto-indent does not happen if a numeric ARG is used." | |||
| 908 | (fortran-indent-line)))) | 908 | (fortran-indent-line)))) |
| 909 | 909 | ||
| 910 | (defvar fortran-end-prog-re1 | 910 | (defvar fortran-end-prog-re1 |
| 911 | ;; `end' followed by optional block type name and then optional | ||
| 912 | ;; symbol, then eol. In the absence of the block type name, the | ||
| 913 | ;; trailing symbol would presumably be a sequence number in cols 72+. | ||
| 914 | "end\ | 911 | "end\ |
| 915 | \\([ \t]+\\(program\\|subroutine\\|function\\|block[ \t]*data\\)\\>\\)?\ | 912 | \\([ \t]*\\(program\\|subroutine\\|function\\|block[ \t]*data\\)\\>\ |
| 916 | [ \t]*\\(\\(\\sw\\|\\s_\\)+[ \t]*\\)?\ | 913 | \\([ \t]*\\(\\sw\\|\\s_\\)+\\)?\\)?") |
| 917 | $") | 914 | |
| 918 | (defvar fortran-end-prog-re | 915 | (defvar fortran-end-prog-re |
| 916 | "Regexp possibly marking subprogram end." | ||
| 919 | (concat "^[ \t0-9]*" fortran-end-prog-re1)) | 917 | (concat "^[ \t0-9]*" fortran-end-prog-re1)) |
| 920 | 918 | ||
| 919 | (defun fortran-check-end-prog-re () | ||
| 920 | "Check a preliminary match against `fortran-end-prog-re'." | ||
| 921 | ;; Having got a possible match for the subprogram end, we need a | ||
| 922 | ;; match of whitespace, avoiding possible column 73+ stuff. | ||
| 923 | (save-match-data | ||
| 924 | (string-match "^\\s-*\\'" | ||
| 925 | (buffer-substring (match-end 0) | ||
| 926 | (min (line-end-position) | ||
| 927 | (+ 72 (line-beginning-position))))))) | ||
| 928 | |||
| 929 | ;; Note that you can't just check backwards for `subroutine' &c in | ||
| 930 | ;; case of un-marked main programs not at the start of the file. | ||
| 921 | (defun beginning-of-fortran-subprogram () | 931 | (defun beginning-of-fortran-subprogram () |
| 922 | "Moves point to the beginning of the current Fortran subprogram." | 932 | "Moves point to the beginning of the current Fortran subprogram." |
| 923 | (interactive) | 933 | (interactive) |
| 924 | (let ((case-fold-search t)) | 934 | (let ((case-fold-search t)) |
| 925 | (beginning-of-line -1) | 935 | (beginning-of-line -1) |
| 926 | (if (re-search-backward fortran-end-prog-re nil 'move) | 936 | (if (catch 'ok |
| 937 | (while (re-search-backward fortran-end-prog-re nil 'move) | ||
| 938 | (if (fortran-check-end-prog-re) | ||
| 939 | (throw 'ok t)))) | ||
| 927 | (forward-line)))) | 940 | (forward-line)))) |
| 928 | 941 | ||
| 929 | (defun end-of-fortran-subprogram () | 942 | (defun end-of-fortran-subprogram () |
| @@ -932,10 +945,14 @@ $") | |||
| 932 | (let ((case-fold-search t)) | 945 | (let ((case-fold-search t)) |
| 933 | (if (save-excursion ; on END | 946 | (if (save-excursion ; on END |
| 934 | (beginning-of-line) | 947 | (beginning-of-line) |
| 935 | (looking-at fortran-end-prog-re)) | 948 | (and (looking-at fortran-end-prog-re) |
| 949 | (fortran-check-end-prog-re))) | ||
| 936 | (forward-line) | 950 | (forward-line) |
| 937 | (beginning-of-line 2) | 951 | (beginning-of-line 2) |
| 938 | (re-search-forward fortran-end-prog-re nil 'move) | 952 | (catch 'ok |
| 953 | (while (re-search-forward fortran-end-prog-re nil 'move) | ||
| 954 | (if (fortran-check-end-prog-re) | ||
| 955 | (throw 'ok t)))) | ||
| 939 | (goto-char (match-beginning 0)) | 956 | (goto-char (match-beginning 0)) |
| 940 | (forward-line)))) | 957 | (forward-line)))) |
| 941 | 958 | ||