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: Thu, 05 Oct 2017 17:22:02 -0400 Message-ID: <87efqh2sud.fsf@udel.edu> References: <87h8vmj3tr.fsf@lolita> <1507138648.1972.0@smtp.gmail.com> <874lre2von.fsf@gmail.com> <87mv566yjx.fsf@udel.edu> <87shex276r.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 1507238543 4827 195.159.176.226 (5 Oct 2017 21:22:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 5 Oct 2017 21:22:23 +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?= =?utf-8?Q?=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 23:22:16 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 1e0Dau-0000Jv-JK for ged-emacs-devel@m.gmane.org; Thu, 05 Oct 2017 23:22:12 +0200 Original-Received: from localhost ([::1]:42078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0Db2-00066i-19 for ged-emacs-devel@m.gmane.org; Thu, 05 Oct 2017 17:22:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32994) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0Daq-000662-D7 for emacs-devel@gnu.org; Thu, 05 Oct 2017 17:22:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0Dan-0000P0-7i for emacs-devel@gnu.org; Thu, 05 Oct 2017 17:22:08 -0400 Original-Received: from mail-qk0-x231.google.com ([2607:f8b0:400d:c09::231]:52991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e0Dan-0000OS-1R for emacs-devel@gnu.org; Thu, 05 Oct 2017 17:22:05 -0400 Original-Received: by mail-qk0-x231.google.com with SMTP id b15so14017906qkg.9 for ; Thu, 05 Oct 2017 14:22:04 -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=ZfWub6T7DWLODkkEQMWzslvnQxC9F68+Kp84ElGHbrc=; b=UFpOp8RlJ3NQnFwkVtAtZ1HcfC9WhurEtoYlIXyCm561mfyFtiWqXWmsON5gppx+t4 ttlJUdHA4eJeWPJJUDCstCHhq7xFz0CcP1mRoEAqn0uvjes9p77JTZyWmXaqC/QkMU8Q 7yVUv/i6Hf+Fy2WEpkSgZpGH5VwBkREkO+LSicarl5sHNKAgMaD47D6Az7QrwACGOv2U Km5tmd2NLsZNNSYQIsfx1JzLaEqQmVQRz+bRVqAWY90ABJg0XTo0F0r9xPmZ3Nle2M2+ lscrV+fn6CV3It9rZOzN+9XG5jqcKdPZX9Pw7HgQaMLC6dO231YYc5FnD3ragoKxGXMk vqlA== 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=ZfWub6T7DWLODkkEQMWzslvnQxC9F68+Kp84ElGHbrc=; b=c1Ld7zv35i0OmIgA90UJjHkQwACHdQI2S/o1pFUhUb/mAquFtdWk/EUIWCkQrnS6QE aRrkcKcHcjQ+p8sKWziDAepGXXQ2CGCc75lg62ELHmkx7vk1HWWlHtjoqcdTgAyAjvs0 cHCPpLJ6XaJNj4JgBbFSe7LXxx9X5sx2fUq7ZetTY0JZRWVNhupfDu72XcDuzMLK/adZ Rojfe5ff6gberbG31kdqnr0xv1clehp4aZCX2vXJ8tI8yzL4l5lyk+jqDGVoZhrY7Hbv HkkPaqCu6AMPOrTY7gxP68Nu5rpZFCAP61CFGmMFvoumuV+IWzsCW5ew19/UL3z2y/GU 7ZIQ== X-Gm-Message-State: AMCzsaVb1x2eLenhYzHbUAdvOFWcEc7uq6HmPkgFfoX7zC9pkyiYOxRs zWOA1Bn3zMCIT4xzkN4pdM84RQ== X-Google-Smtp-Source: AOwi7QCGIXPnxwh4amdIAIdHRWSF8Qxx5AVmUKEPGXkL5yxvo6KEM/9Qpc7SIB4rCeuLV1hsCpBF8g== X-Received: by 10.55.220.2 with SMTP id v2mr32856505qki.64.1507238524201; Thu, 05 Oct 2017 14:22:04 -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 g1sm12598782qta.95.2017.10.05.14.22.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 14:22:03 -0700 (PDT) In-Reply-To: <87shex276r.fsf@gmail.com> (=?utf-8?Q?=22Jo=C3=A3o_T=C3=A1vor?= =?utf-8?Q?a=22's?= message of "Thu, 05 Oct 2017 11:57:32 +0100") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::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:219148 Archived-At: joaotavora@gmail.com (Jo=C3=A3o T=C3=A1vora) writes: > Mark Oteiza writes: >> 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. Ah, thank you. > 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. Nice. Adding to the pile, a LaTeX checker with chktex below. > 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. At first sight it looks like the much of the sentinel contents could be abstracted away in something like compilation mode's error regexp alists ;;; flymake-chktex.el --- Flymake backend for chktex(1) -*- lexical-binding= : t -*- ;;; Code: (defgroup flymake-chktex () "Flymake backend for chktex" :link '(url-link "http://www.nongnu.org/chktex/") :group 'flymake) (defcustom flymake-chktex-program "chktex" "Program." :type 'string :group 'flymake-chktex) (defvar-local flymake-chktex--process nil) (defun flymake-chktex-command (program) `(,program "--quiet" "--verbosity=3D0" "--inputfiles")) (defun flymake-chktex (report-fn &rest _args) (unless (executable-find flymake-chktex-program) (error "Cannot find a suitable chktex")) (when (process-live-p flymake-chktex--process) (kill-process flymake-chktex--process)) (let ((source (current-buffer))) (save-restriction (widen) (setq flymake-chktex--process (make-process :name "flymake-chktex" :buffer (generate-new-buffer "*flymake-chktex*") :command (flymake-chktex-command flymake-chktex-program) :noquery t :connection-type 'pipe :sentinel (lambda (process _event) (unwind-protect (when (eq process flymake-chktex--process) (with-current-buffer (process-buffer process) (goto-char (point-min)) (cl-loop while (search-forward-regexp "^stdin:\\([0-9]+\\):\\([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))) collect (flymake-make-diagnostic source beg end :wa= rning msg) into diags finally (funcall report-fn diags)))) (kill-buffer (process-buffer process)))))) (process-send-region flymake-chktex--process (point-min) (point-max)) (process-send-eof flymake-chktex--process)))) (defun flymake-chktex-register () (add-hook 'flymake-diagnostic-functions 'flymake-chktex nil t)) (add-hook 'plain-tex-mode-hook 'flymake-chktex-register) (add-hook 'latex-mode-hook 'flymake-chktex-register) (add-hook 'bibtex-mode-hook 'flymake-chktex-register) (provide 'flymake-chktex) ;;; flymake-chktex.el ends here