From 5d0709ea7d33eebbde01a83918a37db4039b08d1 Mon Sep 17 00:00:00 2001 From: noa@gaiwan.org Date: Fri, 14 Jun 2024 11:03:59 +0000 Subject: Replace ctrlf with isearch --- emacs/init.el | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/emacs/init.el b/emacs/init.el index 8b77b4d..2d81756 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -722,14 +722,42 @@ The misspelled word is taken from OVERLAY. WORD is the corrected word." ;;; Search in buffer ;; Isearch is good, but it has some rough edges. The easiest way forward was just to use ctrlf, which fixes most of them. -(use-package ctrlf :ensure t) -(global-set-key [remap isearch-forward] #'ctrlf-forward-default) -(global-set-key [remap isearch-backward] #'ctrlf-backward-default) -(global-set-key [remap isearch-forward-regexp] #'ctrlf-forward-alternate) -(global-set-key [remap isearch-backward-regexp] #'ctrlf-backward-alternate) +;; (use-package ctrlf :ensure t) +;; (global-set-key [remap isearch-forward] #'ctrlf-forward-default) +;; n(global-set-key [remap isearch-backward] #'ctrlf-backward-default) +;; (global-set-key [remap isearch-forward-regexp] #'ctrlf-forward-alternate) +;; (global-set-key [remap isearch-backward-regexp] #'ctrlf-backward-alternate) + +;; (use-package casual-isearch :ensure t) +;; (define-key isearch-mode-map (kbd "") #'casual-isearch-tmenu) +(define-key isearch-mode-map (kbd "") #'cc-isearch-menu-transient) ;; It makes more sense to go to the start of the match, because i start searching where i want to be. -(setopt ctrlf-go-to-end-of-match nil ) +(defun isearch-exit-at-front () + "always exit isearch, at the front of search match." + (interactive) + (isearch-exit) + (when isearch-forward + (goto-char isearch-other-end))) +(defun isearch-exit-at-end () + "Always exit isearch, at the end of search match." + (interactive) + (isearch-exit) + (when (not isearch-forward) + (goto-char isearch-other-end))) + +(define-key isearch-mode-map (kbd "") #'isearch-exit-at-front) +(define-key isearch-mode-map (kbd "C-") #'isearch-exit-at-end) +(define-key isearch-mode-map (kbd "M-<") #'isearch-beginning-of-buffer) +(define-key isearch-mode-map (kbd "M->") #'isearch-end-of-buffer) +;; Make isearch always quit on C-g +(define-key isearch-mode-map (kbd "C-g") #'isearch-cancel) +(define-key isearch-mode-map (kbd "C-o") #'isearch-occur) +(setopt search-whitespace-regexp ".*?") +(setopt isearch-lax-whitespace t) +(setopt isearch-lazy-count t) + +;; (add-hook 'occur-mode-hook #'hl-line-mode) (global-set-key (kbd "M-o") 'other-window) (global-set-key (kbd "C-x k") 'kill-this-buffer) -- cgit 1.4.1-2-gfad0