From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.devel Subject: Re: Flymake refactored Date: Wed, 04 Oct 2017 23:52:50 -0400 Message-ID: <87mv566yjx.fsf@udel.edu> References: <87h8vmj3tr.fsf@lolita> <1507138648.1972.0@smtp.gmail.com> <874lre2von.fsf@gmail.com> 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 1507175616 26962 195.159.176.226 (5 Oct 2017 03:53:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 5 Oct 2017 03:53:36 +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: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 05 05:53:28 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 1dzxDy-0005sQ-CH for ged-emacs-devel@m.gmane.org; Thu, 05 Oct 2017 05:53:26 +0200 Original-Received: from localhost ([::1]:37669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzxE5-00016d-S0 for ged-emacs-devel@m.gmane.org; Wed, 04 Oct 2017 23:53:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzxDW-00016I-1C for emacs-devel@gnu.org; Wed, 04 Oct 2017 23:52:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzxDS-0000G8-V5 for emacs-devel@gnu.org; Wed, 04 Oct 2017 23:52:58 -0400 Original-Received: from mail-qt0-x231.google.com ([2607:f8b0:400d:c0d::231]:46943) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dzxDS-0000Ev-MU for emacs-devel@gnu.org; Wed, 04 Oct 2017 23:52:54 -0400 Original-Received: by mail-qt0-x231.google.com with SMTP id 6so14033056qtw.3 for ; Wed, 04 Oct 2017 20:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=IC5r+R1TIDtRybnawEPjOf/8hYwlN9AwNaGaQE6euy4=; b=KpEHVHDKqQEvYEsRmmaVdlXW2cb3ycS3XYYCIUuEUc9ygTt3dVphncA2mDkZftLv61 HmWm5wA4nCpuZMjVtbZNM8Ol3yf9mPMXj57uBbygn8jUV+KpN/j7eVucNqomcmCfrMp8 2KAfQ3D5L6fWjbJ8cjtfNd3gKfPsaEvZIk+7Vx1QLqzvBMAYW0ZNojmuFxTdw6tWlBOJ 4BIySyBgOygSwljr1mU0ZA1syPFnSsYsHYBUNqOrFaFzx/lt6Tcjv0fA0MIa1+OoRU9g vSHt8ctefJMze00nFNOrX7ZChC7yAAU3q62TWG5ieJAFkacjyWhvlg9RcwdOiGm6XsTT lZ+w== 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=IC5r+R1TIDtRybnawEPjOf/8hYwlN9AwNaGaQE6euy4=; b=LVS2YjnLQ+5VP44Ozd/++RCOw2h6bnjYUM96Khqj1NLW+zmYoe+nMjD3f8q8Bvxi8Y GoWm0aNmi35gCuIt7mNKkoSok23L1wzgf8uupR7RVvPCVcL2l2GArED1ALZiygEPPZR+ Uy3BUwpNvgTo0Uq1XjjuUP8OQF+jR5IFsyz1OJrWkoWPQigAzrofJn5pT4oWhtkI2MYM S/v3tdCanRYJWV0fgNqYRFgCoyU1imSG2pSyGa/MP+wKLemU8IRxJnWdQySdzkOxU80+ z/0HqX1Yndji1dXsUKtNnn4KHPR+IEUwjKHZ6DrLjo5/ZZ/LYB6osb/maTrLS6h5INWe jqng== X-Gm-Message-State: AMCzsaWJtgrFqKuWNI3uq2wGpKAy54wMkninLvjZ+rLqrUO0SDS9XzP1 lTEBuXFahhoqx13ZA5l3bUDpeg== X-Google-Smtp-Source: AOwi7QDVMESbzSCz/O8Eh2l2tcrIzFeKZe3v+62IMyEhjMaMbymzIZH8b2AGY9NiG83HxCEveKezkQ== X-Received: by 10.237.41.5 with SMTP id s5mr15301613qtd.172.1507175572505; Wed, 04 Oct 2017 20:52:52 -0700 (PDT) Original-Received: from logos (pool-173-67-36-61.bltmmd.fios.verizon.net. [173.67.36.61]) by smtp.gmail.com with ESMTPSA id h19sm11481599qta.26.2017.10.04.20.52.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2017 20:52:51 -0700 (PDT) In-Reply-To: <874lre2von.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Thu, 05 Oct 2017 03:08:24 +0100") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::231 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:219103 Archived-At: joaotavora@gmail.com (Jo=C3=A3o T=C3=A1vora) writes: > For example, here's a decent Ruby checker under 40 lines that does the > same as MELPA's flymake-ruby.el (which is based on flymake-easy), but > using the new API and without creating any temporary files. Modeled after your example and bits from flycheck[0] and syntastic[1], I have attached humble beginnings to a clang checker (errors only). 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 compiler = bug) I also seem to have problems using the column number (match-string 2) and so it is left unused. [0]: http://www.flycheck.org/en/latest/ [1]: https://github.com/vim-syntastic/syntastic (defvar clang-program "clang") (defvar-local clang--flymake-proc nil) (defun clang-flymake (report-fn &rest _args) (unless (executable-find clang-program) (error "Cannot find a suitable clang")) (when (process-live-p clang--flymake-proc) (kill-process clang--flymake-proc)) (let ((source (current-buffer))) (save-restriction (widen) (setq clang--flymake-proc (make-process :name "clang-flymake" :buffer (generate-new-buffer "*clang-flymake*") :command `(,clang-program "-fsyntax-only" "-Weverything" "-fno-color-diagnostics" "-fno-caret-diagnostics" "-fno-diagnostics-show-option" "-x" "c" "-") :noquery t :connection-type 'pipe :sentinel (lambda (p _ev) (unwind-protect (with-current-buffer (process-buffer p) (goto-char (point-min)) (cl-loop while (search-forward-regexp (rx bol (or "" (eval (or (buffer-file-n= ame) ""))) ":" (group-n 1 (+ digit)) ":" (group-n 2 (= + digit)) ": " (or "fatal error" "error") ": " (group-n 3 (? (* anything))) eol) nil t) for msg =3D (match-string 3) for (beg . end) =3D (flymake-diag-region (string-to-number (match-string 1)= )) for type =3D :error collect (flymake-make-diagnostic source beg end type = msg) into diags finally (funcall report-fn diags))) ;; (message "%S" ;; (with-current-buffer (process-buffer p) ;; (buffer-string))) (kill-buffer (process-buffer p))) ))) (process-send-region clang--flymake-proc (point-min) (point-max)) (process-send-eof clang--flymake-proc)))) (defun clang-flymake-register () (add-hook 'flymake-diagnostic-functions 'clang-flymake nil t)) (add-hook 'c-mode-hook 'clang-flymake-register)