conf-isearch.el 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ;;; Code:
  2. (require 'anzu)
  3. (global-anzu-mode t)
  4. ;; Faces
  5. (set-face-attribute 'anzu-mode-line nil
  6. :foreground "cyan" :weight 'bold)
  7. ;; Hooks
  8. (add-hook 'isearch-mode-end-hook 'distopico:goto-match-beginning)
  9. ;; Functions
  10. (defun distopico:goto-match-beginning ()
  11. "Position of the Cursor after Searching."
  12. (when (and isearch-forward isearch-other-end)
  13. (goto-char isearch-other-end)))
  14. (defadvice isearch-exit (after distopico:goto-match-beginning activate)
  15. "Go to beginning of match."
  16. (when (and isearch-forward isearch-other-end)
  17. (goto-char isearch-other-end)))
  18. (defvar distopico:isearch-initial-string nil)
  19. (defun distopico:isearch-set-initial-string ()
  20. "I-search with initial contents."
  21. (remove-hook 'isearch-mode-hook 'distopico:isearch-set-initial-string)
  22. (setq isearch-string distopico:isearch-initial-string)
  23. (isearch-search-and-update))
  24. (defun distopico:isearch-forward-at-point (&optional regexp-p no-recursive-edit)
  25. "Interactive search forward for the symbol at point.
  26. Options `REGEXP-P' and `NO-RECURSIVE-EDIT',
  27. DEPRECATED: Emacs 26 has `isearch-forward-symbol-at-point'."
  28. (interactive "P\np")
  29. (if regexp-p (isearch-forward regexp-p no-recursive-edit)
  30. (let* ((end (progn (skip-syntax-forward "w_") (point)))
  31. (begin (progn (skip-syntax-backward "w_") (point))))
  32. (if (eq begin end)
  33. (isearch-forward regexp-p no-recursive-edit)
  34. (setq distopico:isearch-initial-string (buffer-substring begin end))
  35. (add-hook 'isearch-mode-hook 'distopico:isearch-set-initial-string)
  36. (isearch-forward regexp-p no-recursive-edit)))))
  37. (provide 'conf-isearch)