unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "FKtPp@Office ;)" <m_pupil@16cn.comp.os.linux3.com>
Subject: Re: [elisp]How to ask and provide a Default value?
Date: Fri, 05 Mar 2004 09:02:04 +0800	[thread overview]
Message-ID: <u1xo8ksxf.fsf@16cn.comp.os.linux3.com> (raw)
In-Reply-To: 40475137.5080409@yahoo.com

Kevin Rodgers <ihs_4664@yahoo.com> writes:


[...]

>
> (defun foo (number)
>    (interactive "nNumber: ")
>    (message "number=%d" number))
>
> When I type `M-x foo RET RET' on Emacs 19.34, I get an "End of file
> during parsing" error.  When I type that on Emacs 21.3, I get a
> transient "Please enter a number." Message, then the prompt is
> redisplayed. 

Thank you. I got it too :) 

> So evidently Emacs does not provide a default for the `n' character
> code.

But, I still don't know how to use the default character description
:P Would u please give me a sample?

>
>
>  >   (let ((step-number (if (numberp step)
>  > 		  step
>  > 		(string-to-number step)))
>  > 	(base-number (if (numberp base)
>  > 			 base
>  > 		       (string-to-number base)))
>  > 	(column-number (if (numberp column)
>  > 			   column
>  > 			 (string-to-number column))))
>
> You are confused here: the `n' characters codes in the interactive form
> will cause base, step, and column to be bound to numbers, not strings.
>
>  >     (save-excursion
>  >       (narrow-to-region beginning end)
>  >       (goto-char (point-min))
>  >       (beginning-of-line)
>  >       (while (< (point) (point-max))
>  > 	(goto-char (+ (point) column-number))
>  > 	(insert (number-to-string base-number))
>  > 	(setq base-number (+ base-number step-number))
>  > 	(forward-line))
>  >       (widen))))
>
> When the save-excursion form returns, it will restore the previous
> narrowing (if any), so you should not explicitly call widen there.

And thank u again. I will take ur advise :P

  reply	other threads:[~2004-03-05  1:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-04  6:54 [elisp]How to ask and provide a Default value? FKtPp@Office ;)
2004-03-04 15:54 ` Kevin Rodgers
2004-03-05  1:02   ` FKtPp@Office ;) [this message]
2004-03-05 18:16     ` Kevin Rodgers
2004-03-06  7:56       ` FKtPp@Office ;)
2004-03-08 18:46         ` Kevin Rodgers
  -- strict thread matches above, loose matches on Subject: below --
2004-03-05  7:45 Joakim Hove
2004-03-05  8:04 ` Joakim Hove
2004-03-06  7:52 ` FKtPp@Office ;)

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=u1xo8ksxf.fsf@16cn.comp.os.linux3.com \
    --to=m_pupil@16cn.comp.os.linux3.com \
    /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.
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).