1

I've only recently started diving deeper into elisp. I've been using message a lot in the past, much like println or print when in other languages. The trouble I have is that I'm writing elisp to operate on another file in another buffer, and I intend to eventually bind an interactive function which I'd then use when in similar buffers.

The problem is then I'm dealing with three buffers in emacs: target buffer, elisp buffer, and the mini-buffer where message output goes. The mini-buffer is way to small sometimes. And I'm suspecting there are better ways of doing this kind of work.

Is there more of an idiomatic way of developing elisp for new interactive functions?

  • How about a 3-way window split, excluding the echo area / mini-buffer -- with the *Messages* buffer being visible in one of the 3 main windows? – lawlist Aug 14 at 18:02
  • IMO, you'd be better off learning how to use a debugger - edebug is a good one: among other things, it allows you to step through a function, checking values as you go. – NickD Aug 14 at 19:10
2

If you are using messages to yourself while developing then:

  • That's fine - nothing wrong with using message.

  • You can also define a wrapper for such uses of message, which respects a global variable you define. That gives you a quick way to turn such messages on/off or otherwise affect them.

  • An alternative is to use debug, to use the Emacs debugger:

    • M-x debug-on-entry open the debugger whenever a given function is invoked.

    • M-x toggle-debug-on-error toggles whether to enter the debugger when an error is raised.

    • You can place (debug) at various places in your code to create breakpoints there. When that's encountered it opens the debugger at that place.

      If you use (debug nil ARG1 ARG2...) then when the debugger opens it prints the values of the arguments, ARG1, etc. Otherwise, you can just use e to evaluate any sexp in the debugger. Use C-h m in the debugger to learn more about it.

  • edebug is an alternative to debug.

For more info about debug see the Elisp manual, node Invoking the Debugger for more info. For a broader view, see its parent node, Debugger.

For more info about edebug see the Elisp manual, node Edebug.

You can access the Elisp manual from Emacs, using C-h i m el TAB RET.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.