Mercurial > emacs
comparison lisp/progmodes/fortran.el @ 23711:7beb8675e914
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.
author | Dave Love <fx@gnu.org> |
---|---|
date | Sun, 15 Nov 1998 15:50:30 +0000 |
parents | 17ebfb12712f |
children | 11303d1d8120 |
comparison
equal
deleted
inserted
replaced
23710:8e78218db0c5 | 23711:7beb8675e914 |
---|---|
906 (skip-chars-backward " \t") | 906 (skip-chars-backward " \t") |
907 (insert last-command-char) | 907 (insert last-command-char) |
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 () |
930 "Moves point to the end of the current Fortran subprogram." | 943 "Moves point to the end of the current Fortran subprogram." |
931 (interactive) | 944 (interactive) |
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 |
942 (defun mark-fortran-subprogram () | 959 (defun mark-fortran-subprogram () |
943 "Put mark at end of Fortran subprogram, point at beginning. | 960 "Put mark at end of Fortran subprogram, point at beginning. |