title: Overriding a function in Emacs Lisp
body: <p>I would like to temporarily override the <strong>kill-new</strong> function.  I have a way I want to reimplement kill-new that works in only in certain contexts, but I don't want to reimplement a special version of <strong>kill-region</strong> on top of that.  (kill-new is called from kill-region)</p>
  
  <p>Since Emacs Lisp uses dynamic scoping, this should be possible, right?  (On the other hand, it seems that this would be an unsafe thing to support, and it might make me a bit nervous knowing that it is possible...)</p>
  
  <p>I have experimented with using let and fset, but so far have found no way to get it to work as expected.  So, hopefully someone can fill in the blank in the following pseudocode: </p>
  
  <pre><code>(defun my-kill-new (string &amp;optional replace yank-handler) 
     (message "in my-kill-new!"))
  
  (defun foo ()
     (some-form-that-binds-a-function (kill-new my-kill-new)
     (kill-region (point) (mark))))
  </code></pre>
  
  <p>What should <strong>some-form-that-binds-a-function</strong> be?  Or am I barking up the wrong tree?</p>