Mercurial > emacs
comparison lisp/progmodes/fortran.el @ 6731:23d9c2bc097b
(fortran-blink-matching-do): New function,
basically copied from fortran-blink-matching-if.
(fortran-indent-line): Call it.
(fortran-mode): Doc mod.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 07 Apr 1994 17:14:44 +0000 |
parents | fe1a71db966f |
children | ce33fcd2ce22 |
comparison
equal
deleted
inserted
replaced
6730:082898766745 | 6731:23d9c2bc097b |
---|---|
109 | 109 |
110 (defvar fortran-check-all-num-for-matching-do nil | 110 (defvar fortran-check-all-num-for-matching-do nil |
111 "*Non-nil causes all numbered lines to be treated as possible DO loop ends.") | 111 "*Non-nil causes all numbered lines to be treated as possible DO loop ends.") |
112 | 112 |
113 (defvar fortran-blink-matching-if nil | 113 (defvar fortran-blink-matching-if nil |
114 "*From a Fortran ENDIF statement, blink the matching IF statement.") | 114 "*From a Fortran ENDIF statement, blink the matching IF statement. |
115 Also, from an ENDDO statement, blink on matching DO [WHILE] statement.") | |
115 | 116 |
116 (defvar fortran-continuation-string "$" | 117 (defvar fortran-continuation-string "$" |
117 "*Single-character string used for Fortran continuation lines. | 118 "*Single-character string used for Fortran continuation lines. |
118 In fixed format continuation style, this character is inserted in | 119 In fixed format continuation style, this character is inserted in |
119 column 6 by \\[fortran-split-line] to begin a continuation line. | 120 column 6 by \\[fortran-split-line] to begin a continuation line. |
324 fortran-check-all-num-for-matching-do | 325 fortran-check-all-num-for-matching-do |
325 Non-nil causes all numbered lines to be treated as possible \"continue\" | 326 Non-nil causes all numbered lines to be treated as possible \"continue\" |
326 statements. (default nil) | 327 statements. (default nil) |
327 fortran-blink-matching-if | 328 fortran-blink-matching-if |
328 From a Fortran ENDIF statement, blink the matching IF statement. | 329 From a Fortran ENDIF statement, blink the matching IF statement. |
330 Also, from an ENDDO statement, blink on matching DO [WHILE] statement. | |
329 (default nil) | 331 (default nil) |
330 fortran-continuation-string | 332 fortran-continuation-string |
331 Single-character string to be inserted in column 5 of a continuation | 333 Single-character string to be inserted in column 5 of a continuation |
332 line. (default \"$\") | 334 line. (default \"$\") |
333 fortran-comment-region | 335 fortran-comment-region |
724 (if message | 726 (if message |
725 (message "%s" message) | 727 (message "%s" message) |
726 (goto-char matching-if) | 728 (goto-char matching-if) |
727 (sit-for 1) | 729 (sit-for 1) |
728 (goto-char endif-point)))))) | 730 (goto-char endif-point)))))) |
731 | |
732 (defun fortran-blink-matching-do () | |
733 ;; From a Fortran ENDDO statement, blink on the matching DO or DO WHILE | |
734 ;; statement. This is basically copied from fortran-blink-matching-if. | |
735 (let ((count 1) (top-of-window (window-start)) matching-do | |
736 (enddo-point (point)) message) | |
737 (if (save-excursion (beginning-of-line) | |
738 (skip-chars-forward " \t0-9") | |
739 (looking-at "end[ \t]*do\\b")) | |
740 (progn | |
741 (save-excursion | |
742 (while (and (not (= count 0)) | |
743 (not (eq (fortran-previous-statement) | |
744 'first-statement)) | |
745 (not (looking-at | |
746 "^[ \t0-9]*end\\b[ \t]*[^ \t=(a-z]"))) | |
747 ; Keep local to subprogram | |
748 (skip-chars-forward " \t0-9") | |
749 (cond ((looking-at "do[ \t]+") | |
750 (setq count (- count 1))) | |
751 ((looking-at "end[ \t]*do\\b") | |
752 (setq count (+ count 1))))) | |
753 (if (not (= count 0)) | |
754 (setq message "No matching do.") | |
755 (if (< (point) top-of-window) | |
756 (setq message (concat "Matches " (buffer-substring | |
757 (progn (beginning-of-line) | |
758 (point)) | |
759 (progn (end-of-line) | |
760 (point))))) | |
761 (setq matching-do (point))))) | |
762 (if message | |
763 (message "%s" message) | |
764 (goto-char matching-do) | |
765 (sit-for 1) | |
766 (goto-char enddo-point)))))) | |
729 | 767 |
730 (defun fortran-indent-line () | 768 (defun fortran-indent-line () |
731 "Indents current Fortran line based on its contents and on previous lines." | 769 "Indents current Fortran line based on its contents and on previous lines." |
732 (interactive) | 770 (interactive) |
733 (let ((cfi (calculate-fortran-indent))) | 771 (let ((cfi (calculate-fortran-indent))) |
748 (> (save-excursion (end-of-line) (current-column)) fill-column)) | 786 (> (save-excursion (end-of-line) (current-column)) fill-column)) |
749 (save-excursion | 787 (save-excursion |
750 (end-of-line) | 788 (end-of-line) |
751 (fortran-do-auto-fill))) | 789 (fortran-do-auto-fill))) |
752 (if fortran-blink-matching-if | 790 (if fortran-blink-matching-if |
753 (fortran-blink-matching-if)))) | 791 (progn |
792 (fortran-blink-matching-if) | |
793 (fortran-blink-matching-do))))) | |
754 | 794 |
755 (defun fortran-indent-new-line () | 795 (defun fortran-indent-new-line () |
756 "Reindent the current Fortran line, insert a newline and indent the newline. | 796 "Reindent the current Fortran line, insert a newline and indent the newline. |
757 An abbrev before point is expanded if `abbrev-mode' is non-nil." | 797 An abbrev before point is expanded if `abbrev-mode' is non-nil." |
758 (interactive) | 798 (interactive) |