[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Try to understand the ora-company-number function again.
From: |
Hongyi Zhao |
Subject: |
Re: Try to understand the ora-company-number function again. |
Date: |
Tue, 26 Oct 2021 22:56:22 +0800 |
On Tue, Oct 26, 2021 at 4:20 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > ("<tab>" . hz-company-search-toggle)
> > ("<return>" . company-abort)
>
> I write tab "\t" and return "\r" but I don't know what the
> difference is, if any ...
>
> > :config
> > (setq company-tooltip-limit 10)
> > (defun hz-company-complete-number ()
> > "Convert the company-quick-access-keys to the candidates' row
> > NUMBER visible on the tooltip,
> > and then feed it to `company-complete-number' to quickly select
> > and insert company candidates.
> > If the currently entered character is belongs to
>
> is/belongs to
If the currently entered character is one of the
company-quick-access-keys and a part of the candidates at the same
time,
>
> > company-quick-access-keys and a part of the candidate simultaneously,
> > append it to the currently entered string to construct
> > new company-prefix."
>
> a new
OK. Agree with you.
>
> > (company-complete-number
> > (cond
> > ((equal k "1") 1)
> > ((equal k "2") 2)
> > ((equal k "3") 3)
> > ((equal k "4") 4)
> > ((equal k "5") 5)
> > ((equal k "6") 6)
> > ((equal k "7") 7)
> > ((equal k "8") 8)
> > ((equal k "9") 9)
> > ((equal k "0") 10)
>
> That doesn't look good to me, you can do
> `string-to-number wither either
> (string-to-number "9")
> (string-to-number "0") I guess
I forgot to simplify the above section in the case of only using
digits as the company-quick-access-keys. The following should be
enough [1]:
(company-complete-number
(if (equal k "0")
10
(string-to-number k)))
[1]
https://github.com/abo-abo/oremacs/blob/0c5f3284acedc966948cbb930e779af5189fd54e/modes/ora-company.el#L36
> > (let ((c-a-map company-active-map)
> > (c-s-map company-search-map))
> > (mapc (lambda (x)
> > (define-key c-a-map (format "%s" x) #'hz-company-complete-number))
> > '(1 2 3 4 5 6 7 8 9 0))
> > (mapc (lambda (x)
> > (define-key c-s-map (format "%s" x) #'hz-company-complete-number))
> > '(1 2 3 4 5 6 7 8 9 0)))
>
> Cl-loop for with i as an Iterator from 1 to 10 ...
>
> Also put this in the `let' clause so can be reused by us
Tried the following methods, but it didn't work:
(let ((c-a-map company-active-map)
(c-s-map company-search-map))
(cl-loop for x in (number-sequence 0 9)
do ((define-key c-a-map (format "%s" x) #'hz/company-complete-number)))
(cl-loop for x in (number-sequence 0 9)
do ((define-key c-s-map (format "%s" x) #'hz/company-complete-number)))
)
HZ
- Try to understand the ora-company-number function again., Hongyi Zhao, 2021/10/21
- Re: Try to understand the ora-company-number function again., Hongyi Zhao, 2021/10/21
- Re: Try to understand the ora-company-number function again., Hongyi Zhao, 2021/10/21
- Re: Try to understand the ora-company-number function again., Hongyi Zhao, 2021/10/21
- Re: Try to understand the ora-company-number function again., Hongyi Zhao, 2021/10/21
- Re: Try to understand the ora-company-number function again., Hongyi Zhao, 2021/10/21
- Re: Try to understand the ora-company-number function again., Hongyi Zhao, 2021/10/21
- Re: Try to understand the ora-company-number function again., Hongyi Zhao, 2021/10/26
- Re: Try to understand the ora-company-number function again., Emanuel Berg, 2021/10/26
- Re: Try to understand the ora-company-number function again.,
Hongyi Zhao <=
- Re: Try to understand the ora-company-number function again., Emanuel Berg, 2021/10/27