unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Try to understand the ora-company-number function again.
@ 2021-10-21  6:54 Hongyi Zhao
  2021-10-21  6:59 ` Hongyi Zhao
  2021-10-21  7:11 ` Hongyi Zhao
  0 siblings, 2 replies; 11+ messages in thread
From: Hongyi Zhao @ 2021-10-21  6:54 UTC (permalink / raw)
  To: help-gnu-emacs

I try to understand the  ora-company-number function [1] again:

(defun ora-company-number ()
"Forward to `company-complete-number'.

Unless the number is potentially part of the candidate.
In that case, insert the number."
(interactive)
(let* ((k (this-command-keys))
(re (concat "^" company-prefix k)))
(if (or (cl-find-if (lambda (s) (string-match re s))
company-candidates)
(> (string-to-number k)
(length company-candidates))
(looking-back "[0-9]+\\.[0-9]*" (line-beginning-position)))
(self-insert-command 1)
(company-complete-number
(if (equal k "0")
10
(string-to-number k))))))

I've figured out all the intention of the above code snippet except
the following line:

(looking-back "[0-9]+\\.[0-9]*" (line-beginning-position)

I can't understand why the regexp used here must be written in this
form. Any hints will be appreciated.

[1] https://github.com/abo-abo/oremacs/blob/0c5f3284acedc966948cbb930e779af5189fd54e/modes/ora-company.el#L22

Regards
-- 
Assoc. Prof. Hongyi 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] 11+ messages in thread

end of thread, other threads:[~2021-10-27 23:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-21  6:54 Try to understand the ora-company-number function again Hongyi Zhao
2021-10-21  6:59 ` Hongyi Zhao
2021-10-21  7:11 ` Hongyi Zhao
2021-10-21 10:48   ` Hongyi Zhao
2021-10-21 10:51     ` Hongyi Zhao
2021-10-21 14:00       ` Hongyi Zhao
2021-10-22  2:33         ` Hongyi Zhao
2021-10-26  5:19           ` Hongyi Zhao
2021-10-26  7:00             ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-26 14:56               ` Hongyi Zhao
2021-10-27 23:08                 ` Emanuel Berg via Users list for the GNU Emacs text editor

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).