From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: lisp read-from-minibuffer propels deep questions Date: Mon, 2 Apr 2012 19:01:18 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1333422699 24256 80.91.229.3 (3 Apr 2012 03:11:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 3 Apr 2012 03:11:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 03 05:11:39 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SEu9h-0007BG-7A for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Apr 2012 05:11:37 +0200 Original-Received: from localhost ([::1]:36112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEt7u-00049x-MA for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Apr 2012 22:05:42 -0400 Original-Path: usenet.stanford.edu!postnews.google.com!wj4g2000pbc.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs,comp.lang.lisp Original-Lines: 64 Original-NNTP-Posting-Host: 76.126.112.84 Original-X-Trace: posting.google.com 1333418478 17165 127.0.0.1 (3 Apr 2012 02:01:18 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 3 Apr 2012 02:01:18 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: wj4g2000pbc.googlegroups.com; posting-host=76.126.112.84; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.83 Safari/535.11,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:191865 comp.emacs:102355 comp.lang.lisp:308985 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84278 Archived-At: slightly frustrated with emacs lisp read-from-minibuffer. Spent now about a hour on this. what i want i simple, like this: (read-from-minibuffer (format "Directory (default %s):" default-directory) default- directory ) prompt user to enter a dir, with default at current dir. however, according to inline doc of read-from-minibuffer, the second arg for default input is obsolete. Instead, you have to use the 6th arg. Quote: (read-from-minibuffer PROMPT &optional INITIAL-CONTENTS KEYMAP READ HIST DEFAULT-VALUE INHERIT-INPUT-METHOD) the doc is long so i won't paste here. See it by calling =E2=80=9Cdescribe- function=E2=80=9D. Now, so i do: (read-from-minibuffer (format "Directory (default %s):" default-directory) nil nil nil nil default-directory) doesn't work. Read the doc again, it turns out that the 4th arg must be t in order for the default value to work, else you get empty string if the user just press Enter. So i do (read-from-minibuffer (format "Directory (default %s):" default-directory) nil nil t nil default-directory) woops! no go! because if the 4th arg is t, it means the input as a string will be fed to lisp reader, then interpreted as a lisp object. Hot damn. This means, if you want a string, you have to feed it =E3=80=8C"\"mystring\""=E3=80=8D. (the outter string makes it a lisp string= to be fed to lisp reader, then, the inner string gets you a lisp string object) So, now i have to do this: (read-from-minibuffer (format "Directory (default %s):" default-directory) nil nil t nil (format "\"%s\"" default-directory) ) But no! Because, now if user actually enter a value, e.g. type =E3=80=8Cmar= y=E3=80=8D, lisp reader freaks out. Again, it doesn't undertand what the letter sequence =E3=80=8Cmary=E3=80=8D is. It wants a string =E3=80=8C"\"mary\""= =E3=80=8D. So, user will have to actually type =E3=80=8C"mary"=E3=80=8D for this to work. WTF? This line is supposed to be done in 20 seconds. Now i've spent 40min on this. Now, my mind wanders to the deep question of humanity=E2=80=A6. Xah