From: CRDGW2::CRDGW2::MRGATE::"SMTP::AI.MIT.EDU::GNULISTS" 26-NOV-1990 09:39:35.49 To: MRGATE::"ARISIA::EVERHART" CC: Subj: Short routine to help traditional FORTRAN programmers. Received: by crdgw1.ge.com (5.57/GE 1.78) id AA13791; Sat, 24 Nov 90 22:06:29 EST Received: by life.ai.mit.edu (4.1/AI-4.10) id AA15140; Sat, 24 Nov 90 17:25:19 EST Return-Path: Received: from rice-chex (rice-chex.ai.mit.edu) by life.ai.mit.edu (4.1/AI-4.10) id AA15111; Sat, 24 Nov 90 17:24:05 EST Received: by rice-chex (4.1/AI-4.10) id AA06309; Sat, 24 Nov 90 17:24:02 EST Resent-Date: 22 Nov 90 17:16:31 GMT Resent-From: gnulists@ai.mit.edu Resent-Message-Id: <9011242224.AA06309@rice-chex> Received: by tut.cis.ohio-state.edu (5.61-kk/5.901120) id AA11921; Thu, 22 Nov 90 22:45:44 -0500 Received: from USENET by tut.cis.ohio-state.edu with netnews for gnu-emacs-sources@prep.ai.mit.edu (gnu-emacs-sources@prep.ai.mit.edu) (contact usenet@tut.cis.ohio-state.edu if you have questions) Date: 22 Nov 90 17:16:31 GMT From: eru!hagbard!sunic!mcsun!ukc!axion!tharr!gombo@bloom-beacon.mit.edu (Alun Jones) Organization: Power Microsystems Ltd Subject: Short routine to help traditional FORTRAN programmers. Message-Id: <1448@tharr.UUCP> Sender: gnu-emacs-sources-request@prep.ai.mit.edu To: gnu-emacs-sources@prep.ai.mit.edu Resent-To: gnu-emacs-sources@prep.ai.mit.edu Okay, so this is only a ten to fifteen minute programming exercise, but it's a useful little gadget if, like me, you like your Fortran in upper case. As the help text says, it puts the whole of the fortran code into one case (either upper or lower), but leaves comments and text as mixed case. Doubtless there are some situations where it falls over, but I haven't found any yet - having gone through over two hundred thousand lines of fortran. The only problem I can see is that occasionally undo fails - and spectacularly! For technical purposes, text begins with a ' and has a ' at the end, with no ' in between, comments are lines beginning with a C (either case), and there is the added feature that a ! means that the rest of the line is comment (except in text) - this because I'm porting Vax FORTRAN onto Unix. Enjoy. ;;; Fupper.el begins here - written 20/11/1990 by Alun Jones ;;; This is public domain, and usual disclaimers apply about ;;; liabilities if this trashes your FORTRAN code. In particular, ;;; save before you run fupcase, and NEVER undo its operation. ;;; If you must cancel what it did - the save will alow you to ;;; revert-buffer and survive. ;;; ;;; The comments took almost as long to write as the code. 8-) (defun fupcase (&optional lower) "Shoves all fortran statements in the current buffer into upper case. (or lower case if the optional argument is non-nil.) For $deity's sake, don't undo fupcase's action - on about one in three of my files, it causes intense problems. Make backup before you run it if you don't trust it, and use the revert-buffer command to escape it." (interactive "P") (goto-char 1) (while (not (eobp)) (while (looking-at "^[Cc]") (if lower (downcase-word 1) (upcase-word 1)) (beginning-of-line 2)) (let ((beginn (point))) (re-search-forward "^[Cc]\\|['!]" (point-max) 1) (if lower (downcase-region beginn (point)) (upcase-region beginn (point))) (if (save-excursion (forward-char -1) (looking-at "'")) (search-forward "'" (point-max) 1 1) (beginning-of-line 2))))) ;;;Fupper.el finishes here. -- Alun Jones - Unix Development Engineer - Welcom Software Technology Int'l. My views are nothing whatsoever to do with the company I work for. (That may be boring, but I feel safer for it.) <-- tharr *free* public access to Usenet in the UK 0234 261804 -->