emacs - change swiper
[dotfiles.git] / emacs.d / config.org
index 1ef2c2f..2b5d441 100644 (file)
@@ -781,47 +781,14 @@ Some global bindings on =Super=, on Mac, it is =Command=
 #+END_SRC
 
 ** Search Replace and highlight
-*** Occur
-Occur search key bindings
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (add-hook 'occur-hook (lambda ()
-                          (switch-to-buffer-other-window "*Occur*")
-                          (define-key occur-mode-map (kbd "C-o") nil)))
-  ;; auto select occur window
-
-  (define-key occur-mode-map (kbd "C-n")
-    (lambda ()
-      (interactive)
-      (occur-next)
-      (occur-mode-goto-occurrence-other-window)
-      (recenter)
-      (other-window 1)))
-
-  (define-key occur-mode-map (kbd "C-p")
-    (lambda ()
-      (interactive)
-      (occur-prev)
-      (occur-mode-goto-occurrence-other-window)
-      (recenter)
-      (other-window 1)))
-
-  (use-package color-moccur
-    :ensure t
-    :commands (isearch-moccur isearch-all)
-    :init
-    (setq isearch-lazy-highlight t)
-    :config
-    (use-package moccur-edit))
-#+END_SRC
-
 *** swiper
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (use-package swiper
-    :ensure t)
+  ;; (use-package swiper
+  ;;   :ensure t)
 
-  (ivy-mode 1)
-  (setq ivy-use-virtual-buffers t)
-  (global-set-key (kbd "s-/") 'swiper)
+  ;; (ivy-mode 1)
+  ;; (setq ivy-use-virtual-buffers t)
+  ;; (global-set-key (kbd "s-/") 'swiper)
 
   (use-package counsel
     :ensure t
@@ -844,10 +811,13 @@ Occur search key bindings
   ;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
   ;; ;; (define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
 
-  (set-face-attribute
-   'ivy-current-match nil
-   :background "Orange"
-   :foreground "black")
+  ;; (set-face-attribute
+  ;;  'ivy-current-match nil
+  ;;  :background "Orange"
+  ;;  :foreground "black")
+
+  ;; ivy-resume
+  ;; (define-key swiper-map (kbd "M-%") 'swiper-aa-replace)
 #+END_SRC
 
 *** =M-s= prefix
@@ -2345,8 +2315,7 @@ Use =Avy= for motion
   (use-package avy
     :ensure t
     :config
-    (avy-setup-default)
-    )
+    (avy-setup-default))
 
   (global-set-key (kbd "C-M-j") 'avy-goto-line-below)
   (global-set-key (kbd "C-M-n") 'avy-goto-line-below)
@@ -2403,6 +2372,54 @@ Use =Avy= for motion
   ;; (setq-default indicate-empty-lines t)
 #+END_SRC
 
+*** Occur
+Occur search key bindings
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (defun sd/occur-keys ()
+    "My key bindings in occur-mode"
+    (interactive)
+    (switch-to-buffer-other-window "*Occur*")
+    (define-key occur-mode-map (kbd "C-o") nil)
+    (define-key occur-mode-map (kbd "C-n") (lambda ()
+                                             (interactive)
+                                             (occur-next)
+                                             (occur-mode-goto-occurrence-other-window)
+                                             (recenter)
+                                             (other-window 1)))
+    (define-key occur-mode-map (kbd "C-p") (lambda ()
+                                             (interactive)
+                                             (occur-prev)
+                                             (occur-mode-goto-occurrence-other-window)
+                                             (recenter)
+                                             (other-window 1))))
+
+  (add-hook 'occur-hook #'sd/occur-keys)
+
+  (use-package color-moccur
+    :ensure t
+    :commands (isearch-moccur isearch-all)
+    :init
+    (setq isearch-lazy-highlight t)
+    :config
+    (use-package moccur-edit))
+#+END_SRC
+
+*** Swiper
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (use-package swiper
+    :ensure t
+    :init
+    (setq ivy-use-virtual-buffers t)
+    :config
+    (ivy-mode)
+    (global-set-key (kbd "s-/") 'swiper)
+    (define-key swiper-map (kbd "M-r") 'swiper-query-replace))
+
+  (set-face-attribute
+   'ivy-current-match nil
+   :background "Orange"
+   :foreground "black")
+#+END_SRC
 * test
 #+BEGIN_SRC ditaa :file temp/hello-world.png :cmdline -r
 +--------------+