[net.emacs] a neat trick in emacs

podar@sbcs.UUCP (Sunil Podar) (05/18/85)

Before I begin, I must remind you that I am only a novice yet......
This trick may have been discovered earlier, but I did not find it being
used in any of the great big programs in our emacs library (through which
I have been tutoring myself in mlisp).
I wanted to take about six arguements for an interactively called function
and the only three ways seemed to be 
(1)taking each one-by-one using a number of constructs like (..(arg n "..?"))
   which would definitely be painful for simple arguments.
(2)use get-tty-string to get the whole list of args as a string and then 
   do your own parsing, again not easy to do if arguments are of varied types.
(3)expect user to type the whole function an an mlisp expression using
   ESC-ESC, but then it is not in conformity with the emacs philosophy of 
   invoking functions by ESCx and then can't have them bound to keys.
Well my trick made life simpler. I broke up the function in two, first one
being a execute-mlisp-line that simply invokes the second (actual) function
supplying it all the arguments and thereby letting emacs do all the parsing
for you!!!!. E.g.
-------------------------------------------------------
(defun (function-invoked-by-ESCx
	   (execute-mlisp-line 
	       (concat "(actual-function " 
			(get-tty-string "arg1 arg2 arg2 arg3 arg4 ...": ") ")"
	       ))))
(defun (actual-function any local variables
	(setq any (arg 1))
	(setq local (arg 2))
        ......
	))
-------------------------------------------------------
If you knew it already => you are a qualified hacker. 
If you have better ideas, please do let me know.
otherwise enjoy, happy hacking.

PS: thanks to all the netters who were very kind in reponding to my query
    about get-tty-buffer and default. keep up the spirit. With all your help,
    I soon hope to be a "net" contributor rather than a "net" taker.
-- 
Sunil Podar
SUNY at Stony Brook

	CSNET: podar@sbcs.csnet
	ARPA: podar%suny-sb.csnet@csnet-relay.arpa
	UUCP: {allegra, hocsd, philabs, ogcvax} !sbcs!podar

-- 
-- 
Sunil Podar
SUNY at Stony Brook

	CSNET: podar@sbcs.csnet
	ARPA: podar%suny-sb.csnet@csnet-relay.arpa
	UUCP: {allegra, hocsd, philabs, ogcvax} !sbcs!podar