I'd recommend you spend some time studying the "Introduction to Emacs Lisp"
guide:



Thanks for pointing this out.  I have recently started programming in elisp, and am still having difficulty in basic understanding.

But the code worked.  So thanks for your help.

soichi