title: Function that remove specific lambda from a hook in Emacs
body: <p>I found this macro, to run code for specific project path:</p>
  
  <pre><code>(defmacro project-specifics (name &amp;rest body)
    `(progn
       (add-hook 'find-file-hook
               (lambda ()
                 (when (string-match-p ,name (buffer-file-name))
                   ,@body)))
       (add-hook 'dired-after-readin-hook
               (lambda ()
                 (when (string-match-p ,name (dired-current-directory))
                   ,@body)))))
  </code></pre>
  
  <p>and I use it:</p>
  
  <pre><code>(project-specifics "projects/test"
    (message "z"))
  </code></pre>
  
  <p>And I work on modification that will remove prevoius lambda from the hook, so far I have helper functions</p>
  
  <pre><code>(defun remove-lambda-helper (list matcher)
    (dolist (item list)
      (if (and (listp item) (eq (car item) 'lambda))
          (when (funcall matcher item)
            (message "found")
            (setq list (delete item list))))))
  
  (defun remove-hook-name-lambda (name hook)
    (remove-lambda-helper hook
                          (lambda (body)
                            (equal (cadr (cadr (caddr body))) name))))
  </code></pre>
  
  <p>But when I call:</p>
  
  <pre><code>(remove-hook-name-lambda "projects/test" find-file-hook)
  </code></pre>
  
  <p>found is show up in <code>*Messages*</code> buffer but the lambda is not removed. What's wrong here?</p>