* message in minibuffer @ 2005-11-19 23:52 wkomornicki 2005-11-20 0:10 ` Drew Adams [not found] ` <mailman.15965.1132445463.20277.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 5+ messages in thread From: wkomornicki @ 2005-11-19 23:52 UTC (permalink / raw) 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? ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: message in minibuffer 2005-11-19 23:52 message in minibuffer wkomornicki @ 2005-11-20 0:10 ` Drew Adams [not found] ` <mailman.15965.1132445463.20277.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 5+ messages in thread From: Drew Adams @ 2005-11-20 0:10 UTC (permalink / raw) 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.15965.1132445463.20277.help-gnu-emacs@gnu.org>]
* Re: message in minibuffer [not found] ` <mailman.15965.1132445463.20277.help-gnu-emacs@gnu.org> @ 2005-11-20 5:52 ` wkomornicki 2005-11-20 6:58 ` Drew Adams [not found] ` <mailman.15984.1132469952.20277.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 5+ messages in thread From: wkomornicki @ 2005-11-20 5:52 UTC (permalink / raw) 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. ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: message in minibuffer 2005-11-20 5:52 ` wkomornicki @ 2005-11-20 6:58 ` Drew Adams [not found] ` <mailman.15984.1132469952.20277.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 5+ messages in thread From: Drew Adams @ 2005-11-20 6:58 UTC (permalink / raw) 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 [echo area]. 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? Like many "functions" in Lisp, `message' does two things: 1. It displays a message in the minibuffer. 2. It returns a value: the message that it displayed - a string. #1 is a side effect. #2 is the normal behavior of a true function. But this is more than a question just of `message'... When you evaluate `(foo)' using, for example, `M-:' (command `eval-expression'), you see only the result of the evaluation - that's the behavior of `eval-expression' (it's own side effect): print the result of evaluation in the echo area. When the string value of `message' is printed, it is enclosed in double-quotes, so you can see that the value is a string. In fact, the process of evaluating `M-: (foo)' first calls (message...), which prints your message (without quotes), but then the result of `M-: (foo)' is printed (as a string - showing the quotes), so you never see the first message. If you check buffer *Messages*, you will see your message, without the quotes. When you evaluate `(message...)' using `M-x foo', the result of the evaluation (of `(foo)') is not echoed in the echo area, because function `execute-extended-command' (which is bound to `M-x') does not have such a side effect. IOW, this is all about 1) keeping straight the difference between side effect and resulting value, and 2) knowing the behavior of the given functions (`eval-expression' vs `execute-extended-command'). "Are we having fun yet?", asks Zippy, tossing his "Elementary Haskell" manual into the dryer and turning the dial to "Delicates". "We'll see if it's really Purely Functional and 100% Fully Lazy..." HTH. ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.15984.1132469952.20277.help-gnu-emacs@gnu.org>]
* Re: message in minibuffer [not found] ` <mailman.15984.1132469952.20277.help-gnu-emacs@gnu.org> @ 2005-11-20 20:15 ` wkomornicki 0 siblings, 0 replies; 5+ messages in thread From: wkomornicki @ 2005-11-20 20:15 UTC (permalink / raw) Thanks. That clears up a lot of other questions that I had when writing elisp code ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-11-20 20:15 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-11-19 23:52 message in minibuffer wkomornicki 2005-11-20 0:10 ` Drew Adams [not found] ` <mailman.15965.1132445463.20277.help-gnu-emacs@gnu.org> 2005-11-20 5:52 ` wkomornicki 2005-11-20 6:58 ` Drew Adams [not found] ` <mailman.15984.1132469952.20277.help-gnu-emacs@gnu.org> 2005-11-20 20:15 ` wkomornicki
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).