From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: How to read an integer from the minibuffer Date: Tue, 16 Nov 2021 18:52:57 +0700 Message-ID: References: <87ee7nqomk.fsf@mbork.pl> <875ysxrj0v.fsf@mbork.pl> <877dd835cp.fsf@zoho.eu> <87y25o1lv4.fsf@zoho.eu> <87ilws1gcf.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36555"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 16 12:54:07 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 1mmx2M-0009Iu-P7 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 12:54:06 +0100 Original-Received: from localhost ([::1]:52756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmx2L-00062U-KW for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 06:54:05 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmx1W-00060u-E3 for help-gnu-emacs@gnu.org; Tue, 16 Nov 2021 06:53:14 -0500 Original-Received: from [2607:f8b0:4864:20::931] (port=38591 helo=mail-ua1-x931.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mmx1R-0003Pb-V6 for help-gnu-emacs@gnu.org; Tue, 16 Nov 2021 06:53:14 -0500 Original-Received: by mail-ua1-x931.google.com with SMTP id w23so18811203uao.5 for ; Tue, 16 Nov 2021 03:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=bc/u0oYLgg6FZTyjc9L6PvhAf1SYqfhc/eE7A2V1sG8=; b=SaxJnY2JqWhmxeEwkky7h7qa5BFn699tUkWTWrJzaVey1L261V+kTXocsA8AREdP/Q fquNIBC4di7B4xjxlnAdBEyktyj810D7IHKv07VIcUNbwAS2dnsY72w9xR26iT4LQ2MY 51oVXiQRGqovAqvAWfchFF/OlImF1sYCZiCs9lwwNfcTS362blQTNUXoC2lQDyfxucrk wllJjZFviZzkofIaHxG3HfIUfx0rTINVzOqOqBjX78Pp+Boa3Uns3UtfiYmoDFaf3S/q 4DzFGdcHGE1ObxOMBw2IJkGR5KlKzd2dpimymqpdpxo+UNdFTzP+dkNcU3cH0vEL21bd Qziw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=bc/u0oYLgg6FZTyjc9L6PvhAf1SYqfhc/eE7A2V1sG8=; b=NH74YwXFu+AId4hdtX/AGZIktO0w8bJTOH0IxLsHrK3HN2PXGYhdu9IUmal0R6qDMN VrEShu8dDLNVOW0t2CymalgWyOWOT5dctRBquywuvBtbhZvRM9uIvAoGLLGSEPlpr77K PKSYEkOCOnc9VPxopDkdDdZ6K5JLyY4cFm8clH1mb6x768TLhl6yLJZbG2n7sUw7I7hn MTxGs/FA3m3ib+yNLeqmyHDeoK56wSp7GdIg4S4Z4qNmsHn3qVQs4ZjMNh8XweamMbsX 7cb79EjP3t204lE7iuW504A05LcjpcVxGT235GwJBkh1S5tlFle4zPBqUPMEguWzhZmA Bk2Q== X-Gm-Message-State: AOAM533gcMUWiJoLVTqN0KehI12Ul40cK9xAgioqKv8vz97eji9jv4uZ y60KJ+2vMwKxtvssY5uV+ENhR5mTG/Y6MekwsZ96tVka X-Google-Smtp-Source: ABdhPJzorLbslOJqyCc0KYY+/9jSUgyHnsDk4FHgGeF+PAEWdBGmPh0GqKqe11lwrjv7QyUQ9yFXHfmWk5qWritHT+Q= X-Received: by 2002:a67:1c05:: with SMTP id c5mr55168543vsc.25.1637063588956; Tue, 16 Nov 2021 03:53:08 -0800 (PST) In-Reply-To: <87ilws1gcf.fsf@zoho.eu> X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::931 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::931; envelope-from=yurivkhan@gmail.com; helo=mail-ua1-x931.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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:134632 Archived-At: On Tue, 16 Nov 2021 at 18:37, Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > Depending on circumstances, you might want to refine the > > regexp to disallow leading zeros unless it is the only digit > > in the integer part; and/or allow exponential format. > As for disallowing leading zeroes I think it should be as > close to Emacs as possible, eval 00 for example. This is because I said =E2=80=9Cdepending on circumstances=E2=80=9D. You ma= y want to allow leading zeros and treat the number as decimal anyway, or you might want to allow leading zeros and treat the number as octal, or disallow leading zeros. It is application-specific. > > It might also be a good idea to wrap all that in > > a =E2=80=98save-match-data=E2=80=99.) > > What/how do you mean? Suppose we put that function in a library and document it as =E2=80=9Cit parses decimal numbers, checking that it is actually a decimal number=E2=80=9D. A user tries to use the function between a (string-match =E2=80=A6) and a subsequent (match-beginning), (match-end), (match-string) or (match-substitute-replacement). But our function itself uses (string-match) so we trash the user=E2=80=99s match result. (It is said somewhere that, generally, it is the caller=E2=80=99s responsibility to preserve the match data across a function call that might trash it, though. Maybe because this way yields better performance when nobody actually cares about the last match data.)