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

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

Re: message in minibuffer


From: wkomornicki
Subject: Re: message in minibuffer
Date: 19 Nov 2005 21:52:40 -0800
User-agent: G2/0.2

Drew:
Here is a sample piece of code
   (defun foo ()
       (let ((arg "abc"))
         (message "Here is arg: %s" arg)))

I evaluate this in the minibuffer
      Eval: (foo)
and get
      "Here is arg: abc"
in the minibuffer.  However if I evaluate it with
      M-x foo
I get the output
      Here is arg: abc
It seems that the quotation marks show up depending on how the function
is invoked.  Why?

Drew Adams wrote:
> I am a newbie in writing lisp code.  When my code displays a message in
>     the minibuffer using the (message ...) syntax, I always have double
>     quotes around the output.  I have noticed in other packages that
>     messages appear without the double quotes yet the code uses the same
>     syntax
>
>     How do I get rid of the double quotes in the mini-buffer?
>
> Post your code, so we can see what it does.
>
> `message' displays a literal string argument without double-quotes. However,
> if your string _contains_ double-quotes, then they will be shown by
> `message', as they are characters in the string itself.
>
> This will not display any double-quotes: (message "This is a message")
>
> This will display double-quotes: (message "\"Quoted message\"")
>
> If you are doing (message foo), then make sure the value of `foo' is not a
> string that contains double-quotes. In particular, be aware that if you set
> a string-valued variable `foo' using `set-variable' or Customize, you should
> not include double-quotes in the value you enter.
>
> Keep in mind also that the first argument to `message' is a format string.
> See function `format' for the proper use of `%' in format strings. If, for
> example, you use `%S' instead of `%s', then a string value will be displayed
> surrounded by double-quotes. For example:
>
> (setq foo "aaa")
>
> (message "Here is a string value: %S." foo) ->
>
>   Here is a string value: "aaa".
>
> (message "Here is a string value: %s." foo) ->
> 
>   Here is a string value: aaa.



reply via email to

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