From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) Newsgroups: gmane.emacs.devel Subject: Re: Flymake refactored Date: Thu, 05 Oct 2017 11:57:32 +0100 Message-ID: <87shex276r.fsf@gmail.com> References: <87h8vmj3tr.fsf@lolita> <1507138648.1972.0@smtp.gmail.com> <874lre2von.fsf@gmail.com> <87mv566yjx.fsf@udel.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1507201071 19306 195.159.176.226 (5 Oct 2017 10:57:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 5 Oct 2017 10:57:51 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) Cc: jwiegley@gmail.com, emacs-devel@gnu.org, Simen =?utf-8?Q?Heggest=C3=B8yl?= , dgutov@yandex.ru, Steve Purcell , sdl.web@gmail.com, monnier@iro.umontreal.ca To: Mark Oteiza Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 05 12:57:47 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e03qb-0004Ml-L8 for ged-emacs-devel@m.gmane.org; Thu, 05 Oct 2017 12:57:45 +0200 Original-Received: from localhost ([::1]:39058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e03qi-0006te-SM for ged-emacs-devel@m.gmane.org; Thu, 05 Oct 2017 06:57:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e03qZ-0006sL-9b for emacs-devel@gnu.org; Thu, 05 Oct 2017 06:57:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e03qV-0000Pj-A2 for emacs-devel@gnu.org; Thu, 05 Oct 2017 06:57:43 -0400 Original-Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:55398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e03qV-0000PV-0M for emacs-devel@gnu.org; Thu, 05 Oct 2017 06:57:39 -0400 Original-Received: by mail-wr0-x22e.google.com with SMTP id l39so10562971wrl.12 for ; Thu, 05 Oct 2017 03:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=AQMQzOaVAowDp9MFysZyw7k50A43i9sA+oxfUg4CHQI=; b=VGn0AkuJA0XFZwsYNNozcnjaS+Q+FLEPe41PqpxHCCiFLe3TQ/RP1AFJXI20nF6XLv 2ELMMZhGY+T7qUMisvIRmJYGt/CFUfPr43W8jDQN/3VZRDKK34Oxw/1K4MfXeN7gLW+r gdJyAkbM54LVKa5PHw3S0n8q1ci5AMRrb2cEC0hrXbzYp6nd/bW7W/PiR/PthVgHEhei Ba3zjTrP6l6liBccfu2HHW1O3Rj3xLDApArEdXHX6Fcc0+bP5+gWKJ3OfBbYctqSuW3l BMMhv+idw5YCUP/GvbQ6W4xllpceVLD9aniJ5VuWpZtjHSov+uwqcXJNll95NC91Tdj4 Tc2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=AQMQzOaVAowDp9MFysZyw7k50A43i9sA+oxfUg4CHQI=; b=eQ++0Ns6BEqcVFsf0S5x7q/6tIciV6UxSq9x1Cz8fKx25T2vFFARqLpO3BcmgV31nH /JDXfyOhnMeG276HF/pd+XYvRq9IwSFeXVMTeojei3rEhRRmW3XPhINJ8lnQ5X9c55V4 pq9DFgV7gR1rI8x2SREIhqBH2kCvcwhfy0B52uvIxbzZmb2r6r1DcRh83uE33DDe0//4 pkQj4eJX8NfJxmLGD8fFqP8nrrc8Vxd6iBv9oPY6mUtFJbf/AaY58rhDFDgjOKirYDA3 8cs/PNyiV70taSqjWZGOnX+yu81P89r4JdRd1i+IVxzvXnp//HrBfOhlMwKsKyJVRfs6 Jwug== X-Gm-Message-State: AHPjjUg6vcHBGXa/STf+bbNqLsexrYFiOjB88hJKHzcqsHANdiwBjpeW D7zSGDPH2FX7Y+Bd6VgGhAI= X-Google-Smtp-Source: AOwi7QAWb++24QadUYdw5zeByzjQbwD37py2BMjZBXQfGucN5jOoppuRVhFq4DG2VSNdb0sTQH0qMg== X-Received: by 10.223.153.100 with SMTP id x91mr21149259wrb.202.1507201057722; Thu, 05 Oct 2017 03:57:37 -0700 (PDT) Original-Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id q16sm11141811wrg.49.2017.10.05.03.57.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 03:57:36 -0700 (PDT) In-Reply-To: <87mv566yjx.fsf@udel.edu> (Mark Oteiza's message of "Wed, 04 Oct 2017 23:52:50 -0400") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:219116 Archived-At: Mark Oteiza writes: > Modeled after your example and bits from flycheck[0] and syntastic[1], I > have attached humble beginnings to a clang checker (errors only). Looks great. > Something is probably very broken, as using it to check Emacs C at this > point triggers the following: > > funcall-interactively: binding stack not balanced (serious byte compile= r bug) Sounds serious indeed. I've seen this too, once or twice, no idea how to debug it. > I also seem to have problems using the column number (match-string 2) > and so it is left unused. The problem is that you are calling flymake-diag-region in the wrong buffer. It has to be the source buffer, so in your case you need a (with-current-buffer source ...) around it. But that inconvenience has been fixed in the very latest code emacs-26 branch. In that version, you just pass 'source' (the c/c++ buffer) to flymake-diag-region. > :sentinel > (lambda (p _ev) One of the things you must do here is check if your process is obsolete, i.e. if Flymake decided to launch another one in the meantime. A good way to do this is to check if 'p' is 'eq' to the buffer-local value of clang-flymake--procress. > for (beg . end) =3D (flymake-diag-region > (string-to-number > (match-string 1))) This is the bit where you would pass 'source' to flymake-diag-region I've built a backend very similar to yours but base on gcc (clang is 500MB and no time for that right now). Have a look, below my sig. I've also noticed, there's a lot of repetition building up in these examples. Later it's probably useful to invent an abstraction that hides it away. Jo=C3=A3o ;;; test-gcc-backend.el --- naive gcc Flymake backend -*- lexical-binding: = t; -*- (defvar-local gcc--flymake-proc nil) (defvar gcc-program "gcc") (defun gcc-flymake (report-fn &rest _args) (unless (executable-find gcc-program) (error "Cannot find a suitable gcc")) (when (process-live-p gcc--flymake-proc) (kill-process gcc--flymake-proc)) (let ((source (current-buffer))) (save-restriction (widen) (setq gcc--flymake-proc (make-process :name "gcc-flymake" :buffer (generate-new-buffer "*gcc-flymake*") :command `(,gcc-program "-fsyntax-only" "-Wextra" "-Wall" "-fno-diagnostics-show-option" "-x" "c" "-") :noquery t :connection-type 'pipe :sentinel (lambda (p _ev) (unwind-protect (when (eq p gcc--flymake-proc) (with-current-buffer (process-buffer p) (goto-char (point-min)) (cl-loop while (search-forward-regexp "^:\\([0-9]+\\):\\([0-9]+\\): \\(.*\\): \\(.*\\)$" nil t) for msg =3D (match-string 4) for (beg . end) =3D (flymake-diag-region source (string-to-n= umber (match-string 1)) (string-to-n= umber (match-string 2))) for type =3D (assoc-default (match-string 3) '(("error" . :error) ("note" . :note) ("warning" . :warning)) #'string-match) collect (flymake-make-diagnostic source beg end typ= e msg) into diags finally (funcall report-fn diags)))) (display-buffer (process-buffer p)) ; use this instead of = the next one for debug ;; (kill-buffer (process-buffer p)) ) ))) (process-send-region gcc--flymake-proc (point-min) (point-max)) (process-send-eof gcc--flymake-proc))))