怎么保存emacs首次启动编译的完整log

使用chenbin的emacs.d配置

git clone GitHub - redguardtoo/emacs.d: Fast and robust Emacs setup. ~/.emacs.d

因为国情,修改成清华软件源

nano ~/.emacs.d/lisp/init-elpa.el

首次启动,使用命令

emacs -nw --debug-init | tee chenbin_emacs_-nw_–debug-init

会输出大量log ,但是在compile-Log 中只能看到 最近的

怎么能看到完整的log ?

使用tee 不能保存

试试 emacs -nw --init-debug 2>&1 | tee chenbin_emacs_-nw_–init-debug

@guo 试了你的命令 还是不行 生成的文件是空的

compile log 并没有输出到 stdout/stderr,而是显示在 Emacs 自己的 buffer 中,所以重定向不起作用。

你可以用 purcell 的 test-startup.sh 来测试首测启动(chenbin 的配置是基于 purcell 的,不知道是 chenbin 删了这个测试脚本,还是 fork 的时候还没有这个脚本),这个时候所有的 log 都在 stdout/stderr 了。

2 个赞

@twlz0ne 谢谢

1 你发的这个,我学习下. 我刚接触这个, 语法不熟悉.

我在首次启动emacs的时候,看到log中有error,但还是最后进入emacs了,所以想看看完整log

2 purcell的测试是做什么任务? 像是持续集成的编译,检测是否有错误?

${EMACS:=emacs} -nw --batch \
                --eval '(let ((debug-on-error t)
                              (url-show-status nil)
                              (user-emacs-directory default-directory)
                              (user-init-file (expand-file-name "init.el"))
                              (load-path (delq default-directory load-path)))
                           (load-file user-init-file)
                           (run-hooks (quote after-init-hook)))'
echo "Startup successful"

上面的代码 是完成了什么具体工作?

@twlz0ne compile log buffer的大小可以设置吗?

现在显示不完整,是因为限制了compile buffer中行数,导致没有显示完整log ? 像 linux下的终端那样,可以设置显示的行数?

直接 cd /path/to/your-emacs.d/ && wget http:/.../test-startup.sh && ./test-startup.sh 就可以了,这个脚本的作用就是在 --batch 模式下运行 Emacs,所有的 log 都在 stdout/stderr。

1 个赞

@twlz0ne

wget https://raw.githubusercontent.com/purcell/emacs.d/master/test-startup.sh

chmod +x test-startup.sh

./test-startup.sh | tee chenbin_emacs_-nw_–debug-init

终端中显示完整的compile log

但是 chenbin_emacs_-nw_–debug-init 中只有

kk@H3:~/d/.emacs.d$ cat chenbin_emacs_-nw_–debug-init Attempting startup… Startup successful

命令换成

./test-startup.sh 2>&1 | tee chenbin_emacs_-nw_–debug-init1

kk@H3:~/d/.emacs.d$ cat chenbin_emacs_-nw_–debug-init1 Attempting startup… Startup successful

是我tee命令用的不对,还是说这个compile log的信息就只能显示在终端中,不能保存成文件?

你的 shell 有问题吧?

fish-shell 是不支持 & 的,不知道其他 shell 会不会有类似的问题。

你可以了强制使用 bash:

bash -c './test-startup.sh 2>&1 | tee startup.log'

1 个赞

@twlz0ne

bash -c './test-startup.sh 2>&1 | tee startup.log'

这个可以将console中的输出,保存到文件中 谢谢

2 我是在win下使用cygwin ssh 到一个debian的电脑上, 因为没有搞定代理和文件共享,就用远程的方式安装emacs

ssh 到 debian之后

kk@H3:~/d/.emacs.d$ echo $SHELL
/bin/bash

上面回复中,就是在 ssh到debian电脑上 执行的.

win上的cygwin中

kk@HA ~
$ echo $SHELL
/bin/bash
kk@H3:~/d/.emacs.d$ cat test-startup.sh
#!/bin/sh -e
if [ -n "$TRAVIS" ]; then
    # Make it look like this is ~/.emacs.d (needed for Emacs 24.3, at least)
    export HOME=$PWD/..
    ln -s emacs.d ../.emacs.d
fi
echo "Attempting startup..."
${EMACS:=emacs} -nw --batch \
                --eval '(let ((debug-on-error t)
                              (url-show-status nil)
                              (user-emacs-directory default-directory)
                              (user-init-file (expand-file-name "init.el"))
                              (load-path (delq default-directory load-path)))
                           (load-file user-init-file)
                           (run-hooks (quote after-init-hook)))'
echo "Startup successful"
kk@H3:~/d/.emacs.d$ which sh
/bin/sh
kk@H3:~/d/.emacs.d$ ls -al /bin/sh
lrwxrwxrwx 1 root root 4 Jan 24  2017 /bin/sh -> dash

debian默认使用的dash 请问dash支持 &吗?

dash有必要换成bash吗?

DashAsBinSh - Ubuntu Wiki 中提到

The default login shell remains bash. Opening a terminal from the menu or shortcut [crtl-alt-t] provides interactive bash. A script run from the desktop or file manager, through the dialogue ‘run in terminal’ will execute as POSIX dash.

运行脚本的时候,是dash

换吧。求兼容就用 Bash,求好用就 zsh / fish。

当然支持啊,fish 都支持这个