An Elisp Editing Tip

One of the first things new Emacs users learn is the eval-last-sexp (C-x C-e) command and that Emacs can interpret elisp anywhere it appears. Here’s a quick tip about using this command when writing elisp that you may not have discovered.

If you call it with a prefix (C-u) argument, it prints (or attempts to print) the result in place in the buffer. Better yet, call it with an argument of 0 (C-0 C-x C-e) to avoid truncating longer results.

Variables evaluate to their values, so here it prints the current values of these variables:

[VIDEO]

This is handy when writing elisp, for example if you want to tweak the current value of a variable:

[VIDEO]

I replace eval-last-sexp everywhere with pp-eval-last-sexp, which produces a cleaner result:

[VIDEO]

That is all.

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论