[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp ChangeLog progmodes/fortran.el
From: |
Glenn Morris |
Subject: |
[Emacs-diffs] emacs/lisp ChangeLog progmodes/fortran.el |
Date: |
Sun, 30 Aug 2009 01:38:14 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Glenn Morris <gm> 09/08/30 01:38:13
Modified files:
lisp : ChangeLog
lisp/progmodes : fortran.el
Log message:
(fortran-start-prog-re): New constant, extracted from
fortran-current-defun.
(fortran-beginning-of-subprogram): Be more precise about finding the
start, to avoid an infinite loop in end-of-defun. (Bug#4259)
(fortran-end-of-subprogram): Simplify.
(fortran-current-defun): Use fortran-start-prog-re.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16052&r2=1.16053
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/progmodes/fortran.el?cvsroot=emacs&r1=1.153&r2=1.154
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16052
retrieving revision 1.16053
diff -u -b -r1.16052 -r1.16053
--- ChangeLog 29 Aug 2009 22:27:19 -0000 1.16052
+++ ChangeLog 30 Aug 2009 01:38:09 -0000 1.16053
@@ -1,3 +1,12 @@
+2009-08-30 Glenn Morris <address@hidden>
+
+ * progmodes/fortran.el (fortran-start-prog-re): New constant, extracted
+ from fortran-current-defun.
+ (fortran-beginning-of-subprogram): Be more precise about finding the
+ start, to avoid an infinite loop in end-of-defun. (Bug#4259)
+ (fortran-end-of-subprogram): Simplify.
+ (fortran-current-defun): Use fortran-start-prog-re.
+
2009-08-29 Juanma Barranquero <address@hidden>
* subr.el (do-after-load-evaluation): Simplify.
Index: progmodes/fortran.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/fortran.el,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -b -r1.153 -r1.154
--- progmodes/fortran.el 9 Jan 2009 04:15:59 -0000 1.153
+++ progmodes/fortran.el 30 Aug 2009 01:38:13 -0000 1.154
@@ -330,6 +330,13 @@
(defconst fortran-if-start-re "\\(\\(\\sw\\|\\s_\\)+:[ \t]*\\)?if[ \t]*("
"Regexp matching the start of an IF statement.")
+;; Note fortran-current-defun uses the subgroups.
+(defconst fortran-start-prog-re
+ "^[ \t]*\\(program\\|subroutine\\|function\
+\\|[ \ta-z0-9*()]*[ \t]+function\\|\
+\\(block[ \t]*data\\)\\)"
+ "Regexp matching the start of a subprogram, from the line start.")
+
(defconst fortran-end-prog-re1
"end\
\\([ \t]*\\(program\\|subroutine\\|function\\|block[ \t]*data\\)\\>\
@@ -1182,37 +1189,47 @@
(+ fortran-line-length
(line-beginning-position)))))))
-;; Note that you can't just check backwards for `subroutine' &c in
-;; case of un-marked main programs not at the start of the file.
+;; This is more complex than first expected because the beginning of a
+;; main program may be implicit (ie not marked by a PROGRAM statement).
+;; This would be fine (we could just go to bob in the absence of a match),
+;; except it need not even be the first subprogram in the file (eg it
+;; could follow a subroutine). Hence we have to search for END
+;; statements instead.
+;; cf fortran-beginning-of-block, f90-beginning-of-subprogram
+;; Note that unlike the latter, we don't have to worry about nested
+;; subprograms (?).
+;; FIXME push-mark?
(defun fortran-beginning-of-subprogram ()
"Move point to the beginning of the current Fortran subprogram."
(interactive)
- (save-match-data
(let ((case-fold-search t))
- (beginning-of-line -1)
- (if (catch 'ok
+ ;; If called already at the start of subprogram, go to the previous.
+ (beginning-of-line (if (bolp) 0 1))
+ (save-match-data
+ (or (looking-at fortran-start-prog-re)
+ ;; This leaves us at bob if before the first subprogram.
+ (eq (fortran-previous-statement) 'first-statement)
+ (if (or (catch 'ok
(while (re-search-backward fortran-end-prog-re nil 'move)
- (if (fortran-check-end-prog-re)
- (throw 'ok t))))
- (forward-line)))))
+ (if (fortran-check-end-prog-re) (throw 'ok t))))
+ ;; If the search failed, must be at bob.
+ ;; First code line is the start of the subprogram.
+ ;; FIXME use a more rigorous test, cf fortran-next-statement?
+ ;; Though that needs to handle continuations too.
+ (not (looking-at "^\\([ \t]*[0-9]\\|[ \t]+[^!#]\\)")))
+ (fortran-next-statement))))))
+;; This is simpler than f-beginning-of-s because the end of a
+;; subprogram is never implicit.
(defun fortran-end-of-subprogram ()
"Move point to the end of the current Fortran subprogram."
(interactive)
- (save-match-data
(let ((case-fold-search t))
- (if (save-excursion ; on END
(beginning-of-line)
- (and (looking-at fortran-end-prog-re)
- (fortran-check-end-prog-re)))
- (forward-line)
- (beginning-of-line 2)
- (when (catch 'ok
- (while (re-search-forward fortran-end-prog-re nil 'move)
- (if (fortran-check-end-prog-re)
- (throw 'ok t))))
- (goto-char (match-beginning 0))
- (forward-line))))))
+ (save-match-data
+ (while (and (re-search-forward fortran-end-prog-re nil 'move)
+ (not (fortran-check-end-prog-re))))
+ (forward-line))))
(defun fortran-previous-statement ()
"Move point to beginning of the previous Fortran statement.
@@ -2137,19 +2154,16 @@
(replace-match "" nil nil nil 1)
(unless do-space (delete-horizontal-space)))))
-;; This code used to live in add-log.el, but this is a better place
-;; for it.
+;; This code used to live in add-log.el, but this is a better place for it.
(defun fortran-current-defun ()
"Function to use for `add-log-current-defun-function' in Fortran mode."
(save-excursion
;; We must be inside function body for this to work.
(fortran-beginning-of-subprogram)
- (let ((case-fold-search t)) ; case-insensitive
+ (let ((case-fold-search t))
;; Search for fortran subprogram start.
(if (re-search-forward
- (concat "^[ \t]*\\(program\\|subroutine\\|function"
- "\\|[ \ta-z0-9*()]*[ \t]+function\\|"
- "\\(block[ \t]*data\\)\\)")
+ fortran-start-prog-re
(save-excursion (fortran-end-of-subprogram)
(point))
t)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs/lisp ChangeLog progmodes/fortran.el,
Glenn Morris <=