aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2001-11-29 12:24:33 +0000
committerDave Love2001-11-29 12:24:33 +0000
commitb25236041463fcc6a76ea4e4796e9887a0124c01 (patch)
treefa6396ef0c68f3a1dfcacc5999cc00f47ed7fd5a
parent1096bcc057c72162ca14d6cc117c7dc6398fb0be (diff)
downloademacs-b25236041463fcc6a76ea4e4796e9887a0124c01.tar.gz
emacs-b25236041463fcc6a76ea4e4796e9887a0124c01.zip
Fontify rewind, backspace. Doc fixes.
(fortran-window-create, fortran-window-create-momentarily): Rewrite, moving error condition. (fortran-beginning-do, fortran-beginning-if): Fix regexps. (fortran-mode-syntax-table): Revert last change.
-rw-r--r--lisp/progmodes/fortran.el75
1 files changed, 38 insertions, 37 deletions
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index 24d053e4cd4..99d91a087ec 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -1,6 +1,6 @@
1;;; fortran.el --- Fortran mode for GNU Emacs 1;;; fortran.el --- Fortran mode for GNU Emacs
2 2
3;; Copyright (c) 1986, 93, 94, 95, 97, 98, 99, 2000 3;; Copyright (c) 1986, 93, 94, 95, 97, 98, 99, 2000, 2001
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: Michael D. Prange <prange@erl.mit.edu> 6;; Author: Michael D. Prange <prange@erl.mit.edu>
@@ -30,7 +30,9 @@
30;; 30;;
31;; Note that it is for editing Fortran77 or Fortran90 fixed source 31;; Note that it is for editing Fortran77 or Fortran90 fixed source
32;; form. For editing Fortran 90 free format source, use `f90-mode' 32;; form. For editing Fortran 90 free format source, use `f90-mode'
33;; (f90.el). 33;; (f90.el). It is meant to support the GNU Fortran language
34;; implemented by g77 (its extensions to Fortran77 and
35;; interpretations, e.g. of blackslash in strings).
34 36
35;;; History: 37;;; History:
36 38
@@ -49,7 +51,7 @@
49;; * Implement insertion and removal of statement continuations in 51;; * Implement insertion and removal of statement continuations in
50;; mixed f77/f90 style, with the first `&' past column 72 and the 52;; mixed f77/f90 style, with the first `&' past column 72 and the
51;; second in column 6. 53;; second in column 6.
52;; * Support any other extensions to f77 grokked by GNU Fortran. 54;; * Support any other extensions to f77 grokked by GNU Fortran I've missed.
53 55
54(defgroup fortran nil 56(defgroup fortran nil
55 "Fortran mode for Emacs" 57 "Fortran mode for Emacs"
@@ -232,9 +234,8 @@ format style.")
232 (modify-syntax-entry ?/ "." table) 234 (modify-syntax-entry ?/ "." table)
233 (modify-syntax-entry ?\' "\"" table) 235 (modify-syntax-entry ?\' "\"" table)
234 (modify-syntax-entry ?\" "\"" table) 236 (modify-syntax-entry ?\" "\"" table)
235;;; Supposedly this is mistaken; Fortran does not treat \ as an escape. 237 ;; Consistent with GNU Fortran -- see the manual.
236;;; (modify-syntax-entry ?\\ "\\" table) 238 (modify-syntax-entry ?\\ "\\" table)
237 (modify-syntax-entry ?\\ "." table)
238 ;; This might be better as punctuation, as for C, but this way you 239 ;; This might be better as punctuation, as for C, but this way you
239 ;; can treat floating-point numbers as symbols. 240 ;; can treat floating-point numbers as symbols.
240 (modify-syntax-entry ?. "_" table) ; e.g. `a.ne.b' 241 (modify-syntax-entry ?. "_" table) ; e.g. `a.ne.b'
@@ -294,7 +295,8 @@ These get fixed-format comments fontified.")
294 (regexp-opt '("continue" "format" "end" "enddo" "if" "then" 295 (regexp-opt '("continue" "format" "end" "enddo" "if" "then"
295 "else" "endif" "elseif" "while" "inquire" "stop" 296 "else" "endif" "elseif" "while" "inquire" "stop"
296 "return" "include" "open" "close" "read" "write" 297 "return" "include" "open" "close" "read" "write"
297 "format" "print" "select" "case" "cycle" "exit")))) 298 "format" "print" "select" "case" "cycle" "exit"
299 "rewind" "backspace"))))
298 (fortran-logicals 300 (fortran-logicals
299 (eval-when-compile 301 (eval-when-compile
300 (regexp-opt '("and" "or" "not" "lt" "le" "eq" "ge" "gt" "ne" 302 (regexp-opt '("and" "or" "not" "lt" "le" "eq" "ge" "gt" "ne"
@@ -363,7 +365,7 @@ These get fixed-format comments fontified.")
363 ;; TAB-formatted line. 365 ;; TAB-formatted line.
364 '("^ \\([^ 0]\\)" 1 font-lock-string-face) 366 '("^ \\([^ 0]\\)" 1 font-lock-string-face)
365 '("^\t\\([1-9]\\)" 1 font-lock-string-face)) 367 '("^\t\\([1-9]\\)" 1 font-lock-string-face))
366 (list 368 (list
367 ;; cpp stuff (ugh) 369 ;; cpp stuff (ugh)
368 '("^# *[a-z]+" . font-lock-keyword-face)) 370 '("^# *[a-z]+" . font-lock-keyword-face))
369 ;; The list `fortran-font-lock-keywords-2' less that for types 371 ;; The list `fortran-font-lock-keywords-2' less that for types
@@ -801,22 +803,18 @@ The key typed is executed unless it is SPC."
801 "Make the window 72 columns wide. 803 "Make the window 72 columns wide.
802See also `fortran-window-create-momentarily'." 804See also `fortran-window-create-momentarily'."
803 (interactive) 805 (interactive)
804 (condition-case error 806 (let ((window-min-width 2))
805 (progn 807 (if (< (window-width) (frame-width))
806 (let ((window-min-width 2)) 808 (enlarge-window-horizontally (- (frame-width)
807 (if (< (window-width) (frame-width)) 809 (window-width) 1)))
808 (enlarge-window-horizontally (- (frame-width) 810 (let* ((window-edges (window-edges))
809 (window-width) 1))) 811 (scroll-bar-width (- (nth 2 window-edges)
810 (let* ((window-edges (window-edges)) 812 (car window-edges)
811 (scroll-bar-width (- (nth 2 window-edges) 813 (window-width))))
812 (car window-edges) 814 (split-window-horizontally (+ 72 scroll-bar-width)))
813 (window-width)))) 815 (other-window 1)
814 (split-window-horizontally (+ 72 scroll-bar-width))) 816 (switch-to-buffer " fortran-window-extra" t)
815 (other-window 1) 817 (select-window (previous-window))))
816 (switch-to-buffer " fortran-window-extra" t)
817 (select-window (previous-window))))
818 (error (message "No room for Fortran window")
819 'error)))
820 818
821(defun fortran-window-create-momentarily (&optional arg) 819(defun fortran-window-create-momentarily (&optional arg)
822 "Momentarily make the window 72 columns wide. 820 "Momentarily make the window 72 columns wide.
@@ -826,11 +824,14 @@ See also `fortran-window-create'."
826 (if (or (not arg) 824 (if (or (not arg)
827 (= arg 1)) 825 (= arg 1))
828 (save-window-excursion 826 (save-window-excursion
829 (if (not (equal (fortran-window-create) 'error)) 827 (progn
830 (progn (message "Type SPC to continue editing.") 828 (condition-case nil
831 (let ((char (read-event))) 829 (fortran-window-create)
832 (or (equal char (string-to-char " ")) 830 (error (error "No room for Fortran window")))
833 (setq unread-command-events (list char))))))) 831 (message "Type SPC to continue editing.")
832 (let ((char (read-event)))
833 (or (equal char (string-to-char " "))
834 (setq unread-command-events (list char))))))
834 (fortran-window-create))) 835 (fortran-window-create)))
835 836
836(defun fortran-split-line () 837(defun fortran-split-line ()
@@ -931,7 +932,7 @@ Auto-indent does not happen if a numeric ARG is used."
931;; Note that you can't just check backwards for `subroutine' &c in 932;; Note that you can't just check backwards for `subroutine' &c in
932;; case of un-marked main programs not at the start of the file. 933;; case of un-marked main programs not at the start of the file.
933(defun fortran-beginning-of-subprogram () 934(defun fortran-beginning-of-subprogram ()
934 "Moves point to the beginning of the current Fortran subprogram." 935 "Move point to the beginning of the current Fortran subprogram."
935 (interactive) 936 (interactive)
936 (save-match-data 937 (save-match-data
937 (let ((case-fold-search t)) 938 (let ((case-fold-search t))
@@ -943,7 +944,7 @@ Auto-indent does not happen if a numeric ARG is used."
943 (forward-line))))) 944 (forward-line)))))
944 945
945(defun fortran-end-of-subprogram () 946(defun fortran-end-of-subprogram ()
946 "Moves point to the end of the current Fortran subprogram." 947 "Move point to the end of the current Fortran subprogram."
947 (interactive) 948 (interactive)
948 (save-match-data 949 (save-match-data
949 (let ((case-fold-search t)) 950 (let ((case-fold-search t))
@@ -961,7 +962,7 @@ Auto-indent does not happen if a numeric ARG is used."
961 (forward-line))))) 962 (forward-line)))))
962 963
963(defun fortran-previous-statement () 964(defun fortran-previous-statement ()
964 "Moves point to beginning of the previous Fortran statement. 965 "Move point to beginning of the previous Fortran statement.
965Returns `first-statement' if that statement is the first 966Returns `first-statement' if that statement is the first
966non-comment Fortran statement in the file, and nil otherwise." 967non-comment Fortran statement in the file, and nil otherwise."
967 (interactive) 968 (interactive)
@@ -987,7 +988,7 @@ non-comment Fortran statement in the file, and nil otherwise."
987 'first-statement)))) 988 'first-statement))))
988 989
989(defun fortran-next-statement () 990(defun fortran-next-statement ()
990 "Moves point to beginning of the next Fortran statement. 991 "Move point to beginning of the next Fortran statement.
991Returns `last-statement' if that statement is the last 992Returns `last-statement' if that statement is the last
992non-comment Fortran statement in the file, and nil otherwise." 993non-comment Fortran statement in the file, and nil otherwise."
993 (interactive) 994 (interactive)
@@ -1099,7 +1100,7 @@ Return point or nil."
1099 (fortran-check-end-prog-re)))) 1100 (fortran-check-end-prog-re))))
1100 (skip-chars-forward " \t0-9") 1101 (skip-chars-forward " \t0-9")
1101 (cond ((looking-at 1102 (cond ((looking-at
1102 "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+[^0-9]") 1103 "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?do[ \t]+[0-9]")
1103 (setq count (1- count))) 1104 (setq count (1- count)))
1104 ((looking-at "end[ \t]*do\\b") 1105 ((looking-at "end[ \t]*do\\b")
1105 (setq count (1+ count))))) 1106 (setq count (1+ count)))))
@@ -1216,7 +1217,7 @@ Return point or nil."
1216 (setq then-test 1217 (setq then-test
1217 (looking-at 1218 (looking-at
1218 (concat ".*then\\b[ \t]*" 1219 (concat ".*then\\b[ \t]*"
1219 "[^ \t(=a-z[0-9]]")))))) 1220 "[^ \t(=a-z0-9]"))))))
1220 then-test)) 1221 then-test))
1221 (setq count (- count 1))))) 1222 (setq count (- count 1)))))
1222 ((looking-at "end[ \t]*if\\b") 1223 ((looking-at "end[ \t]*if\\b")
@@ -1735,7 +1736,7 @@ Intended as the value of `fill-paragraph-function'."
1735 ;; paragraph, delimited either by non-comment lines or empty 1736 ;; paragraph, delimited either by non-comment lines or empty
1736 ;; comments. (Get positions as markers, since the 1737 ;; comments. (Get positions as markers, since the
1737 ;; `indent-region' below can shift the block's end). 1738 ;; `indent-region' below can shift the block's end).
1738 (let* ((non-empty-comment 1739 (let* ((non-empty-comment
1739 (concat fortran-comment-line-start-skip "[^ \t\n]")) 1740 (concat fortran-comment-line-start-skip "[^ \t\n]"))
1740 (start (save-excursion 1741 (start (save-excursion
1741 ;; Find (start of) first line. 1742 ;; Find (start of) first line.
@@ -1746,7 +1747,7 @@ Intended as the value of `fill-paragraph-function'."
1746 (point-marker))) 1747 (point-marker)))
1747 (end (save-excursion 1748 (end (save-excursion
1748 ;; Find start of first line past region to fill. 1749 ;; Find start of first line past region to fill.
1749 (while (progn 1750 (while (progn
1750 (forward-line) 1751 (forward-line)
1751 (looking-at non-empty-comment))) 1752 (looking-at non-empty-comment)))
1752 (point-marker)))) 1753 (point-marker))))