# M-x ack

DevFeed: [M-x ack](<https://devfeed.tech/articles/m-x-ack-34482.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2012/11/m-x-ack/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2012-11-22T16:36:00Z

Content type: tutorial

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [Emacs](<https://devfeed.tech/topics/emacs.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Tool](<https://devfeed.tech/topics/tool.md>)

Tags: [command](<https://devfeed.tech/tags/command.md>), [command-line](<https://devfeed.tech/tags/command-line.md>), [debian](<https://devfeed.tech/tags/debian.md>), [emacs](<https://devfeed.tech/tags/emacs.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [integrate](<https://devfeed.tech/tags/integrate.md>), [stackoverflow](<https://devfeed.tech/tags/stackoverflow.md>), [windows](<https://devfeed.tech/tags/windows.md>)

## AI overview

A tutorial showing how to integrate the ack search tool into Emacs by defining an Emacs Lisp command that configures Emacs's grep interface to use ack or ack-grep.

## Source excerpt

I've been asked about how to integrate the ack tool (you know, the one that is better than grep) into Emacs today. Again. And I just realized that I didn't blog about my solution. That might explain why I keep getting asked about it after all... So here it is, M-x ack: ;;; dim-ack.el --- Dimitri Fontaine ;; ;; http://stackoverflow.com/questions/2322389/ack-does-not-work-when-run-from-grep-find-in-emacs-on-windows (defcustom ack-command (or (executable-find "ack") (executable-find "ack-grep")) "Command to use to call ack, e.g. ack-grep under debian" :type 'file) (defvar ack-command-line (concat ack-command " --nogroup --nocolor ")) (defvar ack-history nil) (defvar ack-host-defaults-alist nil) (defun ack () "Like grep, but using ack-command as the default" (interactive) ; Make sure grep has been initialized (if (>= emacs-major-version 22) (require 'grep) (require 'compile)) ; Close STDIN to keep ack from going into filter mode (let ((null-device (format "< %s" null-device)) (grep-command ack-command-line) (grep-history ack-history) (grep-host-defaults-alist ack-host-defaults-alist)) (call-interactively 'grep) (setq ack-history grep-history ack-host-defaults-alist grep-host-defaults-alist))) (provide 'dim-ack) Enjoy!