diff options
| author | Glenn Morris | 2005-03-29 18:34:22 +0000 |
|---|---|---|
| committer | Glenn Morris | 2005-03-29 18:34:22 +0000 |
| commit | fcca5273e598fdf7813dd3adc077bd8c4cc05df5 (patch) | |
| tree | fb0d8afc47fd2875a4a936857b42303d2666c08d | |
| parent | 0d6d7be5977900c67a66b74746f0a0485cafd275 (diff) | |
| download | emacs-fcca5273e598fdf7813dd3adc077bd8c4cc05df5.tar.gz emacs-fcca5273e598fdf7813dd3adc077bd8c4cc05df5.zip | |
(f90-end-block-re, f90-start-block-re): Doc fix. Tweak regexp.
(f90-beginning-of-block): Push mark first.
| -rw-r--r-- | lisp/progmodes/f90.el | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index fdb7fffac6c..4c8b847b7cd 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el | |||
| @@ -597,41 +597,32 @@ characters long.") | |||
| 597 | 597 | ||
| 598 | ;; Hideshow support. | 598 | ;; Hideshow support. |
| 599 | (defconst f90-end-block-re | 599 | (defconst f90-end-block-re |
| 600 | (concat "^[ \t0-9]*\\<end\\>[ \t]*" | 600 | (concat "^[ \t0-9]*\\<end[ \t]*" |
| 601 | (regexp-opt '("do" "if" "forall" "function" "interface" | 601 | (regexp-opt '("do" "if" "forall" "function" "interface" |
| 602 | "module" "program" "select" "subroutine" | 602 | "module" "program" "select" "subroutine" |
| 603 | "type" "where" ) t) | 603 | "type" "where" ) t) |
| 604 | "[ \t]*\\sw*") | 604 | "[ \t]*\\sw*") |
| 605 | "Regexp matching the end of a \"block\" of F90 code. | 605 | "Regexp matching the end of an F90 \"block\", from the line start. |
| 606 | Used in the F90 entry in `hs-special-modes-alist'.") | 606 | Used in the F90 entry in `hs-special-modes-alist'.") |
| 607 | 607 | ||
| 608 | ;; Ignore the fact that FUNCTION, SUBROUTINE, WHERE, FORALL have a | 608 | ;; Ignore the fact that FUNCTION, SUBROUTINE, WHERE, FORALL have a |
| 609 | ;; following "(". DO, CASE, IF can have labels; IF must be | 609 | ;; following "(". DO, CASE, IF can have labels. |
| 610 | ;; accompanied by THEN. | ||
| 611 | ;; A big problem is that many of these statements can be broken over | ||
| 612 | ;; lines, even with embedded comments. We only try to handle this for | ||
| 613 | ;; IF ... THEN statements, assuming and hoping it will be less common | ||
| 614 | ;; for other constructs. We match up to one new-line, provided ") | ||
| 615 | ;; THEN" appears on one line. Matching on just ") THEN" is no good, | ||
| 616 | ;; since that includes ELSE branches. | ||
| 617 | ;; For a fully accurate solution, hideshow would probably have to be | ||
| 618 | ;; modified to allow functions as well as regexps to be used to | ||
| 619 | ;; specify block start and end positions. | ||
| 620 | (defconst f90-start-block-re | 610 | (defconst f90-start-block-re |
| 621 | (concat | 611 | (concat |
| 622 | "^[ \t0-9]*" ; statement number | 612 | "^[ \t0-9]*" ; statement number |
| 623 | "\\(\\(" | 613 | "\\(\\(" |
| 624 | "\\(\\sw+[ \t]*:[ \t]*\\)?" ; structure label | 614 | "\\(\\sw+[ \t]*:[ \t]*\\)?" ; structure label |
| 625 | "\\(do\\|select[ \t]*case\\|if[ \t]*(.*\n?.*)[ \t]*then\\|" | 615 | "\\(do\\|select[ \t]*case\\|" |
| 616 | ;; See comments in fortran-start-block-re for the problems of IF. | ||
| 617 | "if[ \t]*(\\(.*\\|" | ||
| 618 | ".*\n\\([^if]*\\([^i].\\|.[^f]\\|.\\>\\)\\)\\)\\<then\\|" | ||
| 626 | ;; Distinguish WHERE block from isolated WHERE. | 619 | ;; Distinguish WHERE block from isolated WHERE. |
| 627 | "\\(where\\|forall\\)[ \t]*(.*)[ \t]*\\(!\\|$\\)\\)\\)" | 620 | "\\(where\\|forall\\)[ \t]*(.*)[ \t]*\\(!\\|$\\)\\)\\)" |
| 628 | "\\|" | 621 | "\\|" |
| 629 | "program\\|interface\\|module\\|type\\|function\\|subroutine" | 622 | "program\\|interface\\|module\\|type\\|function\\|subroutine" |
| 630 | ;; ") THEN" at line end. Problem - also does ELSE. | ||
| 631 | ;;; "\\|.*)[ \t]*then[ \t]*\\($\\|!\\)" | ||
| 632 | "\\)" | 623 | "\\)" |
| 633 | "[ \t]*") | 624 | "[ \t]*") |
| 634 | "Regexp matching the start of a \"block\" of F90 code. | 625 | "Regexp matching the start of an F90 \"block\", from the line start. |
| 635 | A simple regexp cannot do this in fully correct fashion, so this | 626 | A simple regexp cannot do this in fully correct fashion, so this |
| 636 | tries to strike a compromise between complexity and flexibility. | 627 | tries to strike a compromise between complexity and flexibility. |
| 637 | Used in the F90 entry in `hs-special-modes-alist'.") | 628 | Used in the F90 entry in `hs-special-modes-alist'.") |
| @@ -1305,12 +1296,12 @@ Checks for consistency of block types and labels (if present). | |||
| 1305 | Does not check the outermost block, because it may be incomplete. | 1296 | Does not check the outermost block, because it may be incomplete. |
| 1306 | Interactively, pushes mark before moving point." | 1297 | Interactively, pushes mark before moving point." |
| 1307 | (interactive "p") | 1298 | (interactive "p") |
| 1299 | (if (interactive-p) (push-mark (point) t)) | ||
| 1308 | (and num (< num 0) (f90-end-of-block (- num))) | 1300 | (and num (< num 0) (f90-end-of-block (- num))) |
| 1309 | (let ((case-fold-search t) | 1301 | (let ((case-fold-search t) |
| 1310 | (count (or num 1)) | 1302 | (count (or num 1)) |
| 1311 | end-list end-this end-type end-label | 1303 | end-list end-this end-type end-label |
| 1312 | start-this start-type start-label) | 1304 | start-this start-type start-label) |
| 1313 | (if (interactive-p) (push-mark (point) t)) | ||
| 1314 | (beginning-of-line) ; probably want this | 1305 | (beginning-of-line) ; probably want this |
| 1315 | (while (and (> count 0) (re-search-backward f90-blocks-re nil 'move)) | 1306 | (while (and (> count 0) (re-search-backward f90-blocks-re nil 'move)) |
| 1316 | (beginning-of-line) | 1307 | (beginning-of-line) |