From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to read an integer from the minibuffer Date: Sat, 13 Nov 2021 10:33:43 +0300 Message-ID: References: <87ee7nqomk.fsf@mbork.pl> <874k8jz372.fsf@yahoo.com> <87czn7qhx7.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19004"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.7+183 (3d24855) (2021-05-28) Cc: Po Lu , Help Gnu Emacs mailing list To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 13 08:38:51 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 1mlnch-0004oB-P9 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 13 Nov 2021 08:38:51 +0100 Original-Received: from localhost ([::1]:43044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlncg-0005Qr-C7 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 13 Nov 2021 02:38:50 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlnbr-0005Qi-VL for help-gnu-emacs@gnu.org; Sat, 13 Nov 2021 02:37:59 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:55003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlnbo-0002jl-Tk for help-gnu-emacs@gnu.org; Sat, 13 Nov 2021 02:37:59 -0500 Original-Received: from localhost ([::ffff:41.75.188.219]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000031EC1.00000000618F6B51.00006F85; Sat, 13 Nov 2021 00:37:52 -0700 Mail-Followup-To: Yuri Khan , Marcin Borkowski , Po Lu , Help Gnu Emacs mailing list Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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.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:134561 Archived-At: * Yuri Khan [2021-11-12 10:23]: > A form control for integer numbers only permits typing digits (as you > initially asked). Now the user cannot enter -42. Integers may be negative. > My bank’s money transfer web form’s amount field filters keypresses to > only allow digits. One, I cannot paste a number I copied from an > invoice opened elsewhere. Two, I cannot press Ctrl+L to activate my > browser’s address bar, or switch to another tab with Ctrl+PgUp, > Ctrl+PgDn, or Alt+[1…9]. Three, I can’t move my cursor if I > inadvertently skip or mistype a digit, e.g., to correct a 1000 to > 15000, I cannot type ‘← ← ← 5’, I have to type ‘backspace backspace > backspace 5 0 0 0’. Totally right, the field shall be given to user to freely type and handle until user presses ENTER. On the other hand certain control is desired. > A bank money transfer is confirmed with a 4-digit code that is sent in > an SMS message. As soon as you type the 4th digit, it goes on to > verify the code, without you having to press Enter. However, this > means you cannot immediately correct a mistyped 4th digit; you get a > “verification failed” message first. That is right, those are good example from life. > Guideline: Perform input validation only after the user has > indicated they are finished with data entry. Those examples are not much relevant to Emacs Lisp, it's interface is quite different to browsers. And it does not have Javascript. The function `read-number' allows user to enter anything and press ENTER, upon that program verifies if it is the number or not, and advises user to enter the number. That I see as good way to go. What is not logical to me is to remove the previously entered information. If user enters "123n", I get message to enter number, but then it would be useful to provide "123n" again in the same line as to easier correct it. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/