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))))
精彩评论