[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 05dfbd0: Fix mark-defun in fortran-mode
From: |
Lars Ingebrigtsen |
Subject: |
master 05dfbd0: Fix mark-defun in fortran-mode |
Date: |
Wed, 9 Dec 2020 11:37:49 -0500 (EST) |
branch: master
commit 05dfbd0667bea8102a8daa7ea8894848178307ea
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix mark-defun in fortran-mode
* lisp/progmodes/fortran.el (fortran-beginning-of-subprogram):
Make mark-defun work (bug#33208).
---
lisp/progmodes/fortran.el | 42 ++++++++++++++++++++++++------------------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index 3a0274c..90eda44 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -1218,25 +1218,31 @@ Auto-indent does not happen if a numeric ARG is used."
;; 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."
+(defun fortran-beginning-of-subprogram (&optional arg)
+ "Move point to the beginning of the current Fortran subprogram.
+If ARG is negative, go to the beginning of the next instead."
(interactive)
- (let ((case-fold-search t))
- ;; 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))))
- ;; 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))))))
+ (if (and arg
+ (< arg 0))
+ (progn
+ (fortran-end-of-subprogram)
+ (fortran-beginning-of-subprogram))
+ (let ((case-fold-search t))
+ ;; 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))))
+ ;; 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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 05dfbd0: Fix mark-defun in fortran-mode,
Lars Ingebrigtsen <=