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: New Flymake rewrite in emacs-26 Date: Tue, 10 Oct 2017 16:09:07 +0100 Message-ID: <87tvz79h0s.fsf@gmail.com> References: <8760bwz5qf.fsf@gmail.com> <83infw1dkz.fsf@gnu.org> <87efqbb35x.fsf@gmail.com> <831smbqe70.fsf@gnu.org> 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 1507648217 8047 195.159.176.226 (10 Oct 2017 15:10:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 10 Oct 2017 15:10:17 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) Cc: sdl.web@gmail.com, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 10 17:10:06 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 1e1wAX-0000kf-97 for ged-emacs-devel@m.gmane.org; Tue, 10 Oct 2017 17:10:05 +0200 Original-Received: from localhost ([::1]:35537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1wAe-00030h-Ki for ged-emacs-devel@m.gmane.org; Tue, 10 Oct 2017 11:10:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1w9m-0002zF-Rz for emacs-devel@gnu.org; Tue, 10 Oct 2017 11:09:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1w9g-0000kI-LW for emacs-devel@gnu.org; Tue, 10 Oct 2017 11:09:18 -0400 Original-Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:54055) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1w9g-0000jl-BV; Tue, 10 Oct 2017 11:09:12 -0400 Original-Received: by mail-wm0-x234.google.com with SMTP id q132so6282973wmd.2; Tue, 10 Oct 2017 08:09:12 -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=Nrl3OLWdnCTQQEO3YRrim/wlTTomuaa6d3+MM3ok3bM=; b=N8pw8lbUI9bJZOHc0+YU41aYS0vQY4roMiHS2idhPf/UKfrTgiIL1cBip6TdMD3xsv KpUhtfHg6aC3nJz3XBGThptyHm832YLJOltVZa0AwQFOKjcLVYt7jJGxMFMYtnVV/FsQ esuWLEy2Wezl4X/a/UW/CaqXUXqRGJRc1cUxyUVTfG9HGQFEM4Fdt/w75nGebBBJSXBx 666Tc4bRE5dOEnHtyCHc7Wl2QjYiJqpsSs9X0L/pnH1DfhoCO9kIJskA6HXeO0STDmSA spfRHqUtFy64/+YZ/EHr5XCs6YhVYTpii7xExkWcLYzFLYxFVCm75LzOpmHv2ukrwhLW 8GPw== 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=Nrl3OLWdnCTQQEO3YRrim/wlTTomuaa6d3+MM3ok3bM=; b=B6blmE1rHXE7Sk9R6LTVWXzGXHV459a+oNSlrX1yJMxbl7qasE9A1yB8/iyVdLeEO/ ziS9ofp0UL+uR04PSHj7ENVE+34xD0LkJKmvisZl5WswNm9QKpEP7G1BIZSfJ3J2OAGU mVMSUnru4tJLcr1K4n6C1RbgxXd5C5tauXqUyMRLUcAWxFGl/jghEVLwgAyepE7z7CqM LRalN6HzSBMREZ/7Pg3XqaX891oj0z7GlZZQnOucVhpZGrJjqMoLAdvoLjGhkaTAQCeI 9EJWAWafSlYd1B16gyUxyJcm7bYOLdzfKwiqbEyh87oLngL/X7rgi5bAxG74iYCbfrpG JluA== X-Gm-Message-State: AMCzsaUlAXFFHeeGukt45J4np7T5P9XUGjfTE/NR+mS/ULXhnbyxHFXB dUsAceIBrr2R9HnwVIF6l5Y= X-Google-Smtp-Source: AOwi7QBz2SHHFLGUf0cgQWdGfcowfffrhvQCjvt8Zi7C5urhq3i8SsDkcvmHM7ymlPNNfdQV4TfZDA== X-Received: by 10.223.157.137 with SMTP id p9mr9317207wre.98.1507648151075; Tue, 10 Oct 2017 08:09:11 -0700 (PDT) Original-Received: from lolita.yourcompany.com ([194.117.2.109]) by smtp.gmail.com with ESMTPSA id c142sm13569858wmh.39.2017.10.10.08.09.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2017 08:09:09 -0700 (PDT) In-Reply-To: <831smbqe70.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Oct 2017 17:18:11 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::234 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:219339 Archived-At: Eli Zaretskii writes: > Thanks, I've proofread it and made several fixes, please take a look. > (I can explain each change I made, if it is not immediately apparent > from the change itself or the log message.) No need, looks very good, thanks. >> > This should be in NEWS, perhaps after adjusting the style a bit. >>=20 >> I'm not great at summarizing changes in a NEWS-snazzy manner, but a >> patch is attached. > > Looks good, see a couple of minor comments below. > >> Apart from that, I see these loose ends: >>=20 >> * Are we keeping track of the Flymake backends developed by people? > > You mean, in the manual? I'd prefer not to, since such information > quickly becomes obsolete, and keeping it up to date imposes a > maintenance burden we'd better avoided. > > If you mean track them somewhere else, please tell. No, I meant generally keep track of the backends that surfaced in this list and merge them into the relevant major-mode in emacs-26 (in keeping with your decision that they should be merged if they work reasonably well). >> * Should Flymake do something with next-error-function? > > I thought it already did? It doesn't. And I should have said 'next-error' more generally. IIUC the place for next-error-function is for major modes, which flymake-mode isn't (but its proposed diagnostics buffer is). Anyway I think the problem is that next-error will have a hard time (if it doesn't already) choosing between its "next-error" source: the compilation, and grep occur buffers, and now the constantly updated list of Flymake annotations. >> * There is a "Flymake diagnostics buffer" sub-feature in >> scratch/flymake-diagnostics-buffer. It is reasonably stable. Is it >> OK to merge into emacs-26? > > If it's easy to show a diff for such a merge, please do. Patch is attached (though I don't really understand if you want to see the diff or rather ensure that a diff is possible and easy to revert if problems arise) > It doesn't seem worth the hassle. Most users will be programmers > anyway. Possibly not elisp programmers, but OK. > Otherwise, please push these [NEWS] changes, and thanks. Done. Jo=C3=A3o diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 4c4d6aef32..6796fc2b76 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -605,7 +605,12 @@ flymake-is-running (flymake-log :debug "backend %s reported %d diagnostics in %.2= f second(s)" backend (length new-diags) - (- (float-time) flymake-check-start-time))))))))) + (- (float-time) flymake-check-start-time))) + (when (and (get-buffer (flymake--diagnostics-buffer-name)) + (get-buffer-window (flymake--diagnostics-buffer-name)) + (null (cl-set-difference (flymake-running-backends) + (flymake-reporting-backends)= ))) + (flymake-show-diagnostics-buffer)))))))) =20 (defun flymake-make-report-fn (backend &optional token) "Make a suitable anonymous report function for BACKEND. @@ -869,6 +874,7 @@ flymake-goto-prev-error [ "Go to previous error" flymake-goto-prev-error t ] [ "Check now" flymake-start t ] [ "Go to log buffer" flymake-switch-to-log-buffer t ] + [ "Show error buffer" flymake-show-diagnostics-buffer t ] "--" [ "Turn off Flymake" flymake-mode t ])) =20 @@ -977,6 +983,102 @@ flymake--mode-line-format '(:propertize " ")) (:propertize "]"))))))) =20 + +;;; Diagnostics buffer + +(defvar-local flymake--diagnostics-buffer-source nil) + +(defvar flymake-diagnostics-buffer-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "RET") 'flymake-goto-diagnostic) + (define-key map (kbd "SPC") 'flymake-show-diagnostic) + map)) + +(defun flymake-show-diagnostic (pos &optional other-window) + "Show location of diagnostic at POS." + (interactive (list (point) t)) + (let* ((id (or (tabulated-list-get-id pos) + (user-error "Nothing at point"))) + (overlay (plist-get id :overlay))) + (with-current-buffer (overlay-buffer overlay) + (with-selected-window + (display-buffer (current-buffer) other-window) + (goto-char (overlay-start overlay)) + (pulse-momentary-highlight-region (overlay-start overlay) + (overlay-end overlay) + 'highlight)) + (current-buffer)))) + +(defun flymake-goto-diagnostic (pos) + "Show location of diagnostic at POS. +POS can be a buffer position or a button" + (interactive "d") + (pop-to-buffer + (flymake-show-diagnostic (if (button-type pos) (button-start pos) pos))= )) + +(defun flymake--diagnostics-buffer-entries () + (with-current-buffer flymake--diagnostics-buffer-source + (cl-loop for ov in (flymake--overlays) + for diag =3D (overlay-get ov + 'flymake--diagnostic) + for (line . col) =3D + (save-excursion + (goto-char (overlay-start ov)) + (cons (line-number-at-pos) + (- (point) + (line-beginning-position)))) + for type =3D (flymake--diag-type diag) + collect + (list (list :overlay ov + :line line + :severity (flymake--lookup-type-property + type + 'severity (warning-numeric-level :erro= r))) + `[,(format "%s" line) + ,(format "%s" col) + ,(propertize (format "%s" type) + 'face (flymake--lookup-type-property + type 'mode-line-face 'flymake-err= or)) + (,(format "%s" (flymake--diag-text diag)) + mouse-face highlight + help-echo "mouse-2: visit this diagnostic" + face nil + mouse-action flymake-goto-diagnostic)])))) + +(define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode + "Flymake diagnostics" + "A mode for listing Flymake diagnostics." + (setq tabulated-list-format + `[("Line" 5 (lambda (l1 l2) + (< (plist-get (car l1) :line) + (plist-get (car l2) :line))) + :right-align t) + ("Col" 3 nil :right-align t) + ("Type" 8 (lambda (l1 l2) + (< (plist-get (car l1) :severity) + (plist-get (car l2) :severity)))) + ("Message" 0 t)]) + (setq tabulated-list-entries + 'flymake--diagnostics-buffer-entries) + (tabulated-list-init-header)) + +(defun flymake--diagnostics-buffer-name () + (format "*Flymake diagnostics for %s*" (current-buffer))) + +(defun flymake-show-diagnostics-buffer () + "Show a list of Flymake diagnostics for current buffer." + (interactive) + (let* ((name (flymake--diagnostics-buffer-name)) + (source (current-buffer)) + (target (or (get-buffer name) + (with-current-buffer (get-buffer-create name) + (flymake-diagnostics-buffer-mode) + (setq flymake--diagnostics-buffer-source source) + (current-buffer))))) + (with-current-buffer target + (revert-buffer) + (display-buffer (current-buffer))))) + (provide 'flymake) =20 (require 'flymake-proc)