[comp.emacs] gosling emacs function for generating uucp addresses

beth@sphinx.UUCP (03/11/87)

I wrote myself a little mlisp function to change those user@host.UUCP
addresses that rn generates when you reply to postings into something
useable.  Then I made it (a little!) more robust, and made it available
to users here on my machine.  Someone suggested that I post the function
to news.admin, so here it is.  I thought it might also belong in
comp.emacs, so you folks get it too.  It relies on the uupath program,
so if that isn't supported on your machine, you'll have to either modify
or ignore this code, as you wish.

I don't read either of these newsgroups regularly, so please mail any
questions, fixes, improvements, responses, flames, ... to me directly.

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Cut here +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; The function uucp-addr searches for the (first) "To: " line of a mail
; message and changes an address of the form "user@host.UUCP" to an
; address of the form "shortest-path!host!user".  It does not handle
; incorrect host names gracefully, so check to make sure it didn't change
; your address to "host not found!user" or some other nonsense.

(defun
    (uucp-addr pgm
	(save-excursion
	    (beginning-of-file)
	    (re-search-forward "^To: ")
	    (beginning-of-line)
	    (set-mark)
	    (next-line)			; We're only concerned with the "To: "
	    (narrow-region)		; line, so don't muck up anything else
	    (beginning-of-file)
	    (error-occurred (replace-string ".uucp" ".UUCP"))
	    (if (error-occured (re-search-forward "@*.UUCP"))
		(progn
		    (widen-region)
		    (message "address is not 'user@host.UUCP'"))
		(progn
		    (beginning-of-file)
		    (search-forward "@")
		    (set-mark)			; Put region around host name
		    (search-forward ".")
		    (backward-character)
		    (case-region-lower)		; we only want lower case
		    (setq pgm (concat "uupath " (region-to-string)))
		    (search-reverse " ")	; Get just before user name
		    (forward-character)
		    (set-mark)
		    (fast-filter-region pgm)	; Insert shortest path to host
		    (delete-previous-character)	; Delete newline after path
		    (insert-string "!")
		    (search-forward "@")	; Now delete "@" and beyond
		    (backward-character)
		    (kill-to-end-of-line)
		    (widen-region)		; put things back to normal
		    (novalue)
		)
	    )
	)))
-- 
--JB  ((Just) Beth Christy, U. of Chicago, ..!ihnp4!gargoyle!sphinx!beth)

	Working here is like a nightmare:
	  you'd like to get out of it, but you need the sleep.