Commit 9128e259c4b5

Vincent Demeester <vincent@sbr.pm>
2024-03-21 06:31:24
tools/emacs: config isearch a little bit…
From https://blog.chmouel.com/posts/emacs-isearch/. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 5fe6acb
tools/emacs/config/config-completion.el
@@ -10,6 +10,7 @@
   ("M-s M-b" . consult-buffer)
   ("M-s M-f" . consult-find)
   ("M-s M-g" . consult-grep)
+  ("M-s M-r" . consult-ripgrep)
   ("M-s M-h" . consult-history)
   ("M-s M-i" . consult-imenu)
   ("M-s M-l" . consult-line)
tools/emacs/config/config-navigating.el
@@ -56,7 +56,8 @@
   :bind (("C-c j w" . avy-goto-word-1)
          ("C-c j b" . avy-pop-mark)
          ("C-c j t" . avy-goto-char-timer)
-         ("C-c j l" . avy-goto-line)))
+         ("C-c j l" . avy-goto-line)
+	 (:map isearch-mode-map ("C-j" . avy-isearch))))
 
 (use-package mwim
   :unless noninteractive
tools/emacs/config/config-search.el
@@ -7,6 +7,24 @@
 (use-package isearch
   :unless noninteractive
   :config
+  (defun my-project-search-from-isearch ()
+    (interactive)
+    (let ((query (if isearch-regexp
+               isearch-string
+             (regexp-quote isearch-string))))
+      (isearch-update-ring isearch-string isearch-regexp)
+      (let (search-nonincremental-instead)
+        (ignore-errors (isearch-done t t)))
+      (project-find-regexp query)))
+  (defun my-occur-from-isearch ()
+    (interactive)
+    (let ((query (if isearch-regexp
+		     isearch-string
+		   (regexp-quote isearch-string))))
+      (isearch-update-ring isearch-string isearch-regexp)
+      (let (search-nonincremental-instead)
+        (ignore-errors (isearch-done t t)))
+      (occur query)))
   (setq-default search-whitespace-regexp ".*?"
                 isearch-lax-whitespace t
                 isearch-regexp-lax-whitespace nil
@@ -49,6 +67,9 @@ confines of word boundaries (e.g. multiple words)."
     (when isearch-other-end (goto-char isearch-other-end)))
   :bind (("M-s M-o" . multi-occur)
          :map isearch-mode-map
+	 ("C-o" . my-occur-from-isearch)
+	 ("C-f" . my-project-search-from-isearch)
+	 ("C-d" . isearch-forward-symbol-at-point)
          ("DEL" . contrib/isearchp-remove-failed-part-or-last-char)
          ("<C-return>" . contrib/isearch-done-opposite-end)))
 ;; -UseISearch