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

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

Re: The definition of orig-fn.


From: Hongyi Zhao
Subject: Re: The definition of orig-fn.
Date: Tue, 5 Oct 2021 17:41:51 +0800

On Tue, Oct 5, 2021 at 5:10 PM Tassilo Horn <tsdh@gnu.org> wrote:
> >> if the prefix matches "\\`[0-9]+\\'" which would be true for 9281, too.
> >
> > I am puzzled why it is written in this form, to be more specific, why
> > not just use "[0-9]+"?
>
> See (info "(elisp) Regexp Backslash"), especially:
>
> --8<---------------cut here---------------start------------->8---
> ‘\`’
>      matches the empty string, but only at the beginning of the buffer
>      or string being matched against.
>
> ‘\'’
>      matches the empty string, but only at the end of the buffer or
>      string being matched against.
> --8<---------------cut here---------------end--------------->8---
>
> So it only matches if prefix is made up entirely of digits, not if the
> prefix contains some digit.

Thank you for letting me know about these Elisp-specific regexp
metacharacters, I just take it for granted that they are not any
metacharacters.


> >> That's why I've said, the regexp would allow multi-digit prefixes
> >
> > Do you mean that it should be more reasonable by removing the + symbol
> > in the regexp?
>
> If the selection can only be one single digit, it would make sense.  But
> no authorative answer from me who doesn't know the code.  I guess the
> author had a reason to add the + there.
>
> >> but probably the candidate selection by numeric key press doesn't
> >> because it triggers immediately when a numeric key is pressed.
> >
> > Insertion candidate by a numeric key is for convenience and
> > efficiency, so it must work the way you described above.
>
> No, not necessarily.  One could use prefixes generated by the DeBruijn
> sequence, see https://en.wikipedia.org/wiki/De_Bruijn_sequence.
>
> The avy package supports an `avy-style' called `'de-bruijn', and then
> you can get unique sequences triggering an action for any alphabet (like
> the digits).  Of course, that means that all candidates will get a
> "shortcut" of the same length, i.e., with just the letters 0 and 1
> available, you could select between 4 candidates using shortcut
> sequences 00, 01, 10, and 11.

Without further keyboard remapping, this scheme will require at least
two keystrokes to complete a candidate insertion. I think abo-abo's
customized function is just for solving this type of problem: One
keystroke for one candidate insertion.

> That's my commit which implemented that for avy:
> https://github.com/abo-abo/avy/commit/27b98bb73044cfe61233d065b8f06bd80cf4867b

Thank you for letting me know of this interesting feature.

HZ



reply via email to

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