Question: Basically I want a command that can do the following:

`find /path/dir -type f -print0 | xargs -0 grep -l "foo"`

Is there an emacs command to do this? If not, then is there a convenient keybinding that I can make? I tried to do the following:

```
(global-set-key (kbd "C-f") 'find)
(defun find (dir string)
  (interactive)
  (shell)
  (insert "find")
  (insert dir)
  (insert "-type f -print0 | xargs -0 grep -l")
  (insert string)
)

```

But it doesn't seem to work. It gives me "wrong type argument: commandp, find".

Answer: 
**Solution 1**, add `(setq wc-idle-wait 2)` into `~/.emacs` if you need get updated with the data in real time,

[![enter image description here](https://i.stack.imgur.com/nI4O6.png)](https://i.stack.imgur.com/nI4O6.png)

Please note `wc-idle-wait` should be set **before** loading `wc-mode.el` because of below code in `wc-mode.el`,

```
(setq wc-timer-tracker
      (run-with-idle-timer
       wc-idle-wait t
       '(lambda ()
          (when wc-mode
            (setq wc-buffer-stats (wc-mode-update))))))

```

**Solution 2**, do the calculation only before saving current buffer. But you need set `wc-idle-wait` to a bigger value first.

Here is sample setup (see my comment, you can do some further optimization inside `before-save-hook`),

```
(setq wc-idle-wait most-positive-fixnum)
(add-hook 'before-save-hook
          (lambda ()
            ;; you can check `buffer-file-name' or `major-mode' first
            (setq wc-buffer-stats (wc-mode-update))))

```
See [mode-line-idle](https://gitlab.com/ideasman42/emacs-mode-line-idle/), the `readme` shows an example of showing a word count in a way that's not blocking.

This allows you to add anything you like to your mode line in a way that doesn't block your workflow.