开发者

How can I get 'next-error' to copy the line causing the error into the kill-ring?

I tried running

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

immediately after M-x compile

But it pushes the current line to the kill ring, not the line where the error was found...

If so how do I 开发者_开发问答make emacs wait for (next-error) to complete before continuing with the next command?


This little bit of advice will copy the line specified by the error into the kill ring:

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

If you decided you wanted to grab the error message, you could use this:

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜