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

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

Re: Is there something between `prin1-to-string' and `princ'?


From: Pascal J. Bourguignon
Subject: Re: Is there something between `prin1-to-string' and `princ'?
Date: Wed, 25 Sep 2013 15:06:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Hi List, 
> or even better
>
> ,-----------------------------------
> | ... :CATEGORY "tmp2" :title ("C2") ...
> `-----------------------------------
>
> but there seems to be no print command or configuration option that
> gives me strings quoted, but text without properties at the same time?

I'm afraid, you'll have to strip the properties before printing.
cf.:   substring-no-properties

(defun sexp-remove-string-properties (sexp)
   (cond
      ((stringp sexp) (substring-no-properties sexp))
      ((atom sexp) sexp)
      (t (cons (sexp-remove-string-properties (car sexp))
               (sexp-remove-string-properties (cdr sexp))))))

(prin1-to-string
  (sexp-remove-string-properties    
    '(:category "tmp2" :title (#("C2 " 0 3 (:parent nil))))))
--> "(:category \"tmp2\" :title (\"C2 \"))"

-- 
__Pascal Bourguignon__
http://www.informatimago.com/


reply via email to

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