elisp tip: message and apropos-command

Tip for elisp coders. Often, while still writing your program and in the debugging process, you might put 「(mesage mystr)」 to print some variables. However, if your “mystr” happens to contain “%” char such as in url, then you'll get a mysterious error “Not enough arguments for format string”. Took me some time to trace a bug to this extraneous debug line. So:

;; don't do this
(message mystr)

;; do this
(message "%s" mystr)

Also, you know about apropos-command 【Ctrl+h a】 right? Useful to find the command you want. However, remember that it only list commands, not functions. When you are looking for the function you want, you can do a 【Ctrl+u】 first, so that apropos-command will also list functions.

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs