unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* user-input ?
@ 2005-06-03 16:31 Mads Jensen
  2005-06-03 16:57 ` Greg Rowe
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mads Jensen @ 2005-06-03 16:31 UTC (permalink / raw)


Hi NG

I am a elisp newbie, who is trying to write a basic major mode. For
this, I need to read some input from the user, but I was not able to
find anything about that, in the elisp manual. Can anyone please tell me
how? Thank you.
-- 
Mads Jensen - mail sent to address ends in /dev/null
	      s/spam/madsj for emailing me

Research is what I'm doing when I don't know what I'm doing.
                -- Wernher von Braun

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: user-input ?
  2005-06-03 16:31 user-input ? Mads Jensen
@ 2005-06-03 16:57 ` Greg Rowe
  2005-06-03 17:00 ` Kevin Rodgers
  2005-06-03 17:02 ` Drew Adams
  2 siblings, 0 replies; 4+ messages in thread
From: Greg Rowe @ 2005-06-03 16:57 UTC (permalink / raw)


Mads Jensen wrote:

> I am a elisp newbie, who is trying to write a basic major mode. For
> this, I need to read some input from the user, but I was not able to
> find anything about that, in the elisp manual. Can anyone please tell me
> how? Thank you.

Check out the help for 'interactive'.  This is a link to the relevant 
section in the elisp manual:

http://www.gnu.org/software/emacs/elisp-manual/html_mono/elisp.html#SEC288

A very basic example of a function that requests user input in the form 
of a string:

(defun my-example (arg)
	"Example of getting user input"
	(interactive "sEnter a string: ")
	(insert arg))

Greg

-- 
Home is where the .bashrc is.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: user-input ?
  2005-06-03 16:31 user-input ? Mads Jensen
  2005-06-03 16:57 ` Greg Rowe
@ 2005-06-03 17:00 ` Kevin Rodgers
  2005-06-03 17:02 ` Drew Adams
  2 siblings, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2005-06-03 17:00 UTC (permalink / raw)


Mads Jensen wrote:
 > I am a elisp newbie, who is trying to write a basic major mode.

See http://www.emacswiki.org/cgi-bin/wiki?CategoryCode and especially
http://www.emacswiki.org/cgi-bin/wiki/CreateNewMajorMode

 > For this, I need to read some input from the user, but I was not able
 > to find anything about that, in the elisp manual. Can anyone please
 > tell me how?

99% of the time you should only read input to supply arguments to an
interactive command, so start with `C-h f interactive'.  When the basic
interactive codes aren't enough, note that you can write more
complicated things like this:

(interactive (list (read-foo "Foo: " ...)
                    (read-bar "Bar: " ...)
                    ...))

See the rather large "Minibuffers" section of the Emacs Lisp manual,
paying particular attention to the various read-* functions, most of
which are documented in the "High-Level Completion" and "Reading File
Names" nodes.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: user-input ?
  2005-06-03 16:31 user-input ? Mads Jensen
  2005-06-03 16:57 ` Greg Rowe
  2005-06-03 17:00 ` Kevin Rodgers
@ 2005-06-03 17:02 ` Drew Adams
  2 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2005-06-03 17:02 UTC (permalink / raw)


    I need to read some input from the user, but I was not
    able to find anything about that, in the elisp manual.

It's hard to believe you looked. At the top level of the Emacs Lisp manual
is this menu entry:

 * Minibuffers:: Using the minibuffer to read input.

How did I find it quickly? `s read RET'.

And before you delve into the Elisp manual, you should try `apropos'. `M-x
apropos RET read' shows the following, plus many more entries:

completing-read - Read a string in the minibuffer, with completion.

face-read-integer - Interactively read an integer face attribute value.

facemenu-read-color - Read a color using the minibuffer.

format-read - Read and return the name of a format.

ido-completing-read - Ido replacement for the built-in `completing-read'.

ido-read-buffer - Ido replacement for the built-in `read-buffer'.

ido-read-directory-name - Ido replacement for the built-in
`read-directory-name'.

ido-read-file-name - Ido replacement for the built-in `read-file-name'.

read-buffer - Read the name of a buffer and return as a string.

read-char - Read a character from the command input (keyboard or macro).

read-charset - Read a character set from the minibuffer, prompting with
string PROMPT.

read-coding-system - Read a coding system from the minibuffer, prompting
with string PROMPT.

read-command - Read the name of a command and return as a symbol.

read-envvar-name - Read environment variable name, prompting with PROMPT.

read-event - Read an event object from the input stream.

read-face-and-attribute - Read face name and face attribute value.

read-face-attribute - Interactively read a new value for FACE's ATTRIBUTE.

read-face-font - Read the name of a font for FACE on FRAME.

read-face-name - Read a face, defaulting to the face or faces on the char
after point.

read-file-name - Read file name, prompting with PROMPT and completing in
directory DIR.

read-from-minibuffer - Read a string from the minibuffer, prompting with
string PROMPT.

read-from-string - Read one Lisp expression which is represented as text by
STRING.

read-hiragana-string - Read a Hiragana string from the minibuffer, prompting
with string PROMPT.

read-input - Read a string from the minibuffer, prompting with string
PROMPT.

read-input-method-name - Read a name of input method from a minibuffer
prompting with PROMPT.

read-key-sequence - Read a sequence of keystrokes and return as a string or
vector.

read-key-sequence-vector - Like `read-key-sequence' but always return a
vector.

read-language-name - Read a language environment name which has information
for KEY.

read-minibuffer - Return a Lisp object read using the minibuffer,
unevaluated.

read-multilingual-string - Read a multilingual string from minibuffer,
prompting with string PROMPT.

read-no-blanks-input - Read a string from the terminal, not allowing blanks.

read-non-nil-coding-system - Read a coding system from the minibuffer,
prompting with string PROMPT.

read-passwd - Read a password, prompting with PROMPT, and return it.

read-quoted-char - Like `read-char', but do not allow quitting.

read-string - Read a string from the minibuffer, prompting with string
PROMPT.

read-variable - Read the name of a user variable and return it as a symbol.

strokes-read-complex-stroke - Read a complex stroke (interactively) and
return the stroke.

strokes-read-stroke - Read a simple stroke (interactively) and return the
stroke.


Decide *what* you want to read, then look closer at the list above... Look
up whatever function interests you in the Elisp manual, or use `C-h f', or
look at the source code that defines it.

It doesn't get any easier than this.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-06-03 17:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-03 16:31 user-input ? Mads Jensen
2005-06-03 16:57 ` Greg Rowe
2005-06-03 17:00 ` Kevin Rodgers
2005-06-03 17:02 ` Drew Adams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).