Add grep stuff
This commit is contained in:
parent
1401f0b8f8
commit
5bff65947b
@ -192,6 +192,19 @@
|
|||||||
(interactive "r")
|
(interactive "r")
|
||||||
(shell-command (buffer-substring-no-properties start end)))
|
(shell-command (buffer-substring-no-properties start end)))
|
||||||
|
|
||||||
|
;; Builtin `rgrep' asks way too many questions. Here's a better one
|
||||||
|
;; Inspired by: https://emacs.stackexchange.com/a/26349
|
||||||
|
(defun recursive-grep ()
|
||||||
|
"Recursively grep file contents. `i` case insensitive; `n` print line number;
|
||||||
|
`I` ignore binary files; `E` extended regular expressions; `r` recursive"
|
||||||
|
(interactive)
|
||||||
|
(let* ((grep-flags "-inrEI --color=always -C3")
|
||||||
|
(search-term (read-string (format "Recursive regex search with grep %s: " grep-flags)))
|
||||||
|
(search-path (directory-file-name (expand-file-name (read-directory-name "directory: "))))
|
||||||
|
(default-directory (file-name-as-directory search-path))
|
||||||
|
(grep-command (concat grep-program " " grep-flags " " search-term " " search-path)))
|
||||||
|
(compilation-start grep-command 'grep-mode (lambda (mode) "*grep*") nil)))
|
||||||
|
|
||||||
(defun ext-terminal-in-workdir ()
|
(defun ext-terminal-in-workdir ()
|
||||||
"Open an external terminal emulator in working directory."
|
"Open an external terminal emulator in working directory."
|
||||||
(interactive)
|
(interactive)
|
||||||
@ -359,6 +372,7 @@
|
|||||||
"l" 'ibuffer
|
"l" 'ibuffer
|
||||||
"d" 'evil-delete-buffer
|
"d" 'evil-delete-buffer
|
||||||
;; Search and replace (interactive)
|
;; Search and replace (interactive)
|
||||||
|
"o" 'occur
|
||||||
"r" 'replace-regexp
|
"r" 'replace-regexp
|
||||||
"y" 'yank-from-kill-ring
|
"y" 'yank-from-kill-ring
|
||||||
;; Running external stuff
|
;; Running external stuff
|
||||||
@ -814,9 +828,10 @@
|
|||||||
;; filesystem vs developing for things inside of Linux.
|
;; filesystem vs developing for things inside of Linux.
|
||||||
(when (eq system-type 'windows-nt)
|
(when (eq system-type 'windows-nt)
|
||||||
(setq exec-path (cons "C:/cygwin/bin" exec-path))
|
(setq exec-path (cons "C:/cygwin/bin" exec-path))
|
||||||
|
(setq find-program "C:/cygwin64/bin/find.exe")
|
||||||
|
(setq grep-program "C:/cygwin64/bin/grep.exe")
|
||||||
(setenv "PATH" (mapconcat #'identity exec-path path-separator)))
|
(setenv "PATH" (mapconcat #'identity exec-path path-separator)))
|
||||||
|
|
||||||
|
|
||||||
;; Have to change emacs init dir for Windows
|
;; Have to change emacs init dir for Windows
|
||||||
;; https://emacs.stackexchange.com/a/12886
|
;; https://emacs.stackexchange.com/a/12886
|
||||||
;; (setenv "HOME" "C:/Users/itzja")
|
;; (setenv "HOME" "C:/Users/itzja")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user