From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Three Flymake backends Was Re: Two issues with the new Flymake Date: Mon, 6 Nov 2017 01:56:22 +0200 Message-ID: References: <87k1z7adxi.fsf@metapensiero.it> <87po8zrubl.fsf@gmail.com> <87a800swy5.fsf@gmail.com> <04d1a3b5-9651-c46d-0e3b-7e1c858cda02@yandex.ru> <87zi80rhak.fsf@gmail.com> <829794de-27ca-383e-2b3a-a5bc4405581b@yandex.ru> <87k1z4qvv5.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1509926226 10549 195.159.176.226 (5 Nov 2017 23:57:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Nov 2017 23:57:06 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Thunderbird/56.0 Cc: Mark Oteiza , Lele Gaifax , Stefan Monnier , emacs-devel@gnu.org To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 06 00:57:02 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 1eBUmj-0002RN-EB for ged-emacs-devel@m.gmane.org; Mon, 06 Nov 2017 00:57:01 +0100 Original-Received: from localhost ([::1]:45974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBUmp-0006JN-6G for ged-emacs-devel@m.gmane.org; Sun, 05 Nov 2017 18:57:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBUmE-0006JE-7a for emacs-devel@gnu.org; Sun, 05 Nov 2017 18:56:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBUmA-0000Ot-Bf for emacs-devel@gnu.org; Sun, 05 Nov 2017 18:56:30 -0500 Original-Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:45776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBUmA-0000O5-3w for emacs-devel@gnu.org; Sun, 05 Nov 2017 18:56:26 -0500 Original-Received: by mail-wr0-x243.google.com with SMTP id y9so7031831wrb.2 for ; Sun, 05 Nov 2017 15:56:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=laQ2lpWcpHmXK42RztDFMpbcOgy6HwZwAirzcB0CNJk=; b=EKPx0n5Do7QcVEZ+TslCuEA3DY9hUbLoS3DntjgUjs0MJrlHhQiCWnrWOr/7xuY46l X1ruAc+RhPYsaLb3aiLHKSsJetICiD9h1mL7ysAe+CeEZHmyBqCJrUee9uZtQkDKwab5 RgbY3cgSGWGEe70BEVoAJgD5vv2ghOqCPVx4B9B0We8sCSVtFg/f5/t1Ay7U92Qz1rQo +n+ZW7yLJS+8NMHYcusU6Sv2P1zSjh1pISsIisC+9hrmb4kcHqeXHFTDKp6/c9na/Hu6 8gMFaOeQl8MIYTLEQ9ZsQFu+6GK2irMFEeCygD48/uxjOr88frczDSxArcttvsYCdSL/ ziwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=laQ2lpWcpHmXK42RztDFMpbcOgy6HwZwAirzcB0CNJk=; b=AlliZOzzmNAc5ZIMwWNN7mhkhD9GP7oZFVgriKkntVKC/QLDl+4YzXZy3ADryipqbO xC9NZ0Kn7ZvIDOl33y6HcTq3yc1Wt0wfhmuxcLwmID8SDw7Vq8464IHI+5Bem0U+qnic +aHI4T4aBDqpgYoAE9Zmz1PWxMQud82MpaquI4sIowpsCIHWsXuR0R5/b0PBywXsqTfp MhEP0ocDDj1lB4uNcgCQ8OIVRKisUIeYPw6O7B37N4KkBbUcxVUo7NCnP7lJhFWv41Vi 7qex95AXZ2Kn2U+V1gIunfigEE/nEbHMwk4WaNdu585nXQZdq6pTKsP+QhobQhw3apXI m0Tg== X-Gm-Message-State: AMCzsaWGwt7mipFTlYTpENYN+H1fMYtoyBpxs2nLyAGzNe/ZSW56SANB yiJtVyfFNG20vC9NpTEM0FjcrlJZ X-Google-Smtp-Source: ABhQp+QSDwwSmN4YOk6zOL+0ro4kLZclh7e3x5edIheqc1tKR3lOP1ec/ue4M8IxTqxUTSkuxIVyHA== X-Received: by 10.223.189.13 with SMTP id j13mr11777638wrh.94.1509926184678; Sun, 05 Nov 2017 15:56:24 -0800 (PST) Original-Received: from [192.168.1.3] ([185.105.174.193]) by smtp.googlemail.com with ESMTPSA id a79sm4549310wma.14.2017.11.05.15.56.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Nov 2017 15:56:24 -0800 (PST) In-Reply-To: <87k1z4qvv5.fsf@gmail.com> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 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:219933 Archived-At: On 11/5/17 11:05 PM, João Távora wrote: > FWIW I installed it and quickly hacked up this. It's the same > boilerplate again, with the tiny exception that rubocop needs the file > to be also saved for some reason (pure stdin doesn't work for some > reason). Thanks. Is there a place in the code where you are saving the file? I don't see it. The backend seems to work fine for me in this regard, but that might be dependent on the version, see https://github.com/bbatsov/rubocop/issues/2576. That aside, it seems like it didn't pick up the project configuration file. Here's what worked for me: (defvar-local rubocop--flymake-proc nil) (defvar rubocop-config-file ".rubocop.yml") (defun rubocop-flymake (report-fn &rest _args) "Rubocop backend" (unless (executable-find "rubocop") (error "Cannot find a suitable checker")) (when (process-live-p rubocop--flymake-proc) (kill-process rubocop--flymake-proc)) (let ((source (current-buffer)) (command (list "rubocop" "--stdin" buffer-file-name "--format" "emacs")) config-dir) (when buffer-file-name (setq config-dir (locate-dominating-file buffer-file-name rubocop-config-file)) (when config-dir (setq command (append command (list "--config" (expand-file-name rubocop-config-file config-dir))))) (save-restriction (widen) (setq rubocop--flymake-proc (make-process :name "rubocop-flymake" :noquery t :connection-type 'pipe :buffer (generate-new-buffer " *rubocop-flymake*") :command command :sentinel (lambda (proc _event) (when (eq 'exit (process-status proc)) (unwind-protect (if (with-current-buffer source (eq proc rubocop--flymake-proc)) (with-current-buffer (process-buffer proc) (goto-char (point-min)) (cl-loop while (search-forward-regexp "^\\(?:.*.rb\\|-\\):\\([0-9]+\\):\\([0-9]+\\): \\(.*\\)$" nil t) for msg = (match-string 3) for (beg . end) = (flymake-diag-region source (string-to-number (match-string 1)) (string-to-number (match-string 2))) for type = (if (string-match "^E: " msg) :error :note) collect (flymake-make-diagnostic source beg end type msg) into diags finally (funcall report-fn diags))) (flymake-log :debug "Canceling obsolete check %s" proc)) (kill-buffer (process-buffer proc))))))) (process-send-region rubocop--flymake-proc (point-min) (point-max)) (process-send-eof rubocop--flymake-proc)))))