3

When building Emacs, I use ./configure --enable-checking='glyphs' so that I can take advantage of some of the built-in tools such as M-x trace-redisplay.

The redisplay debugging messages can be seen if the GUI version of Emacs was launched from the terminal.

Instead of watching a separate terminal application while using Emacs, I would like to see the stderr output — in real time (if possible¹) — from within Emacs. For example, I would like to do some stuff in one Emacs window and be able to see stderr output in another visible Emacs window. How can I achieve that goal?

¹ Due to the nature of redisplay, the buffer that displays stderr (when this question is answered) may not be able to update until the next command loop?

  • I think it's better to ask this question on emacs-devel. It's very specific to debugging Emacs' internals; it's unlikely that you'll get a proper answer here. – lunaryorn Jan 24 '16 at 21:17
  • 2
    I don't know if this is a good idea. Here's why: if you make Emacs display debugging information about its redisplay code, then this debugging information will include messages about displaying this debugging information itself. (Hmm... I don't know if I'm making sense here.) – Constantine Jan 25 '16 at 8:17
  • 4
    A low-tech solution is to redirect stderr to a file and simply visit that file, with auto-revert-mode enabled. – Lindydancer Mar 29 '16 at 18:53
  • Maybe you could use eshell for starting a 2nd instance of emacs. – Tobias Jun 18 '18 at 14:54
0

One viable alternative is to create a message with a Lisp_Object instead, but beware that passing raw numbers without using functions like make_number or make_float will cause Emacs to crash. This is not technically speaking the answer to the question, but it permits seeing values within Emacs and is not subject to the limitations of GLYPH_DEBUG (which cannot print a Lisp_Object).

Lisp_Object my_object_one = make_float (0.1);
AUTO_STRING (my_string_one, "This is the value of `my_object_one':  %s");
CALLN (Fmessage, my_string_one, my_object_one);

Lisp_Object my_object_two = make_number (777);
AUTO_STRING (my_string_two, "This is the value of `my_object_two':  %s");
CALLN (Fmessage, my_string_two, my_object_two);

The following examples use fprintf to generate output to STDERR (seen from a separate terminal that launched Emacs), converting Lisp_Object into usable information with SSDATA. The usual formats apply. e.g., %f for float, %d for integer, %s for a string, etc.:

fprintf (stderr, "My lisp object:  %s\n", SSDATA (Fchar_to_string (make_number (101))));

fprintf (stderr, "string: %s | int: %d\n", SSDATA (build_string ("foo")), 69);

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.