[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 16:15:09 +0800 |
On Tue, Oct 5, 2021 at 3:47 PM Tassilo Horn <tsdh@gnu.org> wrote:
>
>
> >> I don't know how that candidate selection by number actually works
> >> but the advice arranges that the original `company--good-prefix-p' is
> >> only called if
> >>
> >> (and (stringp prefix) (string-match-p "\\`[0-9]+\\'" prefix))
> >>
> >> is nil and that happens only if the prefix doesn't start with a
> >> number. So I'd suggest it's essential to the use-case.
> >
> > Thanks for analyzing the complex advice combination function - if I
> > could call it that way.
> >
> >> > 2. Extend the digits to a more wide range with digits letters, so that
> >> > I can select and insert more candidates, as we've discussed here [1].
> >>
> >> The above regexp would already match 9281 but probably pressing 9
> >> already selects the 9th candidate and you cannot type more?
> >
> > I still don't quite understand what you mean above. The currently
> > implemented method can match 0-9, by mapping 0 to 10, therefore, we
> > can select 10 candidates by number.
>
> The advice suppresses calls to `company--good-prefix-p'
Here [1] comes the definition of `company--good-prefix-p':
(defun company--good-prefix-p (prefix)
(and (stringp (company--prefix-str prefix)) ;excludes 'stop
(or (eq (cdr-safe prefix) t)
(let ((len (or (cdr-safe prefix) (length prefix))))
(if company--manual-prefix
(or (not company-abort-manual-when-too-short)
;; Must not be less than minimum or initial length.
(>= len (min company-minimum-prefix-length
(length company--manual-prefix))))
(>= len company-minimum-prefix-length))))))
[1]
https://github.com/company-mode/company-mode/blob/4c08ef468678bbf3b3c9e750f6e694eea1aa8423/company.el#L1974-L1983
> 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]+"?
> 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?
> 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.
HZ
- Re: The definition of orig-fn., (continued)
- Re: The definition of orig-fn., Hongyi Zhao, 2021/10/04
- Re: The definition of orig-fn., Tassilo Horn, 2021/10/04
- Re: The definition of orig-fn., Hongyi Zhao, 2021/10/04
- Re: The definition of orig-fn., Tassilo Horn, 2021/10/04
- Re: The definition of orig-fn., Hongyi Zhao, 2021/10/04
- Re: The definition of orig-fn., Tassilo Horn, 2021/10/05
- Re: The definition of orig-fn., Emanuel Berg, 2021/10/05
- Re: The definition of orig-fn., Hongyi Zhao, 2021/10/05
- Re: The definition of orig-fn., Hongyi Zhao, 2021/10/05
- Re: The definition of orig-fn., Tassilo Horn, 2021/10/05
- Re: The definition of orig-fn.,
Hongyi Zhao <=
- Re: The definition of orig-fn., Tassilo Horn, 2021/10/05
- Re: The definition of orig-fn., Hongyi Zhao, 2021/10/05
- Re: The definition of orig-fn., Tassilo Horn, 2021/10/05
- Re: The definition of orig-fn., Tassilo Horn, 2021/10/05
- Re: The definition of orig-fn., Emanuel Berg, 2021/10/05
- Re: The definition of orig-fn., Hongyi Zhao, 2021/10/05
- Re: The definition of orig-fn., Emanuel Berg, 2021/10/05
- Re: The definition of orig-fn., Emanuel Berg, 2021/10/05
- Re: The definition of orig-fn., Hongyi Zhao, 2021/10/05
Re: The definition of orig-fn., Emanuel Berg, 2021/10/04