سؤال

I am trying to debug an Emacs program performance wise. In particular, I suffer an extremely long startup time (~5' compared to ~1' for a bare Emacs) on a remote connection via WLAN, cellphone etc. In this context, any message written is no help, for the display is not refreshed at all.

What I would like to do is to write onto the "standard output" of the Linux process. I am aware of the --batch mode but this is no help to me because I want to use Emacs interactively.

So how can I write messages out to the Linux-standard output (as opposed to the Emacs standard output)?

هل كانت مفيدة؟

المحلول

You can output to standard error like this:

(print "hello world" #'external-debugging-output)

or

(princ "hello world" #'external-debugging-output)

This can buffer, so be careful.It's not possible to output to standard out at the moment. I'm going to add that, I think!

نصائح أخرى

Start emacs as a daemon (emacs --daemon) and any messages during the start-up sequence will be sent to stdout or stderr, as described by lunaryorn.

Connect to the server with emacsclient

The simplest way to kill the server is M-x kill-emacs RET

For details see C-hig (emacs) Emacs Server RET

Works for me in centos 6.8 (GNU Emacs 23.1.1):

(append-to-file "here I come to save the day\n" nil "/dev/stdout")

Try also using "/dev/tty" in place of "/dev/stdout":

Unclear from question if you intend to redirect "emacs -nw" stdout to a file and monitor that file externally (then use "/dev/stdout"); or are ok with writing to "/dev/tty" thus polluting the self-same tty of the main "emacs -nw" display.

If starting a GUI version of emacs, in such a way it may lose attachment to originating tty, can abuse environment variables to communicate an originating shell's tty to elisp.

This works for me using Aquamacs in Mac OS X. Launching from a bash shell:

$ MY_TTY=$(tty) open /Applications/Aquamacs\ Emacs.app &

then in emacs:

(append-to-file "here I come to save the day\n" nil (getenv "MY_TTY"))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top