Function: grep-mode

grep-mode is an autoloaded, interactive and byte-compiled function defined in grep.el.gz.

Signature

(grep-mode)

Documentation

Sets grep-last-buffer and compilation-window-height.

In addition to any hooks its parent mode compilation-mode might have run, this mode runs the hook grep-mode-hook, as the final or penultimate step during initialization.

- negative-argument
0 digit-argument
1 digit-argument
2 digit-argument
3 digit-argument
4 digit-argument
5 digit-argument
6 digit-argument
7 digit-argument
8 digit-argument
9 digit-argument
< beginning-of-buffer
<backtab> compilation-previous-error
<follow-link> mouse-face
<mouse-2> compile-goto-error
> end-of-buffer
? describe-mode
C-c C-c compile-goto-error
C-c C-f next-error-follow-minor-mode(var)/next-error-follow-minor-mode(fun)
C-c C-k kill-compilation
C-o compilation-display-error
DEL scroll-down-command
DEL scroll-down-command
M-n compilation-next-error
M-p compilation-previous-error
M-{ compilation-previous-file
M-} compilation-next-file
RET compile-goto-error
RET compile-goto-error
S-SPC scroll-down-command
S-SPC scroll-down-command
SPC scroll-up-command
SPC scroll-up-command
SPC..~ undefined
TAB compilation-next-error
g recompile
g revert-buffer
h describe-mode
l recenter-current-error
n next-error-no-select
p previous-error-no-select
q quit-window
{ compilation-previous-file
} compilation-next-file

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/grep.el.gz
;;;###autoload
(define-compilation-mode grep-mode "Grep"
  "Sets `grep-last-buffer' and `compilation-window-height'."
  (setq grep-last-buffer (current-buffer))
  (setq-local tool-bar-map grep-mode-tool-bar-map)
  (setq-local compilation-error-face
              grep-hit-face)
  (setq-local compilation-error-regexp-alist
              grep-regexp-alist)
  (setq-local compilation-mode-line-errors
              grep-mode-line-matches)
  ;; compilation-directory-matcher can't be nil, so we set it to a regexp that
  ;; can never match.
  (setq-local compilation-directory-matcher
              (list regexp-unmatchable))
  (setq-local compilation-process-setup-function
              #'grep-process-setup)
  (setq-local compilation-disable-input t)
  (setq-local compilation-error-screen-columns
              grep-error-screen-columns)
  ;; We normally use a nul byte to separate the file name from the
  ;; contents, but display it as ":".  That's fine, but when yanking
  ;; to other buffers, it's annoying to have the nul byte there.
  (unless kill-transform-function
    (setq-local kill-transform-function #'identity))
  (add-function :filter-return (local 'kill-transform-function)
                (lambda (string)
                  (string-replace "\0" ":" string)))
  (when grep-use-headings
    (add-hook 'compilation-filter-hook #'grep--heading-filter 80 t)
    (setq-local outline-search-function #'outline-search-level
                outline-level (lambda () (get-text-property
                                          (point) 'outline-level))))
  (add-hook 'compilation-filter-hook #'grep-filter nil t))