title: Exposing variables to a lambda returned from within defun
body: <p>I'm attempting to attach a key handler such that a wrapper function is first executed that checks whether a library has been loaded and, if not, loads it before finally executing the intended function.</p>
  
  <p>The idea is to be able to do:</p>
  
  <pre><code>(global-set-key (kbd "C-c r")
                  (run-or-load-f 'visual-regexp 'vr/replace))
  </code></pre>
  
  <p>Where <code>run-or-load-f</code> is:</p>
  
  <pre><code>(defmacro run-or-load-f (mode func)
    `(lambda()
       (interactive)
       (run-or-load mode func)))
  </code></pre>
  
  <p>The problem I'm having is that <strong>I do not know how to expose <code>mode</code> and <code>func</code> in the lambda above</strong>.  I'm not even sure I need a macro but it does seem that way.</p>
  
  <p>For completion's sake, the function <code>run-or-load</code> above is very simply:</p>
  
  <pre><code>(defun run-or-load (mode func)
    (unless (fboundp mode)
      (load-library (symbol-name mode)))
    (call-interactively func))
  </code></pre>