;; for it.
(defun fortran-current-defun ()
"Function to use for `add-log-current-defun-function' in Fortran mode."
- ;; We must be inside function body for this to work.
- (fortran-beginning-of-subprogram)
- (let ((case-fold-search t)) ; case-insensitive
- ;; search for fortran subprogram start
- (if (re-search-forward
- (concat "^[ \t]*\\(program\\|subroutine\\|function"
- "\\|[ \ta-z0-9*()]*[ \t]+function\\|"
- "\\(block[ \t]*data\\)\\)")
- (save-excursion (fortran-end-of-subprogram)
- (point))
- t)
- (or (match-string-no-properties 2)
- (progn
- ;; move to EOL or before first left paren
- (if (re-search-forward "[(\n]" nil t)
- (progn (backward-char)
- (skip-chars-backward " \t"))
- (end-of-line))
- ;; Use the name preceding that.
- (buffer-substring-no-properties (point) (progn (backward-sexp)
- (point)))))
- "main")))
+ (save-excursion
+ ;; We must be inside function body for this to work.
+ (fortran-beginning-of-subprogram)
+ (let ((case-fold-search t)) ; case-insensitive
+ ;; search for fortran subprogram start
+ (if (re-search-forward
+ (concat "^[ \t]*\\(program\\|subroutine\\|function"
+ "\\|[ \ta-z0-9*()]*[ \t]+function\\|"
+ "\\(block[ \t]*data\\)\\)")
+ (save-excursion (fortran-end-of-subprogram)
+ (point))
+ t)
+ (or (match-string-no-properties 2)
+ (progn
+ ;; move to EOL or before first left paren
+ (if (re-search-forward "[(\n]" nil t)
+ (progn (backward-char)
+ (skip-chars-backward " \t"))
+ (end-of-line))
+ ;; Use the name preceding that.
+ (buffer-substring-no-properties (point) (progn (backward-sexp)
+ (point)))))
+ "main"))))
(provide 'fortran)