From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: lisp read-from-minibuffer propels deep questions
Date: Mon, 2 Apr 2012 19:01:18 -0700 (PDT) [thread overview]
Message-ID: <a44f5e91-30cd-4ee8-a588-3747814f4c92@wj4g2000pbc.googlegroups.com> (raw)
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 “describe-
function”.
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
「"\"mystring\""」. (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 「mary」,
lisp reader freaks out. Again, it doesn't undertand what the letter
sequence 「mary」 is. It wants a string 「"\"mary\""」. So, user will have
to actually type 「"mary"」 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….
Xah
next reply other threads:[~2012-04-03 2:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 2:01 Xah Lee [this message]
2012-04-03 4:57 ` lisp read-from-minibuffer propels deep questions Kevin Rodgers
2012-04-03 5:35 ` Drew Adams
[not found] ` <mailman.420.1333431363.20052.help-gnu-emacs@gnu.org>
2012-04-03 5:58 ` Xah Lee
2012-04-04 1:06 ` Stefan Monnier
2012-04-04 4:24 ` Xah Lee
2012-04-13 2:03 ` Joe keane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a44f5e91-30cd-4ee8-a588-3747814f4c92@wj4g2000pbc.googlegroups.com \
--to=xahlee@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.