This is really a note to myself but I’ll bet many of you are in the same boat. When I want to print something in Elisp, I usually use format but sometimes one of the prin* functions is really what I need. The problem is that I can never remember exactly what they do. What, for example, is the difference between princ, print, and prin1?
This post is meant to be a cheat sheet for the family. Although it’s not really part of the prin* family, I’ve included pp as well because I always forget about it.
prin1
Output a printed representation of the argument with quoting. Output will bereadable if possible.prin1-char
Return a string representation of the argument, which must be a character.prin1-to-string
Return a string representation of the argument with quoting. Likeprin1but returns the string rather than outputting it. Output will bereadable if possible.princ
Output the printed representation of the argument without quoting.princ-list
Print all arguments withprincfollowed by a newline. OBSOLETE: Usemapcandprincinstead.print
Output the printed representaton of the argument with newlines around it. Output will be quoted andreadable if possible.print-buffer
Paginate and print buffer contents.print-diary-entries
Print a hard copy of the diary display.print-help-return-message
OBSOLETE: usehelp-print-return-messageinstead.print-region
Paginate and print the region contents.pp
Output a pretty-printed representation of the argument with quoting. Output will bereadable if possible.