help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatically highlight all same occurrence of same stuff which has


From: Philip Kaludercic
Subject: Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
Date: Sun, 21 May 2023 07:17:26 +0000

Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> Hi here,
>
> In an Emacs buffer, I want to let it automatically highlight all same
> occurrence of some stuff which has been currently marked/selected.
>
> Say, I have the following:
>
> foo ...
> .. bar...
> baz foo
>
> Then when I select one of the `foo` above, the two `foo`s will be
> highlighted automatically. Any tips for achieving this?

I have this command

--8<---------------cut here---------------start------------->8---
;;;; Search the selected region
(defun site/isearch-region (start end)
  "Start isearch with the contents between START and END."
  (interactive (if (use-region-p)
                   (list (region-beginning) (region-end))
                 (user-error "No region")))
  (when (and start end)
    (deactivate-mark)
    (isearch-mode t)
    (isearch-yank-string (buffer-substring start end))))

(global-set-key (kbd "M-s M-s") #'site/isearch-region)
--8<---------------cut here---------------end--------------->8---

that searches for whatever is selected.  That also highlights every
occurrence.

> Regards,
> Zhao



reply via email to

[Prev in Thread] Current Thread [Next in Thread]