* How to actually print single ‘\’ character?
@ 2020-12-23 5:21 Pankaj Jangid
2020-12-23 8:08 ` Lars Ingebrigtsen
2020-12-23 8:17 ` Eli Zaretskii
0 siblings, 2 replies; 8+ messages in thread
From: Pankaj Jangid @ 2020-12-23 5:21 UTC (permalink / raw)
To: emacs-devel
I have tried:
‘"this \\ is a single embedded backslash"’
inside ‘format’ and ‘message’ functions. It prints two backslashes. How
to print single slash in a message?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to actually print single ‘\’ character?
2020-12-23 5:21 How to actually print single ‘\’ character? Pankaj Jangid
@ 2020-12-23 8:08 ` Lars Ingebrigtsen
2020-12-23 10:04 ` Pankaj Jangid
2020-12-23 8:17 ` Eli Zaretskii
1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-23 8:08 UTC (permalink / raw)
To: Pankaj Jangid; +Cc: emacs-devel
Pankaj Jangid <pankaj@codeisgreat.org> writes:
> I have tried:
>
> ‘"this \\ is a single embedded backslash"’
>
> inside ‘format’ and ‘message’ functions. It prints two backslashes. How
> to print single slash in a message?
(insert "this \\ is a single embedded backslash")
-> this \ is a single embedded backslashnil
Perhaps you're confused by how Emacs prin1s readable strings?
"foo \\ bar"
=> "foo \\ bar"
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to actually print single ‘\’ character?
2020-12-23 8:08 ` Lars Ingebrigtsen
@ 2020-12-23 10:04 ` Pankaj Jangid
2020-12-23 10:29 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Pankaj Jangid @ 2020-12-23 10:04 UTC (permalink / raw)
To: emacs-devel
Lars Ingebrigtsen <larsi@gnus.org> writes:
> (insert "this \\ is a single embedded backslash")
> -> this \ is a single embedded backslashnil
>
> Perhaps you're confused by how Emacs prin1s readable strings?
>
> "foo \\ bar"
> => "foo \\ bar"
I was reading about “Regexp Search” and then went on to see “(elisp)
String Type”.
Eli Zaretskii <eliz@gnu.org> writes:
>> I have tried:
>>
>> ‘"this \\ is a single embedded backslash"’
>>
>> inside ‘format’ and ‘message’ functions. It prints two backslashes.
>
> It does? What exactly did you try, and wbere did you see 2 backslashes?
As I was reading, I was trying in the “*scratch*” buffer and evaluating
using “C-x e”. Tried to pring in “*Message*” buffer using “(message)”
function as well.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to actually print single ‘\’ character?
2020-12-23 10:04 ` Pankaj Jangid
@ 2020-12-23 10:29 ` Eli Zaretskii
2020-12-23 11:55 ` Pankaj Jangid
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-12-23 10:29 UTC (permalink / raw)
To: emacs-devel, Pankaj Jangid
On December 23, 2020 12:04:37 PM GMT+02:00, Pankaj Jangid <pankaj@codeisgreat.org> wrote:
>
> >> I have tried:
> >>
> >> ‘"this \\ is a single embedded backslash"’
> >>
> >> inside ‘format’ and ‘message’ functions. It prints two backslashes.
> >
> > It does? What exactly did you try, and wbere did you see 2
> backslashes?
>
> As I was reading, I was trying in the “*scratch*” buffer and
> evaluating
> using “C-x e”. Tried to pring in “*Message*” buffer using “(message)”
> function as well.
After using "C-x C-e", did you look in *Messages* to make sure you are not confusing what 'message' prints with what it returns?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to actually print single ‘\’ character?
2020-12-23 10:29 ` Eli Zaretskii
@ 2020-12-23 11:55 ` Pankaj Jangid
2020-12-23 12:35 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Pankaj Jangid @ 2020-12-23 11:55 UTC (permalink / raw)
To: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> As I was reading, I was trying in the “*scratch*” buffer and
>> evaluating using “C-x e”. Tried to pring in “*Message*” buffer using
>> “(message)” function as well.
>
> After using "C-x C-e", did you look in *Messages* to make sure you are
> not confusing what 'message' prints with what it returns?
Rechecked. Now I noticed two messages. One for output and one for return
value. Earlier, I didn’t notice the output message. Just picked the last
one, which was return.
Now I have confusion with single backslash. See following two forms,
their output and return values:
(message "this \\ is a single embedded backslash") ⊣ "this \ is a single
embedded backslash" ⇒ "this \\ is a single embedded backslash"
(message "this \ is a single embedded backslash") ⊣ "this is a single
embedded backslash" ⇒ "this is a single embedded backslash"
Why the output and return same for string with single backslash?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to actually print single ‘\’ character?
2020-12-23 11:55 ` Pankaj Jangid
@ 2020-12-23 12:35 ` Eli Zaretskii
2020-12-23 16:44 ` Pankaj Jangid
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-12-23 12:35 UTC (permalink / raw)
To: emacs-devel, Pankaj Jangid
On December 23, 2020 1:55:49 PM GMT+02:00, Pankaj Jangid <pankaj@codeisgreat.org> wrote:
>
> Now I have confusion with single backslash. See following two forms,
> their output and return values:
>
> (message "this \\ is a single embedded backslash") ⊣ "this \ is a
> single
> embedded backslash" ⇒ "this \\ is a single embedded backslash"
>
> (message "this \ is a single embedded backslash") ⊣ "this is a single
> embedded backslash" ⇒ "this is a single embedded backslash"
>
> Why the output and return same for string with single backslash?
Because the return value should be suitable for the Lisp reader.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to actually print single ‘\’ character?
2020-12-23 12:35 ` Eli Zaretskii
@ 2020-12-23 16:44 ` Pankaj Jangid
0 siblings, 0 replies; 8+ messages in thread
From: Pankaj Jangid @ 2020-12-23 16:44 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> Now I have confusion with single backslash. See following two forms,
>> their output and return values:
>>
>> (message "this \\ is a single embedded backslash") ⊣ "this \ is a
>> single
>> embedded backslash" ⇒ "this \\ is a single embedded backslash"
>>
>> (message "this \ is a single embedded backslash") ⊣ "this is a single
>> embedded backslash" ⇒ "this is a single embedded backslash"
>>
>> Why the output and return same for string with single backslash?
>
> Because the return value should be suitable for the Lisp reader.
Got it.
whatever is the output (print), the consumer of the return value should
be able to produce the same output. i.e.
(message "this \ is a single embedded backslash")
and
(message (message "this \ is a single embedded backslash"))
should produce same output.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to actually print single ‘\’ character?
2020-12-23 5:21 How to actually print single ‘\’ character? Pankaj Jangid
2020-12-23 8:08 ` Lars Ingebrigtsen
@ 2020-12-23 8:17 ` Eli Zaretskii
1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2020-12-23 8:17 UTC (permalink / raw)
To: emacs-devel, Pankaj Jangid
On December 23, 2020 7:21:14 AM GMT+02:00, Pankaj Jangid <pankaj@codeisgreat.org> wrote:
> I have tried:
>
> ‘"this \\ is a single embedded backslash"’
>
> inside ‘format’ and ‘message’ functions. It prints two backslashes.
It does? What exactly did you try, and wbere did you see 2 backslashes?
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-12-23 16:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-23 5:21 How to actually print single ‘\’ character? Pankaj Jangid
2020-12-23 8:08 ` Lars Ingebrigtsen
2020-12-23 10:04 ` Pankaj Jangid
2020-12-23 10:29 ` Eli Zaretskii
2020-12-23 11:55 ` Pankaj Jangid
2020-12-23 12:35 ` Eli Zaretskii
2020-12-23 16:44 ` Pankaj Jangid
2020-12-23 8:17 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).