From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Try to understand the ora-company-number function again. Date: Thu, 21 Oct 2021 14:54:37 +0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2787"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 21 08:56:20 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdRzw-0000Vj-7T for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 21 Oct 2021 08:56:20 +0200 Original-Received: from localhost ([::1]:59640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdRzu-000718-Qo for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 21 Oct 2021 02:56:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdRyV-000710-IC for help-gnu-emacs@gnu.org; Thu, 21 Oct 2021 02:54:51 -0400 Original-Received: from mail-ua1-x92c.google.com ([2607:f8b0:4864:20::92c]:43847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mdRyT-000272-3a for help-gnu-emacs@gnu.org; Thu, 21 Oct 2021 02:54:51 -0400 Original-Received: by mail-ua1-x92c.google.com with SMTP id i22so11252465ual.10 for ; Wed, 20 Oct 2021 23:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=Wmu8x4A4uzGy+t/HvYLL4prMOChRG9aEJ6cckAw2Tz4=; b=nYoI8ks7Xdmix5NFYPVntnYB/VOHYRNg6H+MXUmYZaaEEIobjZ5C+ZRSeLgjisYs4b 2okLu7s/Q+FuFOWvdxIZ2YUVTQeE7coQfoPuY5dlMkp84TVWl4Ip0hntZGZ7Mqnwybvw XSYdBNkvEbyaJpTcyLT8GEjqhtqySr2KqYnRP9Yc80QyKX4FLa07WEwkwBDrB5V5Fb2D 33TWZwE2x8QSqKxrPW6MrsCn3ptO1DiAVFST2t0BJCFUtmDvlgaEk4tPDHIUKKTYugsB GxXPO9iPIVwY8kPw82FE7tI4w7d+IUZAQiZr/zSidf2dIrF5BLRT6FYigQpXuFzFTtHj 3Hfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Wmu8x4A4uzGy+t/HvYLL4prMOChRG9aEJ6cckAw2Tz4=; b=XnRfd/rcT59TFb9wF+z5JibA+lPtO14FoKMrWwG7B6hkE826++3kNvKH7KrizShFJy WQhz42NJbMgSFgL0k49hVJMjUrjaQymZINsMFKeU8pZADWS2OLodDatAbSUwuBnwjbOr ToNFI8z0mo74BOuYub6aivGer9JFskxDEI8HfpaY9ZbU+JCZoaDqF/zLEs/BMcGC8cWM RTxVnFIXN4CSW1QY6agyDrNtoEwOx7CtLuqYORub23oJRuOBqnTRbXNKE6tz22CYHRip GJtZuic79vstgTdXoDXExBUmhJelQkJLlG3FSAQbu8vxOxVI2n734PFWZnG56VAubiJJ fmzQ== X-Gm-Message-State: AOAM533RM9LBnlDycVcgGGDVOAQkGpQHJlI+crL3Cy+WQoF1QekhuOwC sTRxjbgJPyjjNr+73tOuycEfZfQjRNeSzSX3E45rBYgcZMAw8q0w X-Google-Smtp-Source: ABdhPJx0JE7eLScbAjdYtyMyN03Rw4CRERKD9HZZo0XItzFIYoPQlE7WJQFIiiLbsJRUf7KBVHd26g1nqhA+2yI2TLY= X-Received: by 2002:a05:6130:328:: with SMTP id ay40mr4561277uab.60.1634799287710; Wed, 20 Oct 2021 23:54:47 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::92c; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x92c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:133938 Archived-At: 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 Theory and Simulation of Materials Hebei Vocational University of Technology and Engineering No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province