help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to prompt for string?


From: Peter Dyballa
Subject: Re: How to prompt for string?
Date: Fri, 17 Feb 2006 20:58:01 +0100


Am 17.02.2006 um 05:58 schrieb jacksneckhurts@yahoo.com:

I'm trying to teach myself emacs Lisp, but can't figure out how to
prompt for a string. I found the "read-key-sequence-vector" function,
but that only takes in one character. Does anyone know how to prompt
for a string?

Yes, there seem to be a few! I remember that calendar prompts me a few times when I want to go to some date. And there are these functions to change an encoding, C-x RET f for example. Let's see how they do it!

C-h k C-x RET f opens a *Help* buffer with a hyper link to mule.el. I follow it. Oufff, it opens in another window! I do not need to remember the function's name! Oh -- the cursor is already positioned at the function's start ... shall I manage to remember this behaviour? But, what is a life without constant sorrows?! I'm glad that I've chosen a bad example: no obvious output or input, but ... it's prompting me with "Coding system for saving file (default nil): " -- let's search for this sentence! Ah, there it is -- the first line of code of this function set-buffer-file-coding-system, very strange:

  (interactive "zCoding system for saving file (default nil): \nP")


OK, that's one guess. Let's see how a veteran does it in Calendar! (interactive (list (calendar-read-date))) -- a function in calendar.el. Hey, GNU Emacs even takes me to my private copy with German text! Here two functions, calendar-read and completing-read are doing the job of prompting, while taking the first argument as the prompt's text. The first one uses (read-minibuffer prompt initial- contents), the latter uses a function in `C source code'. (completing- read PROMPT TABLE &optional PREDICATE REQUIRE-MATCH INITIAL-INPUT HIST DEF INHERIT-INPUT-METHOD). Aha.


Two "applications" and three ways to prompt for an input! That's efficiency.

--
Greetings

  Pete

Got Mole problems?
Call Avogadro 6.02 x 10^23






reply via email to

[Prev in Thread] Current Thread [Next in Thread]