diff --git a/init.el b/init.el index 69d94b6..fe84f5c 100644 --- a/init.el +++ b/init.el @@ -810,6 +810,18 @@ debian, and derivatives). On most it's 'fd'.") "M-c" 'mdrp/toggle-case "c" 'mdrp/toggle-case) :config + ;; use current region as first search + (defadvice isearch-mode (around isearch-mode-default-string (forward &optional regexp op-fun recursive-edit word-p) activate) + (if (and transient-mark-mode mark-active (not (eq (mark) (point)))) + (progn + (isearch-update-ring (buffer-substring-no-properties (mark) (point))) + (deactivate-mark) + ad-do-it + (if (not forward) + (isearch-repeat-backward) + (goto-char (mark)) + (isearch-repeat-forward))) + ad-do-it)) (defun mdrp/toggle-case () (interactive) (setq case-fold-search (not case-fold-search)) diff --git a/init.org b/init.org index a1b40eb..1645f93 100644 --- a/init.org +++ b/init.org @@ -1502,6 +1502,18 @@ This part will load packages that are useful for emacs and are not specific to m "M-c" 'mdrp/toggle-case "c" 'mdrp/toggle-case) :config + ;; use current region as first search + (defadvice isearch-mode (around isearch-mode-default-string (forward &optional regexp op-fun recursive-edit word-p) activate) + (if (and transient-mark-mode mark-active (not (eq (mark) (point)))) + (progn + (isearch-update-ring (buffer-substring-no-properties (mark) (point))) + (deactivate-mark) + ad-do-it + (if (not forward) + (isearch-repeat-backward) + (goto-char (mark)) + (isearch-repeat-forward))) + ad-do-it)) (defun mdrp/toggle-case () (interactive) (setq case-fold-search (not case-fold-search))