forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-isearch.el
44 lines (35 loc) · 1.58 KB
/
init-isearch.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
;; Show number of matches while searching
(when (maybe-require-package 'anzu)
(global-anzu-mode t)
(setq anzu-mode-lighter "")
(global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)
(global-set-key [remap query-replace] 'anzu-query-replace))
;; Activate occur easily inside isearch
(when (maybe-require-package 'emacs '(24 3))
(define-key isearch-mode-map (kbd "C-c C-o") 'isearch-occur)) ;; to match ivy conventions
;; DEL during isearch should edit the search string, not jump back to the previous result
(define-key isearch-mode-map [remap isearch-delete-char] 'isearch-del-char)
;; Search back/forth for the symbol at point
;; See http://www.emacswiki.org/emacs/SearchAtPoint
(defun isearch-yank-symbol ()
"*Put symbol at current point into search string."
(interactive)
(let ((sym (symbol-at-point)))
(if sym
(progn
(setq isearch-regexp t
isearch-string (concat "\\_<" (regexp-quote (symbol-name sym)) "\\_>")
isearch-message (mapconcat 'isearch-text-char-description isearch-string "")
isearch-yank-flag t))
(ding)))
(isearch-search-and-update))
(define-key isearch-mode-map "\C-\M-w" 'isearch-yank-symbol)
;; http://www.emacswiki.org/emacs/ZapToISearch
(defun sanityinc/isearch-exit-other-end (rbeg rend)
"Exit isearch, but at the other end of the search string.
This is useful when followed by an immediate kill."
(interactive "r")
(isearch-exit)
(goto-char isearch-other-end))
(define-key isearch-mode-map [(control return)] 'sanityinc/isearch-exit-other-end)
(provide 'init-isearch)