开发者

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

开发者 https://www.devze.com 2023-03-28 17:14 出处:网络
I tried running (list (next-error) (kill-ring-save (line-beginning-position) (line-end-position))) immediately after M-x compile

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

精彩评论

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