From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.help Subject: Re: How to read an integer from the minibuffer Date: Thu, 11 Nov 2021 11:00:12 +0000 Message-ID: References: <87ee7nqomk.fsf@mbork.pl> <87fss3c7fc.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28117"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 11 12:01:29 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 1ml7pg-00076W-KL for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 11 Nov 2021 12:01:28 +0100 Original-Received: from localhost ([::1]:47738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ml7pe-000765-RW for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 11 Nov 2021 06:01:26 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:49590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml7ok-000737-Nd for help-gnu-emacs@gnu.org; Thu, 11 Nov 2021 06:00:31 -0500 Original-Received: from heytings.org ([95.142.160.155]:34142) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ml7oW-0000bk-Tf for help-gnu-emacs@gnu.org; Thu, 11 Nov 2021 06:00:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20210101; t=1636628412; bh=Jyg6ft+41plSR0mpIiQCTtfHn4yUjfQzcKgnUMN4kBA=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=n4ttOJZw5pcdWssQjMulVBxZobpzKFNUR9UTkJoNj/we8Me7W3Vl+VMK6as223r+J b6g2SJXxXbvxfYrze2y+py32tnkQKJ1h8qsXTEI0TKQX2rHp4/jlzPboRMwHb49dDb 8wgEN+9D8TZ6yOIhvTisA9ueaclJZTyUUAL5u7B4yTYwCQg9BDJMssKQWjHNlXJYM8 iu+c3IihiUSk9i7Sj0rRDWs7fjAM8l4UBZrvffPbBaDum+r0TiJYpUb+tK2ugwto9e BmmtPrp414tOp5V44/pK8JT/dUzx5o7/biE9O3PZeq78n99BcVOR5StKI+4jEsKsTh UeN89hza2Ne9w== In-Reply-To: <87fss3c7fc.fsf@zoho.eu> Received-SPF: pass client-ip=95.142.160.155; envelope-from=gregory@heytings.org; helo=heytings.org X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_PASS=-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:134479 Archived-At: >> (defun restricted-read-from-minibuffer (prompt allowed-chars) >> "Read a string from the minibuffer, prompting with PROMPT. >> The only allowed characters are those in the string ALLOWED-CHARS." >> (let ((m (make-keymap))) >> (define-key m [t] #'ignore) >> (define-key m (kbd "RET") #'exit-minibuffer) >> (define-key m (kbd "") #'exit-minibuffer) >> (define-key m (kbd "C-j") #'exit-minibuffer) >> (define-key m (kbd "C-g") #'abort-minibuffers) >> (dolist (c (split-string allowed-chars "" t)) >> (define-key m c #'self-insert-command)) >> (read-from-minibuffer prompt nil m))) > > (read-number "try input a string instead: ") > (read-number "Try input a time in hh:mm format: ")