* Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
@ 2023-05-21 0:47 Hongyi Zhao
2023-05-21 1:13 ` Michael Heerdegen
2023-05-21 7:17 ` Philip Kaludercic
0 siblings, 2 replies; 12+ messages in thread
From: Hongyi Zhao @ 2023-05-21 0:47 UTC (permalink / raw)
To: help-gnu-emacs
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?
Regards,
Zhao
--
Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-21 0:47 Automatically highlight all same occurrence of same stuff which has been currently marked/selected Hongyi Zhao
@ 2023-05-21 1:13 ` Michael Heerdegen
2023-05-21 1:44 ` Hongyi Zhao
2023-05-21 7:17 ` Philip Kaludercic
1 sibling, 1 reply; 12+ messages in thread
From: Michael Heerdegen @ 2023-05-21 1:13 UTC (permalink / raw)
To: help-gnu-emacs
Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> 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?
"high-lock.el" - in particular, M-x highlight-regexp ...? Should even
catch the region string as DEFAULT for the regexp (not regexp-quoted
though).
Michael.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-21 1:13 ` Michael Heerdegen
@ 2023-05-21 1:44 ` Hongyi Zhao
0 siblings, 0 replies; 12+ messages in thread
From: Hongyi Zhao @ 2023-05-21 1:44 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
On Sun, May 21, 2023 at 9:14 AM Michael Heerdegen
<michael_heerdegen@web.de> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > 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?
>
> "high-lock.el" - in particular, M-x highlight-regexp ...? Should even
> catch the region string as DEFAULT for the regexp (not regexp-quoted
> though).
The following packages do the trick:
(use-package idle-highlight-mode
:config (setq idle-highlight-idle-time 0.2)
(idle-highlight-global-mode)
;; :hook ((prog-mode text-mode) . idle-highlight-mode)
)
(use-package symbol-overlay
:config
(symbol-overlay-mode)
(global-set-key (kbd "M-i") 'symbol-overlay-put)
(global-set-key (kbd "M-n") 'symbol-overlay-switch-forward)
(global-set-key (kbd "M-p") 'symbol-overlay-switch-backward)
;; (global-set-key (kbd "<f7>") 'symbol-overlay-mode)
(global-set-key (kbd "<f8>") 'symbol-overlay-remove-all)
)
> Michael.
Zhao
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-21 0:47 Automatically highlight all same occurrence of same stuff which has been currently marked/selected Hongyi Zhao
2023-05-21 1:13 ` Michael Heerdegen
@ 2023-05-21 7:17 ` Philip Kaludercic
2023-05-22 11:16 ` Daniel Martín
1 sibling, 1 reply; 12+ messages in thread
From: Philip Kaludercic @ 2023-05-21 7:17 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-21 7:17 ` Philip Kaludercic
@ 2023-05-22 11:16 ` Daniel Martín
2023-05-25 13:27 ` Rudolf Adamkovič
0 siblings, 1 reply; 12+ messages in thread
From: Daniel Martín @ 2023-05-22 11:16 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: Hongyi Zhao, help-gnu-emacs
Philip Kaludercic <philipk@posteo.net> writes:
>
> I have this command
>
> ;;;; 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)
>
> that searches for whatever is selected. That also highlights every
> occurrence.
>
And, since Emacs 28.1, one can select the region and press M-s
M-. (`isearch-forward-thing-at-point`). By default, Emacs will try to
search for the active region first (see `isearch-forward-thing-at-point`
to customize this behavior).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-22 11:16 ` Daniel Martín
@ 2023-05-25 13:27 ` Rudolf Adamkovič
2023-05-25 14:29 ` Hongyi Zhao
2023-05-25 15:31 ` Daniel Martín
0 siblings, 2 replies; 12+ messages in thread
From: Rudolf Adamkovič @ 2023-05-25 13:27 UTC (permalink / raw)
To: Daniel Martín, Philip Kaludercic; +Cc: Hongyi Zhao, help-gnu-emacs
Daniel Martín <mardani29@yahoo.es> writes:
> And, since Emacs 28.1, one can select the region and press M-s
> M-. (`isearch-forward-thing-at-point`).
Or, simply M-s . (which is much better for touch typists).
Rudy
--
"The introduction of suitable abstractions is our only mental aid to
organize and master complexity."
-- Edsger Wybe Dijkstra, 1930-2002
Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-25 13:27 ` Rudolf Adamkovič
@ 2023-05-25 14:29 ` Hongyi Zhao
2023-05-25 14:35 ` tomas
2023-05-25 15:31 ` Daniel Martín
1 sibling, 1 reply; 12+ messages in thread
From: Hongyi Zhao @ 2023-05-25 14:29 UTC (permalink / raw)
To: Rudolf Adamkovič
Cc: Daniel Martín, Philip Kaludercic, help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
On Thu, May 25, 2023 at 9:27 PM Rudolf Adamkovič <salutis@me.com> wrote:
>
> Daniel Martín <mardani29@yahoo.es> writes:
>
> > And, since Emacs 28.1, one can select the region and press M-s
> > M-. (`isearch-forward-thing-at-point`).
>
> Or, simply M-s . (which is much better for touch typists).
Failed, as shown in the attached file.
> Rudy
Zhao
> --
> "The introduction of suitable abstractions is our only mental aid to
> organize and master complexity."
> -- Edsger Wybe Dijkstra, 1930-2002
>
> Rudolf Adamkovič <salutis@me.com> [he/him]
> Studenohorská 25
> 84103 Bratislava
> Slovakia
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 179257 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-25 14:29 ` Hongyi Zhao
@ 2023-05-25 14:35 ` tomas
0 siblings, 0 replies; 12+ messages in thread
From: tomas @ 2023-05-25 14:35 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 606 bytes --]
On Thu, May 25, 2023 at 10:29:20PM +0800, Hongyi Zhao wrote:
> On Thu, May 25, 2023 at 9:27 PM Rudolf Adamkovič <salutis@me.com> wrote:
> >
> > Daniel Martín <mardani29@yahoo.es> writes:
> >
> > > And, since Emacs 28.1, one can select the region and press M-s
> > > M-. (`isearch-forward-thing-at-point`).
> >
> > Or, simply M-s . (which is much better for touch typists).
>
> Failed, as shown in the attached file.
I can't currently look at images in mails, but what I do to search
selected is simply C-s C-y (i.e. yanking the selection into the
search term query).
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-25 13:27 ` Rudolf Adamkovič
2023-05-25 14:29 ` Hongyi Zhao
@ 2023-05-25 15:31 ` Daniel Martín
2023-05-26 11:47 ` Rudolf Adamkovič
1 sibling, 1 reply; 12+ messages in thread
From: Daniel Martín @ 2023-05-25 15:31 UTC (permalink / raw)
To: Rudolf Adamkovič; +Cc: Philip Kaludercic, Hongyi Zhao, help-gnu-emacs
Rudolf Adamkovič <salutis@me.com> writes:
> Daniel Martín <mardani29@yahoo.es> writes:
>
>> And, since Emacs 28.1, one can select the region and press M-s
>> M-. (`isearch-forward-thing-at-point`).
>
> Or, simply M-s . (which is much better for touch typists).
>
No, it's not the same command. M-s . will always search for the symbol
at point, but it won't take the region into account.
M-s M-. is an Emacs 28 generalization of M-s ., for things other than
symbols.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-25 15:31 ` Daniel Martín
@ 2023-05-26 11:47 ` Rudolf Adamkovič
2023-05-26 12:26 ` Hongyi Zhao
0 siblings, 1 reply; 12+ messages in thread
From: Rudolf Adamkovič @ 2023-05-26 11:47 UTC (permalink / raw)
To: Daniel Martín; +Cc: Philip Kaludercic, Hongyi Zhao, help-gnu-emacs
Daniel Martín <mardani29@yahoo.es> writes:
> No, it's not the same command. M-s . will always search for the symbol
> at point, but it won't take the region into account.
>
> M-s M-. is an Emacs 28 generalization of M-s ., for things other than
> symbols.
Oh, thank you for the heads up! TIL and notes updated.
Rudy
--
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947
Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Automatically highlight all same occurrence of same stuff which has been currently marked/selected.
2023-05-26 11:47 ` Rudolf Adamkovič
@ 2023-05-26 12:26 ` Hongyi Zhao
2023-05-26 12:38 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Hongyi Zhao @ 2023-05-26 12:26 UTC (permalink / raw)
To: Rudolf Adamkovič
Cc: Daniel Martín, Philip Kaludercic, help-gnu-emacs
On Fri, May 26, 2023 at 7:47 PM Rudolf Adamkovič <salutis@me.com> wrote:
>
> Daniel Martín <mardani29@yahoo.es> writes:
>
> > No, it's not the same command. M-s . will always search for the symbol
> > at point, but it won't take the region into account.
> >
> > M-s M-. is an Emacs 28 generalization of M-s ., for things other than
> > symbols.
>
> Oh, thank you for the heads up! TIL and notes updated.
What's the meaning of TIL?
> Rudy
Zhao
> --
> "It is no paradox to say that in our most theoretical moods we may be
> nearest to our most practical applications."
> -- Alfred North Whitehead, 1861-1947
>
> Rudolf Adamkovič <salutis@me.com> [he/him]
> Studenohorská 25
> 84103 Bratislava
> Slovakia
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-05-26 12:38 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-21 0:47 Automatically highlight all same occurrence of same stuff which has been currently marked/selected Hongyi Zhao
2023-05-21 1:13 ` Michael Heerdegen
2023-05-21 1:44 ` Hongyi Zhao
2023-05-21 7:17 ` Philip Kaludercic
2023-05-22 11:16 ` Daniel Martín
2023-05-25 13:27 ` Rudolf Adamkovič
2023-05-25 14:29 ` Hongyi Zhao
2023-05-25 14:35 ` tomas
2023-05-25 15:31 ` Daniel Martín
2023-05-26 11:47 ` Rudolf Adamkovič
2023-05-26 12:26 ` Hongyi Zhao
2023-05-26 12:38 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.