all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to make (format "%S" ...) print nothing?
@ 2014-07-12 10:43 Thorsten Jolitz
  2014-07-12 14:30 ` W. Greenhouse
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Jolitz @ 2014-07-12 10:43 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

I have a case where (format "%S" ...) is generally much more
convenient than (format "%s" ...), because it prints symbol args as
strings and string args as strings surrounded by double quotes, except
for this one situation:

Prints nothing:

#+begin_src emacs-lisp
(format "%s" "")
#+end_src

#+results:

but all of these print something

#+begin_src emacs-lisp
(format "%S" "")
#+end_src

#+results:
: ""

#+begin_src emacs-lisp
(format "%S" nil)
#+end_src

#+results:
: nil

#+begin_src emacs-lisp
(format "%S" ())
#+end_src

#+results:
: nil

Is there any way to use (format "%S"...) and have it print nothing
when given an empty string, an empty list or nil (or something else)?

-- 
cheers,
Thorsten




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

* Re: How to make (format "%S" ...) print nothing?
  2014-07-12 10:43 How to make (format "%S" ...) print nothing? Thorsten Jolitz
@ 2014-07-12 14:30 ` W. Greenhouse
  2014-07-12 15:44   ` Thorsten Jolitz
  0 siblings, 1 reply; 3+ messages in thread
From: W. Greenhouse @ 2014-07-12 14:30 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Thorsten Jolitz <tjolitz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Is there any way to use (format "%S"...) and have it print nothing
> when given an empty string, an empty list or nil (or something else)?

No. The printed representation of the empty string is "", and the
printed representation of the list () or nil is nil, so (format "%S" ...)
will of course print something in these cases. Since you know what that
something is going to be, perhaps you could use split-string or a
similar text-mangling function to remove it.




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

* Re: How to make (format "%S" ...) print nothing?
  2014-07-12 14:30 ` W. Greenhouse
@ 2014-07-12 15:44   ` Thorsten Jolitz
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Jolitz @ 2014-07-12 15:44 UTC (permalink / raw)
  To: help-gnu-emacs

W. Greenhouse <wgreenhouse@riseup.net>
writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> Is there any way to use (format "%S"...) and have it print nothing
>> when given an empty string, an empty list or nil (or something else)?
>
> No. The printed representation of the empty string is "", and the
> printed representation of the list () or nil is nil, so (format "%S" ...)
> will of course print something in these cases. Since you know what that
> something is going to be, perhaps you could use split-string or a
> similar text-mangling function to remove it.

This was not really a problem I could not solve, its easy to work around
it, I was just curious if there is some kind of 'hackers-trick',
someTHING that could be given as arg that does not cause an error but
has no printed representation. I guess not ...

-- 
cheers,
Thorsten




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

end of thread, other threads:[~2014-07-12 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-12 10:43 How to make (format "%S" ...) print nothing? Thorsten Jolitz
2014-07-12 14:30 ` W. Greenhouse
2014-07-12 15:44   ` Thorsten Jolitz

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.