Re: utility to replace "end" with "end subroutine foo"
- From: Glenn Morris <rgm+news@xxxxxxxxxxxx>
- Date: Fri, 27 Apr 2007 20:31:00 -0700
Rich Townsend wrote:
Beliavsky wrote:[...]
Has anyone written a utility to replace "end" statements with "end
program/subroutine/function" statements as appropriate?
The f90-mode in emacs does this when you hit 'tab' over the statement.
Being emacs, I'm sure there's an (arcane, lisp) way to call the
function that does this, for the entire file.
Being Emacs, if there isn't already a way, there can be:
(defun f90-match-all-ends (beg end)
"Qualify all ENDs in the region."
(interactive "*r")
(save-excursion
(goto-char end)
(setq end (point-marker))
(goto-char beg)
(let ((f90-smart-end 'noblink))
(while (re-search-forward "^[ \t0-9]*end" end t)
(goto-char (line-beginning-position))
(skip-chars-forward " \t0-9")
(when (f90-looking-at-program-block-end)
(f90-match-end))))))
Interactively:
C-x h
M-x f90-match-all-ends
Batch-mode:
Save the above definition to a file foo.el, then
emacs -batch --no-site-file -l f90 -l ./foo.el \
--eval '(progn (find-file "code.f90")
(f90-match-all-ends (point-min) (point-max))
(write-file "code_end.f90"))'
.
- References:
- utility to replace "end" with "end subroutine foo"
- From: Beliavsky
- Re: utility to replace "end" with "end subroutine foo"
- From: Rich Townsend
- utility to replace "end" with "end subroutine foo"
- Prev by Date: mpi & xlf
- Next by Date: Re: repeated namelist behavior
- Previous by thread: Re: utility to replace "end" with "end subroutine foo"
- Next by thread: Re: utility to replace "end" with "end subroutine foo"
- Index(es):
Relevant Pages
|
|