title: Segment Lisp source code by top level S-expression by emacs Lisp?
body: <p>I'd like to segment Lisp source code into a list of code segments. Each segment is either a top level S-expression, or whatever text between those S-expressions. </p>
  
  <p>Initially I thought that I could use regular expression pattern to match top level S-expression, but I found that it's not as trivial to handle the matching parenthesis to at the top level only. </p>
  
  <p>(I feel that it might be possible to work out a regular expression to match top level S-exp) by following example of this
  <a href="https://stackoverflow.com/questions/3227728/using-regular-expressions-to-extract-functions-and-function-headers-from-source">Using regular expressions to extract functions and function headers from source code</a></p>
  
  <p>Next, I figure that I may scan the text to observe the first left parenthesis '(', and the last right parenthesis ')', and do the segmentation accordingly. </p>
  
  <p>Before I do that I feel that given the ubiquitous nature of S-expression in emacs Lisp, there should have already existing solution to my requirements. </p>
  
  <p>So I ask if you could teach me any solution?</p>
  
  <p>Thanks, </p>