title: emacs call-interactively and key simulation
body: <p>I want to write a small function that saves the cursor's current position, mark the whole buffer, indents it and then goes back to the previous cursor position. I understand there might be easier way to achieve the same result but I'd like to understand how these principles work in Elisp.</p>
  
  <p>Here's what I tried to do :</p>
  
  <pre><code>(defun indent-whole-buffer () (interactive)                                                                                                                                                                        
      (call-interactively 'point-to-register)                                                                                                                                                                    
      (call-interactively (kbd "RET"))                                                                                                                                                                                 
      (mark-whole-buffer)                                                                                                                                                                                              
      (call-interactively 'indent-region)                                                                                                                                                                              
      (call-interactively 'jump-to-register)                                                                                                                                                                           
      (call-interactively (kbd "RET"))                                                                                                                                                                                 
    )  
  </code></pre>
  
  <p>The blocking point here is  the <code>(call-interactively (kbd "RET"))</code> how can I simulate the RET key, just as if I was doing</p>
  
  <pre><code>M-x point-to-register RET
  </code></pre>