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 15:05:40 +0700 Message-ID: References: <87ee7nqomk.fsf@mbork.pl> <875ysxrj0v.fsf@mbork.pl> <877dd835cp.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="30618"; 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 09:06:56 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 1mmtUW-0007kQ-Oq for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 09:06:56 +0100 Original-Received: from localhost ([::1]:52742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mmtUV-0006KB-Mh for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 03:06:55 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmtTX-0006Jm-MJ for help-gnu-emacs@gnu.org; Tue, 16 Nov 2021 03:05:55 -0500 Original-Received: from [2607:f8b0:4864:20::931] (port=38684 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 1mmtTU-0002yY-Ip for help-gnu-emacs@gnu.org; Tue, 16 Nov 2021 03:05:55 -0500 Original-Received: by mail-ua1-x931.google.com with SMTP id w23so17679996uao.5 for ; Tue, 16 Nov 2021 00:05:52 -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=i9RsMeWa0vLDUEEc3lHoDu3WEFFn49FafUswRdm69uE=; b=NmfhHocGQ75YrgImF666ksUgqtwL1KxBPNedPJfPWJu9c7IxTEuqsg9FDsWYxTBD92 Fi5GdY7QyraHkh29DktlOlD4mu+s+EYhxSLOIGoxj8/UjlXCCnXvbq5jCiVan958a/5I Qj+BhGoJYaJdB6X049XWv7Rs/z0+6ou5leQLNIXrfP1+04Xc2C/bUGIplImPdXTzuRBQ y7j40ao86rIpJhvSkjK0EcVp1SPA5/7Nn/4ySknh9Xn2l3q7EVZesttOLn1Jx7DONiun HTFwbKrWIqFBtc3eq4n16iz0/uKd9kO8CU2GFWBf8wCaNA+4dtk+9P5Q5VCMtkG/x43G SJGg== 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=i9RsMeWa0vLDUEEc3lHoDu3WEFFn49FafUswRdm69uE=; b=TcTh3gazdDKr7H8ziGuCX2zVSzsdj5sp34JgqCNjZNqjDIzTSbvMDOaeYg+C7NI/xx GZbCP5eHPW022siPzCpNw5Hr+37hR5PCtMnlBvOEJjLcc6meHHA52nuzHO8v9unD4x1j j5A5bEm3Lo5+P24RBc2ghgRPHHBQFrRn3wL2jnSp2QdyE4/EVR0OUPkbYbyGwj7F6glA vm9SRpfaRzj0iwLFJ0ojIs9ZAibv4eCzPFX9X0ecaeCIMw0VyZU6h6PA3S1KdsD6V+B/ 59cTjHKyd/p2pYRH32pbfOeMkIhEDwwjjZk6bF/GbX+YL6MAEvLBSFbCzZwqcDKqrTrq 0knQ== X-Gm-Message-State: AOAM532z3UZ40oh/NCbDEWQnisgxuMiQ5DPTCOy1pa+e8KZFPS7qR97+ Cg0Wd3hqJFmBNJG5c6nxedoyQPWQZ/+ENLfwvpg= X-Google-Smtp-Source: ABdhPJxlRUnT8kJLJsy6njw/vTy2LswEg+78rprgkzgKj+58QAvMraaH5e0XaaPjxP2vSThQ1oH6odcL6b+WmMiMNMU= X-Received: by 2002:a67:1c05:: with SMTP id c5mr53250055vsc.25.1637049951608; Tue, 16 Nov 2021 00:05:51 -0800 (PST) In-Reply-To: <877dd835cp.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:134627 Archived-At: On Tue, 16 Nov 2021 at 14:52, Emanuel Berg via Users list for the GNU Emacs text editor wrote: > And they explicitely made it be this way ... weird. I was going to suggest piggybacking on the JSON parser, but it has the same= bug: M-: (json-read-from-string "123foo") =E2=87=92 123 (#o173, #x7b, ?\{) Fortunately, json-read-from-string is simple enough that you can copy and modify it: -(defun json-read-from-string (string) +(defun json-read-from-string-strict (string) "Read the JSON object contained in STRING and return it." (with-temp-buffer (insert string) (goto-char (point-min)) - (json-read))) + (prog1 (json-read) + (unless (eobp) (error "Trailing garbage"))))) You still get some whitespace skipping though.