vendredi 13 janvier 2017

Jump to code from Coverity report emails (notmuch)

If you use notmuch as your email client and receive Coverity reports emails, here's a quick function that compiles the reports to a single buffer (newest first), applies some color on the errors, and enables the compilation minor mode so you can use Emacs regular "jump to next error" key.

Adapt the default-directory to your project source.

(defun samba-coverity ()
  (interactive)
  (let ((b (get-buffer-create "*coverity*")))
    (with-current-buffer b
      (erase-buffer)
      (setq default-directory (expand-file-name "~/prog/samba-git"))
      (insert
       (shell-command-to-string
 (concat
  "for i in $(notmuch search --output=messages"
  " 'from:scan-admin@coverity.com'); do notmuch show $i; done"
  " | perl -pE 's,^/(\\S+): (\\d+) in,cov:$1:$2: in,'")))
      (goto-char (point-min))
      (while (search-forward-regexp (rx bol ">>>") nil t)
 (let ((beg (save-excursion (beginning-of-line) (point)))
       (end (save-excursion (end-of-line) (point))))
   (put-text-property beg end 'face 'error)))
      (goto-char (point-min))      
      (compilation-minor-mode))
    (switch-to-buffer b)))

Aucun commentaire:

Enregistrer un commentaire