From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tyler Smith Newsgroups: gmane.emacs.help Subject: read-from-minibuffer with default value string Date: Sun, 05 Dec 2010 15:33:15 -0500 Message-ID: <87zksk0xkk.fsf@guruji.demimonde> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1291581253 9618 80.91.229.12 (5 Dec 2010 20:34:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 5 Dec 2010 20:34:13 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 05 21:34:09 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PPLHb-0005jm-JN for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Dec 2010 21:34:07 +0100 Original-Received: from localhost ([127.0.0.1]:47337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPLHa-0000RI-Sj for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Dec 2010 15:34:06 -0500 Original-Received: from [140.186.70.92] (port=39193 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPLHF-0000RC-VA for help-gnu-emacs@gnu.org; Sun, 05 Dec 2010 15:33:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPLHE-0003wH-Od for help-gnu-emacs@gnu.org; Sun, 05 Dec 2010 15:33:45 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:58327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPLHE-0003vK-Cb for help-gnu-emacs@gnu.org; Sun, 05 Dec 2010 15:33:44 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PPLHA-0005Sw-RO for help-gnu-emacs@gnu.org; Sun, 05 Dec 2010 21:33:42 +0100 Original-Received: from 76.177.51.182 ([76.177.51.182]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 05 Dec 2010 21:33:40 +0100 Original-Received: from tyler.smith by 76.177.51.182 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 05 Dec 2010 21:33:40 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 48 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 76.177.51.182 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:M3unW8Oe1sQ/mmbB96EcNub1OCM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75511 Archived-At: Hi, I'm confused by the documentation for read-from-minibuffer. It says that the INITIAL-CONTENTS argument is obsolete, but I can't duplicate the functionality using DEFAULT-VALUE. I'm working on a function that will query the user for input using completing-read. If the value entered isn't in the collection used for completing-read, then the user is asked if they want to add the value to the collection. The following code works as I want it: (setq collection-list '(("Advances in Ecological Research" "adv_ecol_res") ("Acta Oecologica" "acta_oecol") ("Acta Botanica Neerlandica" "acta_bot_neerl"))) ;; Note that in my full code, collection-list contains three-element ;; lists, which is why I haven't used the normal (key . value) form of ;; normal alists. (defun double-query () (interactive) (let ((key (completing-read "Journal: " collection-list))) (if (setq code (cadr (assoc key collection-list))) (message "Pass <%s> to another function here" code) (if (y-or-n-p "Add to list?") (let* ((key (read-from-minibuffer (format "Journal Title <%s>: " key) key)) (code (read-from-minibuffer "Journal Bibtex Code: "))) (push (list key code) collection-list) (message "Pass <%s> to another function here" code)))))) This uses the obsolete INITIAL-CONTENTS argument. If I use the DEFAULT value list, I either have to set the READ argument to nil, which means that entering an empty string results in key being set to the empty string rather than the default value; or I set READ to t, which means that any text the user enters is treated as an expression, which produces an error when the string contains a space. The strings will often contain spaces, so this isn't good. How can I rewrite this to work without using INITIAL-CONTENTS? Thanks, Tyler