title: How to switch to a specific directory before grepping in emacs?
body: <p>I am grepping across all my projects:</p>
  
  <pre><code>(defun grep-all-projects(start end)
    (interactive "r")
    (if (and transient-mark-mode mark-active)
        (setq my-word (buffer-substring-no-properties start end))
      (setq my-word (thing-at-point 'word))
      )
    (let ((default-directory (getenv "REPOS_DIR")))
      (message "===&gt; Grepping '%s' in %s" my-word (getenv "REPOS_DIR"))
      (grep (format "grep --exclude-dir target -r -ne '%s' ." my-word)))
    )
  </code></pre>
  
  <p>But somehow the grepping is performed on the root directory (<code>/</code>), even though the grep buffer correctly says:</p>
  
  <pre><code>-*- mode: grep; default-directory: "/repos/" -*-
  Grep started at Tue Jun  6 10:38:08
  </code></pre>
  
  <p>What is going on? Is <code>emacs</code> <code>grep</code> not respecting the <code>default-directory</code>?</p>
  
  <h2>EDIT</h2>
  
  <p>This workaround, without making use of <code>default-directory</code>, works:</p>
  
  <pre><code>(defun grep-all-projects(start end)
    (interactive "r")
    (if (and transient-mark-mode mark-active)
        (setq my-word (buffer-substring-no-properties start end))
      (setq my-word (thing-at-point 'word))
      )
    (message "===&gt; Grepping '%s' in %s" my-word (getenv "REPOS_DIR"))
    (grep (format "grep --exclude-dir target -r -ne '%s' %s" my-word (getenv "REPOS_DIR")))
    )
  </code></pre>
  
  <p>I am still interested in knowing why the first implementation does not work as expected</p>