diff options
| author | Glenn Morris | 2002-04-28 22:28:38 +0000 |
|---|---|---|
| committer | Glenn Morris | 2002-04-28 22:28:38 +0000 |
| commit | 5c2a80ad5c8133b8712d3b606bd7987945b99f63 (patch) | |
| tree | 8b3ba172746949cb1b8bc365fb1791332216577b /lisp | |
| parent | 82b4fc4ab4cea651f8341db488fffa1bb180ef8a (diff) | |
| download | emacs-5c2a80ad5c8133b8712d3b606bd7987945b99f63.tar.gz emacs-5c2a80ad5c8133b8712d3b606bd7987945b99f63.zip | |
Minor reorganization of some code.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/f90.el | 213 |
1 files changed, 104 insertions, 109 deletions
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 873520c7544..c21d7bcd356 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el | |||
| @@ -664,12 +664,12 @@ program\\|select\\|subroutine\\|type\\|where\\|forall\\)\\>") | |||
| 664 | (defun f90-add-imenu-menu () | 664 | (defun f90-add-imenu-menu () |
| 665 | "Add an imenu menu to the menubar." | 665 | "Add an imenu menu to the menubar." |
| 666 | (interactive) | 666 | (interactive) |
| 667 | (if (not f90-imenu) | 667 | (if f90-imenu |
| 668 | (progn | 668 | (message "%s" "F90-imenu already exists.") |
| 669 | (imenu-add-to-menubar "F90-imenu") | 669 | (imenu-add-to-menubar "F90-imenu") |
| 670 | (redraw-frame (selected-frame)) | 670 | (redraw-frame (selected-frame)) |
| 671 | (setq f90-imenu t)) | 671 | (setq f90-imenu t))) |
| 672 | (message "%s" "F90-imenu already exists."))) | 672 | |
| 673 | (put 'f90-add-imenu-menu 'menu-enable '(not f90-imenu)) | 673 | (put 'f90-add-imenu-menu 'menu-enable '(not f90-imenu)) |
| 674 | 674 | ||
| 675 | 675 | ||
| @@ -899,13 +899,12 @@ If optional argument NO-LINE-NUMBER is nil, jump over a possible line-number." | |||
| 899 | (defsubst f90-get-present-comment-type () | 899 | (defsubst f90-get-present-comment-type () |
| 900 | (save-excursion | 900 | (save-excursion |
| 901 | (let ((type nil) (eol (line-end-position))) | 901 | (let ((type nil) (eol (line-end-position))) |
| 902 | (if (f90-in-comment) | 902 | (when (f90-in-comment) |
| 903 | (progn | 903 | (beginning-of-line) |
| 904 | (beginning-of-line) | 904 | (re-search-forward "[!]+" eol) |
| 905 | (re-search-forward "[!]+" eol) | 905 | (while (f90-in-string) |
| 906 | (while (f90-in-string) | 906 | (re-search-forward "[!]+" eol)) |
| 907 | (re-search-forward "[!]+" eol)) | 907 | (setq type (match-string 0))) |
| 908 | (setq type (match-string 0)))) | ||
| 909 | type))) | 908 | type))) |
| 910 | 909 | ||
| 911 | (defsubst f90-equal-symbols (a b) | 910 | (defsubst f90-equal-symbols (a b) |
| @@ -942,21 +941,19 @@ Name is nil if the statement has no label." | |||
| 942 | Name is nil if the statement has no label." | 941 | Name is nil if the statement has no label." |
| 943 | (save-excursion | 942 | (save-excursion |
| 944 | (let (struct (label nil)) | 943 | (let (struct (label nil)) |
| 945 | (if (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(if\\)\\>") | 944 | (when (looking-at "\\(\\(\\sw+\\)[ \t]*\:\\)?[ \t]*\\(if\\)\\>") |
| 946 | (progn | 945 | (setq struct (match-string 3)) |
| 947 | (setq struct (match-string 3)) | 946 | (if (looking-at "\\(\\sw+\\)[ \t]*\:") |
| 948 | (if (looking-at "\\(\\sw+\\)[ \t]*\:") | 947 | (setq label (match-string 1))) |
| 949 | (setq label (match-string 1))) | 948 | (let ((pos (scan-lists (point) 1 0))) |
| 950 | (let ((pos (scan-lists (point) 1 0))) | 949 | (and pos (goto-char pos))) |
| 951 | (and pos (goto-char pos))) | 950 | (skip-chars-forward " \t") |
| 952 | (skip-chars-forward " \t") | 951 | (if (or (looking-at "then\\>") |
| 953 | (if (or (looking-at "then\\>") | 952 | (when (f90-line-continued) |
| 954 | (if (f90-line-continued) | 953 | (f90-next-statement) |
| 955 | (progn | 954 | (skip-chars-forward " \t0-9&") |
| 956 | (f90-next-statement) | 955 | (looking-at "then\\>"))) |
| 957 | (skip-chars-forward " \t0-9&") | 956 | (list struct label)))))) |
| 958 | (looking-at "then\\>")))) | ||
| 959 | (list struct label))))))) | ||
| 960 | 957 | ||
| 961 | (defsubst f90-looking-at-where-or-forall () | 958 | (defsubst f90-looking-at-where-or-forall () |
| 962 | "Return (kind name) if a where or forall block starts after point. | 959 | "Return (kind name) if a where or forall block starts after point. |
| @@ -1043,11 +1040,11 @@ block[ \t]*data\\)\\>") | |||
| 1043 | 1040 | ||
| 1044 | (defsubst f90-update-line () | 1041 | (defsubst f90-update-line () |
| 1045 | (let (bol eol) | 1042 | (let (bol eol) |
| 1046 | (if f90-auto-keyword-case | 1043 | (when f90-auto-keyword-case |
| 1047 | (progn (setq bol (line-beginning-position) | 1044 | (setq bol (line-beginning-position) |
| 1048 | eol (line-end-position)) | 1045 | eol (line-end-position)) |
| 1049 | (if f90-auto-keyword-case | 1046 | (if f90-auto-keyword-case |
| 1050 | (f90-change-keywords f90-auto-keyword-case bol eol)))))) | 1047 | (f90-change-keywords f90-auto-keyword-case bol eol))))) |
| 1051 | 1048 | ||
| 1052 | (defun f90-electric-insert () | 1049 | (defun f90-electric-insert () |
| 1053 | "Call `f90-do-auto-fill' at each operator insertion." | 1050 | "Call `f90-do-auto-fill' at each operator insertion." |
| @@ -1068,17 +1065,16 @@ Does not check type and subprogram indentation." | |||
| 1068 | (looking-at "[ \t]*[0-9]")))) | 1065 | (looking-at "[ \t]*[0-9]")))) |
| 1069 | (setq icol (current-indentation)) | 1066 | (setq icol (current-indentation)) |
| 1070 | (beginning-of-line) | 1067 | (beginning-of-line) |
| 1071 | (if (re-search-forward "\\(if\\|do\\|select\\|where\\|forall\\)" | 1068 | (when (re-search-forward "\\(if\\|do\\|select\\|where\\|forall\\)" |
| 1072 | (line-end-position) t) | 1069 | (line-end-position) t) |
| 1073 | (progn | 1070 | (beginning-of-line) (skip-chars-forward " \t") |
| 1074 | (beginning-of-line) (skip-chars-forward " \t") | 1071 | (cond ((f90-looking-at-do) |
| 1075 | (cond ((f90-looking-at-do) | 1072 | (setq icol (+ icol f90-do-indent))) |
| 1076 | (setq icol (+ icol f90-do-indent))) | 1073 | ((or (f90-looking-at-if-then) |
| 1077 | ((or (f90-looking-at-if-then) | 1074 | (f90-looking-at-where-or-forall) |
| 1078 | (f90-looking-at-where-or-forall) | 1075 | (f90-looking-at-select-case)) |
| 1079 | (f90-looking-at-select-case)) | 1076 | (setq icol (+ icol f90-if-indent)))) |
| 1080 | (setq icol (+ icol f90-if-indent)))) | 1077 | (end-of-line)) |
| 1081 | (end-of-line))) | ||
| 1082 | (while (re-search-forward | 1078 | (while (re-search-forward |
| 1083 | "\\(if\\|do\\|select\\|where\\|forall\\)" epnt t) | 1079 | "\\(if\\|do\\|select\\|where\\|forall\\)" epnt t) |
| 1084 | (beginning-of-line) (skip-chars-forward " \t0-9") | 1080 | (beginning-of-line) (skip-chars-forward " \t0-9") |
| @@ -1453,13 +1449,13 @@ is non-nil, call `f90-update-line' after inserting the continuation marker." | |||
| 1453 | "From `fill-column', search backward for break-delimiter." | 1449 | "From `fill-column', search backward for break-delimiter." |
| 1454 | (let ((bol (line-beginning-position))) | 1450 | (let ((bol (line-beginning-position))) |
| 1455 | (re-search-backward f90-break-delimiters bol) | 1451 | (re-search-backward f90-break-delimiters bol) |
| 1456 | (if f90-break-before-delimiters | 1452 | (if (not f90-break-before-delimiters) |
| 1457 | (progn (backward-char) | 1453 | (if (looking-at f90-no-break-re) |
| 1458 | (if (not (looking-at f90-no-break-re)) | 1454 | (forward-char 2) |
| 1459 | (forward-char))) | 1455 | (forward-char)) |
| 1460 | (if (looking-at f90-no-break-re) | 1456 | (backward-char) |
| 1461 | (forward-char 2) | 1457 | (if (not (looking-at f90-no-break-re)) |
| 1462 | (forward-char))))) | 1458 | (forward-char))))) |
| 1463 | 1459 | ||
| 1464 | (defun f90-do-auto-fill () | 1460 | (defun f90-do-auto-fill () |
| 1465 | "Break line if non-white characters beyond `fill-column'. Also, update line." | 1461 | "Break line if non-white characters beyond `fill-column'. Also, update line." |
| @@ -1491,8 +1487,9 @@ is non-nil, call `f90-update-line' after inserting the continuation marker." | |||
| 1491 | (skip-chars-forward " \t") | 1487 | (skip-chars-forward " \t") |
| 1492 | (if (looking-at "\&") (delete-char 1)) | 1488 | (if (looking-at "\&") (delete-char 1)) |
| 1493 | (delete-region pos (point)) | 1489 | (delete-region pos (point)) |
| 1494 | (if (not (f90-in-string)) | 1490 | (unless (f90-in-string) |
| 1495 | (progn (delete-horizontal-space) (insert " "))) | 1491 | (delete-horizontal-space) |
| 1492 | (insert " ")) | ||
| 1496 | (if (and auto-fill-function | 1493 | (if (and auto-fill-function |
| 1497 | (> (save-excursion (end-of-line) | 1494 | (> (save-excursion (end-of-line) |
| 1498 | (current-column)) | 1495 | (current-column)) |
| @@ -1561,54 +1558,53 @@ Leave point at the end of line." | |||
| 1561 | (let ((count 1) (top-of-window (window-start)) (matching-beg nil) | 1558 | (let ((count 1) (top-of-window (window-start)) (matching-beg nil) |
| 1562 | (end-point (point)) (case-fold-search t) | 1559 | (end-point (point)) (case-fold-search t) |
| 1563 | beg-name end-name beg-block end-block end-struct) | 1560 | beg-name end-name beg-block end-block end-struct) |
| 1564 | (if (save-excursion (beginning-of-line) (skip-chars-forward " \t0-9") | 1561 | (when (save-excursion (beginning-of-line) (skip-chars-forward " \t0-9") |
| 1565 | (setq end-struct (f90-looking-at-program-block-end))) | 1562 | (setq end-struct (f90-looking-at-program-block-end))) |
| 1566 | (progn | 1563 | (setq end-block (car end-struct)) |
| 1567 | (setq end-block (car end-struct)) | 1564 | (setq end-name (car (cdr end-struct))) |
| 1568 | (setq end-name (car (cdr end-struct))) | 1565 | (save-excursion |
| 1569 | (save-excursion | 1566 | (beginning-of-line) |
| 1570 | (beginning-of-line) | 1567 | (while |
| 1571 | (while | 1568 | (and (not (zerop count)) |
| 1572 | (and (not (zerop count)) | 1569 | (let ((stop nil) notexist) |
| 1573 | (let ((stop nil) notexist) | 1570 | (while (not stop) |
| 1574 | (while (not stop) | 1571 | (setq notexist |
| 1575 | (setq notexist | 1572 | (not (re-search-backward |
| 1576 | (not (re-search-backward | 1573 | (concat "\\(" f90-blocks-re "\\)") nil t))) |
| 1577 | (concat "\\(" f90-blocks-re "\\)") nil t))) | 1574 | (if notexist |
| 1578 | (if notexist | 1575 | (setq stop t) |
| 1579 | (setq stop t) | 1576 | (setq stop |
| 1580 | (setq stop | 1577 | (not (or (f90-in-string) |
| 1581 | (not (or (f90-in-string) | 1578 | (f90-in-comment)))))) |
| 1582 | (f90-in-comment)))))) | 1579 | (not notexist))) |
| 1583 | (not notexist))) | 1580 | (beginning-of-line) (skip-chars-forward " \t0-9") |
| 1584 | (beginning-of-line) (skip-chars-forward " \t0-9") | 1581 | (cond ((setq matching-beg |
| 1585 | (cond ((setq matching-beg | 1582 | (cond |
| 1586 | (cond | 1583 | ((f90-looking-at-do)) |
| 1587 | ((f90-looking-at-do)) | 1584 | ((f90-looking-at-if-then)) |
| 1588 | ((f90-looking-at-if-then)) | 1585 | ((f90-looking-at-where-or-forall)) |
| 1589 | ((f90-looking-at-where-or-forall)) | 1586 | ((f90-looking-at-select-case)) |
| 1590 | ((f90-looking-at-select-case)) | 1587 | ((f90-looking-at-type-like)) |
| 1591 | ((f90-looking-at-type-like)) | 1588 | ((f90-looking-at-program-block-start)))) |
| 1592 | ((f90-looking-at-program-block-start)))) | 1589 | (setq count (- count 1))) |
| 1593 | (setq count (- count 1))) | 1590 | ((looking-at (concat "end[ \t]*" f90-blocks-re "\\b")) |
| 1594 | ((looking-at (concat "end[ \t]*" f90-blocks-re "\\b")) | 1591 | (setq count (+ count 1))))) |
| 1595 | (setq count (+ count 1))))) | 1592 | (if (not (zerop count)) |
| 1596 | (if (not (zerop count)) | 1593 | (message "No matching beginning.") |
| 1597 | (message "No matching beginning.") | 1594 | (f90-update-line) |
| 1598 | (f90-update-line) | 1595 | (if (eq f90-smart-end 'blink) |
| 1599 | (if (eq f90-smart-end 'blink) | 1596 | (if (< (point) top-of-window) |
| 1600 | (if (< (point) top-of-window) | 1597 | (message "Matches %s: %s" |
| 1601 | (message "Matches %s: %s" | 1598 | (what-line) |
| 1602 | (what-line) | 1599 | (buffer-substring |
| 1603 | (buffer-substring | 1600 | (line-beginning-position) |
| 1604 | (line-beginning-position) | 1601 | (line-end-position))) |
| 1605 | (line-end-position))) | 1602 | (sit-for 1))) |
| 1606 | (sit-for 1))) | 1603 | (setq beg-block (car matching-beg)) |
| 1607 | (setq beg-block (car matching-beg)) | 1604 | (setq beg-name (car (cdr matching-beg))) |
| 1608 | (setq beg-name (car (cdr matching-beg))) | 1605 | (goto-char end-point) |
| 1609 | (goto-char end-point) | 1606 | (beginning-of-line) |
| 1610 | (beginning-of-line) | 1607 | (f90-block-match beg-block beg-name end-block end-name)))))) |
| 1611 | (f90-block-match beg-block beg-name end-block end-name))))))) | ||
| 1612 | 1608 | ||
| 1613 | (defun f90-insert-end () | 1609 | (defun f90-insert-end () |
| 1614 | "Insert a complete end statement matching beginning of present block." | 1610 | "Insert a complete end statement matching beginning of present block." |
| @@ -1697,14 +1693,13 @@ Any other key combination is executed normally." | |||
| 1697 | (goto-char beg) | 1693 | (goto-char beg) |
| 1698 | (unwind-protect | 1694 | (unwind-protect |
| 1699 | (while (re-search-forward keyword-re end t) | 1695 | (while (re-search-forward keyword-re end t) |
| 1700 | (if (progn | 1696 | (unless (progn |
| 1701 | (setq state (parse-partial-sexp ref-point (point))) | 1697 | (setq state (parse-partial-sexp ref-point (point))) |
| 1702 | (or (nth 3 state) (nth 4 state) | 1698 | (or (nth 3 state) (nth 4 state) |
| 1703 | (save-excursion ; Check for cpp directive. | 1699 | (save-excursion ; Check for cpp directive. |
| 1704 | (beginning-of-line) | 1700 | (beginning-of-line) |
| 1705 | (skip-chars-forward " \t0-9") | 1701 | (skip-chars-forward " \t0-9") |
| 1706 | (looking-at "#")))) | 1702 | (looking-at "#")))) |
| 1707 | () | ||
| 1708 | (setq ref-point (point) | 1703 | (setq ref-point (point) |
| 1709 | back-point (save-excursion (backward-word 1) (point))) | 1704 | back-point (save-excursion (backward-word 1) (point))) |
| 1710 | (setq saveword (buffer-substring back-point ref-point)) | 1705 | (setq saveword (buffer-substring back-point ref-point)) |