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: Three Flymake backends Was Re: Two issues with the new Flymake Date: Sun, 05 Nov 2017 21:05:50 +0000 Message-ID: <87k1z4qvv5.fsf@gmail.com> 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> 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 1509915999 16397 195.159.176.226 (5 Nov 2017 21:06:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Nov 2017 21:06:39 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: Mark Oteiza , Lele Gaifax , Stefan Monnier , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 05 22:06:33 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 1eBS7k-00041Z-Vx for ged-emacs-devel@m.gmane.org; Sun, 05 Nov 2017 22:06:33 +0100 Original-Received: from localhost ([::1]:45668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBS7q-0000RB-Io for ged-emacs-devel@m.gmane.org; Sun, 05 Nov 2017 16:06:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBS7C-0000R6-5Z for emacs-devel@gnu.org; Sun, 05 Nov 2017 16:05:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBS78-0007il-W4 for emacs-devel@gnu.org; Sun, 05 Nov 2017 16:05:58 -0500 Original-Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:53428) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBS78-0007iR-OU for emacs-devel@gnu.org; Sun, 05 Nov 2017 16:05:54 -0500 Original-Received: by mail-wr0-x244.google.com with SMTP id u40so6811850wrf.10 for ; Sun, 05 Nov 2017 13:05:54 -0800 (PST) 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=CJHJD6mvOBzvSCMSzO6rHUpziHucg3qCWYXbyAAARTk=; b=qDBQB2XvYRKDUURLJ/vvNA/AhAC5/Mqd+eeMH9xu7ObN9kdleR4cZKHbZ8Mjr9DS6q yrKi8Jyz/W/jx7/dfvDZhaZwlpPUnPy0yaHJn1YU8I/rl6aRR7ANAjCqinActYdJ3Y8b B8fmZrmbkUEWGixM/jhWprohE5IJIpA1LTwDcastBh+mnj2hhPoIa6DUZN5dvMrTkjWk iXqj1g4JeYxqb4terYYR/bz4Hv95iewJdFwYbPy8fqCqI7HXOZWzelriGbkd6QcYm0IG HpL32jFsQaWwBEG0PXzm6UvoS6Lwv5SYlkoWUghGj1JTVZCBN4Il0eN11Mv4k/SWdcEY UhRw== 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=CJHJD6mvOBzvSCMSzO6rHUpziHucg3qCWYXbyAAARTk=; b=XSVwlwxAweITzK/NwezFynxtOhCzYJMPFQDlyphq6O6Z8GtH5bEPjNYC/lfL13GKhq 7MKCPq+cYv7Ee1+eJwM0QV6s1vmDVoXvTFP4iw6F6KZbj6LDRCISWkd03fDnmeIbtwyr pulfNssvgiZpqt9jUv2cXmzftxg+d37WXbl/cAsw9upACebW/ftIiCsvqYnW42xOGDWy Y//KBi/g9yG0flvou7ZR+LqgcC6YstYnTbe7I1njrdeGX9PCLrG7JiojFab10k5Dhsjo Kf54VOMAXylAW4ZxP1XA0/96s6OFUlL+JE9XRZVMyPLxuXUlBKeKVUoG14eRjoKKndmb eV4Q== X-Gm-Message-State: AMCzsaUZiaAEHP2lKksuQFBASoxmxw7L6sxMZTuQGWvoc3mq7vMm4MFC 76SrIykRLlXmuDj+3d7z51/lPQgW X-Google-Smtp-Source: ABhQp+TreKhjajL6Cn2ErX0Moc7k7z+jJF/vYa9ogLhI6onwA3RFl/j44KxFJT2pJ77uZSxo1vIH8g== X-Received: by 10.223.134.106 with SMTP id 39mr10403051wrw.134.1509915953409; Sun, 05 Nov 2017 13:05:53 -0800 (PST) Original-Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id o11sm10686783wrg.5.2017.11.05.13.05.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Nov 2017 13:05:52 -0800 (PST) In-Reply-To: <829794de-27ca-383e-2b3a-a5bc4405581b@yandex.ru> (Dmitry Gutov's message of "Sun, 5 Nov 2017 22:14:48 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 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:219932 Archived-At: Dmitry Gutov writes: > On 11/5/17 3:22 PM, Jo=C3=A3o T=C3=A1vora wrote: > >> I think the doors are still open for the "sooner" case :-) I don't have >> rubucop, but defining new backends of the >> "feed-to-stdin-then-parse-with-regexp" type is really easy (and of >> really verbose, but we're trying to fix that) > > OK, I'll keep that in mind. :) 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). (defvar-local rubocop--flymake-proc nil) (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))) (when buffer-file-name (save-restriction (widen) (setq rubocop--flymake-proc (make-process :name "rubocop-flymake" :noquery t :connection-type 'pipe :buffer (generate-new-buffer " *rubocop-flymake*") :command `("rubocop" "--stdin" ,buffer-file-name "--format" "emac= s") :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 =3D (match-string 3) for (beg . end) =3D (flymake-diag-region source (string-to-number (match-string= 1)) (string-to-number (match-string= 2))) for type =3D (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))))) > The defalias way should be all right with remove-hook, though. Yes, and exposing the function that returns the lambda is also OK. > I'm in the "don't create new macros unless it's _really_ beneficial" > camp, though it might be in the minority here. I'm with you on that camp. However macros that create functions or defmethod, if done in the standard fashion, almost always escape that razor.