开发者

How can I make emacs think it is using a terminal?

I want to automate a job involving font lock mode using Emacs. I wan开发者_运维问答t to fontify a file and then convert it to HTML using the colouring of font lock mode. The problem is that Emacs refuses to fontify the file unless it thinks it is running in a terminal. In other words it will not fontify when running under -batch. Is there a way to fool Emacs into thinking it is running inside a terminal even when it is being run programmatically?


Advanced Programming in the Unix Environment provides a src.tar.gz for all the source code in the book; the 'pty' directory contains sample code for creating a pty master/slave program, which can fake the existence of a tty. I tested this out using cron:

* * * * * /tmp/apue.2e/pty/pty /usr/bin/tty > /tmp/pty.out 2> /tmp/pty.err
* * * * * /usr/bin/tty > /tmp/tty.out 2> /tmp/tty.err

And the output is pleasing:

==> /tmp/pty.out <==
/dev/pts/5

==> /tmp/tty.out <==
not a tty

It's at least good enough to fool tty. :)


What about using the -batch parameter ?


You could try using expect to wrap it and see if that fools emacs enough. Another alternative is to dig through the elisp code and frig it to remove whatever checks for isatty or prevents the job from running.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜