如何将“next-error”复制到导致错误的行进入kill-ring?

时间:2011-08-16 15:55:18

标签: elisp

我试过了

(list (next-error) 
      (kill-ring-save (line-beginning-position) (line-end-position)))
M-x compile

之后

但是它将当前行推送到kill ring,而不是发现错误的行......

如果是这样,我如何让emacs在继续下一个命令之前等待(next-error)完成?

1 个答案:

答案 0 :(得分:0)

这一点建议会将错误指定的行复制到kill ring中:

(defadvice compilation-goto-locus (after next-error-copy-offending-line activate)
  (kill-ring-save (line-beginning-position) (line-end-position)))

如果您决定要抓取错误消息,可以使用:

(progn
  (next-error)
  (with-current-buffer next-error-last-buffer
    (kill-ring-save (line-beginning-position) (line-end-position))))