* Use Vertico + consult to do the search for an exact word.
@ 2023-05-31 23:27 Hongyi Zhao
2023-06-01 6:50 ` Tassilo Horn
0 siblings, 1 reply; 7+ messages in thread
From: Hongyi Zhao @ 2023-05-31 23:27 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 702 bytes --]
Hi here,
In Emacs, I use Vertico + consult to do the in-buffer and minibuffer
search and bind
bound the command `consult-line' to M-s l.
What puzzles me is that this cannot let me search for an exact word.
For example, if I want to sear all the occurrences of the word `id',
the result obtained is shown in the attached file, which obviously is
not what I want.
How to achieve my goal based on Vertico + consult for utilizing the
more intuitive minibuffer display?
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
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 171979 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use Vertico + consult to do the search for an exact word.
2023-05-31 23:27 Use Vertico + consult to do the search for an exact word Hongyi Zhao
@ 2023-06-01 6:50 ` Tassilo Horn
2023-06-01 7:36 ` Hongyi Zhao
0 siblings, 1 reply; 7+ messages in thread
From: Tassilo Horn @ 2023-06-01 6:50 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> In Emacs, I use Vertico + consult to do the in-buffer and minibuffer
> search and bind bound the command `consult-line' to M-s l.
>
> What puzzles me is that this cannot let me search for an exact word.
> For example, if I want to sear all the occurrences of the word `id',
> the result obtained is shown in the attached file, which obviously is
> not what I want.
>
> How to achieve my goal based on Vertico + consult for utilizing the
> more intuitive minibuffer display?
I don't use consult myself but I guess the search string is a regular
expression. So when you want to search for an exact word, use \bid\b to
find all occurrences of the word id.
See (info "(elisp) Regexp Backslash") for details:
--8<---------------cut here---------------start------------->8---
‘\b’
matches the empty string, but only at the beginning or end of a
word. Thus, ‘\bfoo\b’ matches any occurrence of ‘foo’ as a
separate word. ‘\bballs?\b’ matches ‘ball’ or ‘balls’ as a
separate word.
‘\b’ matches at the beginning or end of the buffer (or string)
regardless of what text appears next to it.
--8<---------------cut here---------------end--------------->8---
HTH,
Tassilo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use Vertico + consult to do the search for an exact word.
2023-06-01 6:50 ` Tassilo Horn
@ 2023-06-01 7:36 ` Hongyi Zhao
2023-06-01 9:47 ` Tassilo Horn
0 siblings, 1 reply; 7+ messages in thread
From: Hongyi Zhao @ 2023-06-01 7:36 UTC (permalink / raw)
To: Tassilo Horn; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1682 bytes --]
On Thu, Jun 1, 2023 at 2:54 PM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > In Emacs, I use Vertico + consult to do the in-buffer and minibuffer
> > search and bind bound the command `consult-line' to M-s l.
> >
> > What puzzles me is that this cannot let me search for an exact word.
> > For example, if I want to sear all the occurrences of the word `id',
> > the result obtained is shown in the attached file, which obviously is
> > not what I want.
> >
> > How to achieve my goal based on Vertico + consult for utilizing the
> > more intuitive minibuffer display?
>
> I don't use consult myself but I guess the search string is a regular
> expression. So when you want to search for an exact word, use \bid\b to
> find all occurrences of the word id.
I've tried this trick, but it cannot match the results like `$id$', as
shown in the attached screenshot, from where you can see that the
entry indexed by the circle numbered 1 doesn't appear in the
minibuffer's matching list.
> See (info "(elisp) Regexp Backslash") for details:
>
> --8<---------------cut here---------------start------------->8---
> ‘\b’
> matches the empty string, but only at the beginning or end of a
> word. Thus, ‘\bfoo\b’ matches any occurrence of ‘foo’ as a
> separate word. ‘\bballs?\b’ matches ‘ball’ or ‘balls’ as a
> separate word.
>
> ‘\b’ matches at the beginning or end of the buffer (or string)
> regardless of what text appears next to it.
> --8<---------------cut here---------------end--------------->8---
>
> HTH,
> Tassilo
Regards,
Zhao
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 310052 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use Vertico + consult to do the search for an exact word.
2023-06-01 7:36 ` Hongyi Zhao
@ 2023-06-01 9:47 ` Tassilo Horn
2023-06-01 9:59 ` Hongyi Zhao
0 siblings, 1 reply; 7+ messages in thread
From: Tassilo Horn @ 2023-06-01 9:47 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>> I don't use consult myself but I guess the search string is a regular
>> expression. So when you want to search for an exact word, use \bid\b
>> to find all occurrences of the word id.
>
> I've tried this trick, but it cannot match the results like `$id$', as
> shown in the attached screenshot, from where you can see that the
> entry indexed by the circle numbered 1 doesn't appear in the
> minibuffer's matching list.
That's because $ is a word-character in the syntax-table of the mode you
are using in that buffer. You can try
\([^a-zA-Z]\|\b\)id\([^a-zA-Z]\|\b\) which should also find $id$ and
1id02.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use Vertico + consult to do the search for an exact word.
2023-06-01 9:47 ` Tassilo Horn
@ 2023-06-01 9:59 ` Hongyi Zhao
2023-06-01 18:45 ` Tassilo Horn
0 siblings, 1 reply; 7+ messages in thread
From: Hongyi Zhao @ 2023-06-01 9:59 UTC (permalink / raw)
To: Tassilo Horn; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 972 bytes --]
On Thu, Jun 1, 2023 at 5:52 PM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> >> I don't use consult myself but I guess the search string is a regular
> >> expression. So when you want to search for an exact word, use \bid\b
> >> to find all occurrences of the word id.
> >
> > I've tried this trick, but it cannot match the results like `$id$', as
> > shown in the attached screenshot, from where you can see that the
> > entry indexed by the circle numbered 1 doesn't appear in the
> > minibuffer's matching list.
>
> That's because $ is a word-character in the syntax-table of the mode you
> are using in that buffer. You can try
> \([^a-zA-Z]\|\b\)id\([^a-zA-Z]\|\b\) which should also find $id$ and
> 1id02.
Yes. This works, as shown in the attached screenshot. But the input is
rather cumbersome. Are there more efficient/concise regexp patterns
for this goal?
> Bye,
> Tassilo
Regards,
Zhao
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 220060 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use Vertico + consult to do the search for an exact word.
2023-06-01 9:59 ` Hongyi Zhao
@ 2023-06-01 18:45 ` Tassilo Horn
2023-06-02 1:53 ` Hongyi Zhao
0 siblings, 1 reply; 7+ messages in thread
From: Tassilo Horn @ 2023-06-01 18:45 UTC (permalink / raw)
To: Hongyi Zhao; +Cc: help-gnu-emacs
Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>> That's because $ is a word-character in the syntax-table of the mode
>> you are using in that buffer. You can try
>> \([^a-zA-Z]\|\b\)id\([^a-zA-Z]\|\b\) which should also find $id$ and
>> 1id02.
>
> Yes. This works, as shown in the attached screenshot. But the input is
> rather cumbersome. Are there more efficient/concise regexp patterns
> for this goal?
Well, \bid\b should be enough, actually. I don't understand why it
seems like the $s in $id$ in your latex buffer have word syntax. I've
just tried both the stock latex-mode and AUCTeX and with both the $s
don't have word syntax.
Could you please put point on such a $ and report the output of M-x
describe-char RET? I'm mostly interested in the line
syntax: $ which means: math
which might be
syntax: w which means: word
on your side for whatever reason.
Also, please try if regexp isearch works as expected, i.e., C-u C-s
\bid\b should also find the id in $id$. If you both have $ in math
syntax and isearch works but consult doesn't, then I'd ask at the
consult community.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Use Vertico + consult to do the search for an exact word.
2023-06-01 18:45 ` Tassilo Horn
@ 2023-06-02 1:53 ` Hongyi Zhao
0 siblings, 0 replies; 7+ messages in thread
From: Hongyi Zhao @ 2023-06-02 1:53 UTC (permalink / raw)
To: Tassilo Horn; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]
On Fri, Jun 2, 2023 at 2:56 AM Tassilo Horn <tsdh@gnu.org> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> >> That's because $ is a word-character in the syntax-table of the mode
> >> you are using in that buffer. You can try
> >> \([^a-zA-Z]\|\b\)id\([^a-zA-Z]\|\b\) which should also find $id$ and
> >> 1id02.
> >
> > Yes. This works, as shown in the attached screenshot. But the input is
> > rather cumbersome. Are there more efficient/concise regexp patterns
> > for this goal?
>
> Well, \bid\b should be enough, actually. I don't understand why it
> seems like the $s in $id$ in your latex buffer have word syntax. I've
> just tried both the stock latex-mode and AUCTeX and with both the $s
> don't have word syntax.
>
> Could you please put point on such a $ and report the output of M-x
> describe-char RET? I'm mostly interested in the line
>
> syntax: $ which means: math
>
> which might be
>
> syntax: w which means: word
>
> on your side for whatever reason.
See below:
;;; output begin here
position: 14582 of 24975 (58%), column: 6
character: $ (displayed as $) (codepoint 36, #o44, #x24)
charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x24
script: latin
syntax: $ which means: math
category: .:Base, a:ASCII, l:Latin, r:Roman
to input: type "C-x 8 RET 24" or "C-x 8 RET DOLLAR SIGN"
buffer code: #x24
file code: #x24 (encoded by coding system utf-8-unix)
display: by this font (glyph code):
ftcrhb:-PfEd-DejaVuSansMono Nerd Font
Mono-regular-normal-normal-*-20-*-*-*-m-0-iso10646-1 (#x07)
Character code properties: customize what to show
name: DOLLAR SIGN
general-category: Sc (Symbol, Currency)
decomposition: (36) ('$')
There are text properties here:
face font-latex-math-face
fontified t
wrap-prefix " "
;;; output end here
> Also, please try if regexp isearch works as expected, i.e., C-u C-s
> \bid\b should also find the id in $id$. If you both have $ in math
> syntax and isearch works but consult doesn't, then I'd ask at the
> consult community.
This method works, as shown in the attached screenshot.
> Bye,
> Tassilo
Regards,
Zhao
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 53660 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-06-02 1:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31 23:27 Use Vertico + consult to do the search for an exact word Hongyi Zhao
2023-06-01 6:50 ` Tassilo Horn
2023-06-01 7:36 ` Hongyi Zhao
2023-06-01 9:47 ` Tassilo Horn
2023-06-01 9:59 ` Hongyi Zhao
2023-06-01 18:45 ` Tassilo Horn
2023-06-02 1:53 ` Hongyi Zhao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).