From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#51380: 29.0.50; The annotated example of a complete working Flymake backend leaves process buffers around Date: Sun, 24 Oct 2021 22:01:38 +0200 Message-ID: Reply-To: Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37087"; mail-complaints-to="usenet@ciao.gmane.io" To: 51380@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 24 22:02:22 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mejhF-0009N1-T9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 22:02:22 +0200 Original-Received: from localhost ([::1]:60498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mejhE-0003rs-4u for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Oct 2021 16:02:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mejgy-0003rZ-Al for bug-gnu-emacs@gnu.org; Sun, 24 Oct 2021 16:02:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57726) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mejgw-0005Wg-Gv for bug-gnu-emacs@gnu.org; Sun, 24 Oct 2021 16:02:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mejgw-00038A-E9 for bug-gnu-emacs@gnu.org; Sun, 24 Oct 2021 16:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Oct 2021 20:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51380 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163510571512020 (code B ref -1); Sun, 24 Oct 2021 20:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Oct 2021 20:01:55 +0000 Original-Received: from localhost ([127.0.0.1]:41039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mejgo-00037n-St for submit@debbugs.gnu.org; Sun, 24 Oct 2021 16:01:55 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:35636) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mejgn-00037g-4D for submit@debbugs.gnu.org; Sun, 24 Oct 2021 16:01:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mejgm-0003pd-St for bug-gnu-emacs@gnu.org; Sun, 24 Oct 2021 16:01:52 -0400 Original-Received: from pv50p00im-ztdg10011201.me.com ([17.58.6.39]:54841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mejgi-0004r1-NB for bug-gnu-emacs@gnu.org; Sun, 24 Oct 2021 16:01:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1635105702; bh=+LdygqHFZQ7pb2i/39pD/okFxA1EZ3fyphYjHuwAik8=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=RBUWjKbALDs59zzmIz3RKLi/ExJfeSTvEtpTfL7RxpyqTCQuk9WP+q/6p16/rigH5 HkL8U3eYnluXtewjJRUS7Tf/9mMpFBfSNVGNN3l4ETdoM9mno/kvxbB9mNEXl9xlxD lNYd0g3y9WcqWKUbVGDvRc8gb1572nJZJ/CqYZKuVokNR072RdsBT2/+e3Ea8p4uUu 2j+X12GELXAbp9hrHhpK4TgbiXisOA0BjawNqPluR4bi2LOIyZPmuNchNyTTodzP5A l/ltb8MfV3BYpKCDbduR/47b2EN9Dl/Ac4vYEF/Xyid0+gsxjj/tNjPQx7wxOV3S44 UqvwB+lUo4+Dg== Original-Received: from Workstation.local (78-141-116-131.dynamic.orange.sk [78.141.116.131]) by pv50p00im-ztdg10011201.me.com (Postfix) with ESMTPSA id DF7792A0346 for ; Sun, 24 Oct 2021 20:01:41 +0000 (UTC) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.425, 18.0.790 definitions=2021-10-24_06:2021-10-22, 2021-10-24 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2009150000 definitions=main-2110240136 Received-SPF: pass client-ip=17.58.6.39; envelope-from=salutis@me.com; helo=pv50p00im-ztdg10011201.me.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:218196 Archived-At: I noticed that the "annotated example of a complete working Flymake backend= " at leaves zombie buffers around. I traced the problem down to =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 (when (eq 'exit (process-status proc)) =E2=80=A6 =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 The backend kills the process buffer on `'exit' but not on `'signal', which= happens when Flymake kills an obsolete in-progress check. I fixed the prob= lem locally by checking for both `(or (eq status 'exit) (eq status 'signal)= '. Below, I include a macro that includes the fix. =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 (defmacro my-define-flymake-backend (name cmd regexp warning-p) =E2=94=82 "Define a new Flymake backend named NAME. =E2=94=82=20 =E2=94=82 CMD takes a buffer file name and returns a system command =E2=94=82 to run to check the buffer. REGEXP matches the output of the syst= em =E2=94=82 command in three capture groups: (1) line, (2) column, and (3) =E2=94=82 message. WARNING-P takes the message matched by REGEXP and decide= s if =E2=94=82 the issue represents a warning or an error. =E2=94=82=20 =E2=94=82 The macro defines a function called NAME representing the Flymake =E2=94=82 backend and a variable called NAME that stores the current proces= s." =E2=94=82 `(defun ,name (report-fn &rest _args) =E2=94=82 (defvar-local ,name nil) =E2=94=82 (when (process-live-p ,name) (kill-process ,name)) =E2=94=82 (let ((src (current-buffer))) =E2=94=82 (save-restriction =E2=94=82 (widen) =E2=94=82 (setq =E2=94=82 ,name =E2=94=82 (make-process =E2=94=82 :name (symbol-name ',name) =E2=94=82 :noquery t =E2=94=82 :connection-type 'pipe =E2=94=82 :buffer (generate-new-buffer =E2=94=82 (concat "*" (symbol-name ',name) "*")) =E2=94=82 :command (with-current-buffer src =E2=94=82 (funcall ,cmd buffer-file-name)) =E2=94=82 :sentinel =E2=94=82 (lambda (proc _event) =E2=94=82 (let ((status (process-status proc))) =E2=94=82 (when (or (eq status 'exit) =E2=94=82 (eq status 'signal)) =E2=94=82 (unwind-protect =E2=94=82 (when (and (with-current-buffer src (eq proc= ,name)) =E2=94=82 (eq status 'exit)) =E2=94=82 (with-current-buffer (process-buffer proc) =E2=94=82 (goto-char (point-min)) =E2=94=82 (cl-loop =E2=94=82 while (search-forward-regexp ,regexp ni= l t) =E2=94=82 for msg =3D (match-string 3) =E2=94=82 for line =3D (string-to-number (match-s= tring 1)) =E2=94=82 for col =3D (string-to-number (match-st= ring 2)) =E2=94=82 for (beg . end) =3D (flymake-diag-regio= n src line col) =E2=94=82 for type =3D (if (funcall ,warning-p ms= g) :warning :error) =E2=94=82 collect (flymake-make-diagnostic src be= g end type msg) =E2=94=82 into diags =E2=94=82 finally (funcall report-fn diags)))) =E2=94=82 (kill-buffer (process-buffer proc)))))))) =E2=94=82 (process-send-region ,name (point-min) (point-max)) =E2=94=82 (process-send-eof ,name))))) =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 For completeness, I call the macro above as follows: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 (my-define-flymake-backend =E2=94=82 my-flymake-vale =E2=94=82 (lambda (source) (list "vale" "--output" "line" "--ext" ".md", "= --no-wrap")) =E2=94=82 "^stdin.md:\\([0-9]+\\):\\([0-9]+\\):\\(.*\\)$" =E2=94=82 (lambda (msg) t)) =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 Rudy In GNU Emacs 29.0.50 (build 6, x86_64-apple-darwin20.6.0, NS appkit-2022.60= Version 11.5.1 (Build 20G80)) of 2021-10-24 built on Workstation.local Repository revision: aea4af5119fdf130f1df7190478a23c6777f92a2 Repository branch: master Windowing system distributor 'Apple', version 10.3.2022 System Description: macOS 11.5.1 Configured using: 'configure --with-json PKG_CONFIG_PATH=3D/usr/local/Cellar/zlib/1.2.11/lib/pkgconfig:/usr/local/l= ib/pkgconfig:/opt/X11/lib/pkgconfig' Configured features: ACL DBUS GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER PNG RSVG THREADS TIFF TOOLKIT_SCROLL_BARS WEBP XIM ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Text Minor modes in effect: TeX-PDF-mode: t shell-dirtrack-mode: t flymake-mode: t which-key-mode: t corfu-global-mode: t corfu-mode: t vertico-mode: t marginalia-mode: t global-diff-hl-mode: t yas-global-mode: t yas-minor-mode: t global-hl-todo-mode: t hl-todo-mode: t savehist-mode: t global-subword-mode: t subword-mode: t save-place-mode: t global-auto-revert-mode: t delete-selection-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t column-number-mode: t line-number-mode: t global-visual-line-mode: t visual-line-mode: t transient-mark-mode: t Load-path shadows: /Users/salutis/.emacs.d/elpa/transient-20211023.2151/transient hides /Users= /salutis/src/emacs/nextstep/Emacs.app/Contents/Resources/lisp/transient Features: (shadow sort bbdb-message fortune mail-extr emacsbug sendmail ox-md ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda org-refile ox-html table ox-ascii ox-publish ox bug-reference helpful imenu trace edebug backtrace info-look help-fns radix-tree elisp-refs vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs preview tex-buf font-latex latex edmacro latex-flymake tex-ispell tex-style tex crm texmathp tex-mode shell flymake-proc flymake project warnings org-indent image-file image-converter disp-table char-fold cursor-sensor bbdb bbdb-site timezone modus-vivendi-theme modus-operandi-theme modus-themes which-key corfu orderless consult-vertico vertico marginalia consult recentf tree-widget kmacro pdf-loader diff-hl log-view pcvs-util vc-dir ewoc vc diminish yasnippet hl-todo finder-inf org-clock oc-csl citeproc citeproc-itemgetters citeproc-biblatex citeproc-bibtex parsebib citeproc-cite citeproc-subbibs citeproc-sort citeproc-name citeproc-formatters citeproc-number rst compile citeproc-proc citeproc-disamb citeproc-itemdata citeproc-generic-elements citeproc-macro citeproc-choose citeproc-date citeproc-context citeproc-prange citeproc-style citeproc-locale citeproc-term f citeproc-rt citeproc-lib citeproc-s s let-alist queue dash savehist ls-lisp cap-words superword subword saveplace autorevert filenotify delsel elfeed-link elfeed-show elfeed-search elfeed-csv elfeed elfeed-curl elfeed-log xml-query bookmark pp elfeed-db elfeed-lib vc-git diff-mode vc-dispatcher org-element avl-tree generator ol-eww eww xdg url-queue thingatpt mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message rmc puny rfc822 mml mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search mail-utils mm-util mail-prsvr wid-edit ol-docview doc-view jka-compr image-mode exif dired dired-loaddefs ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi cl-extra help-mode org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint ansi-color ring org-list org-faces org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex iso8601 time-date ol rx org-keys oc org-compat advice org-macs org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs tex-site info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind kqueue cocoa ns lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 887550 54338) (symbols 48 45003 4) (strings 32 241995 11585) (string-bytes 1 6618139) (vectors 16 86621) (vector-slots 8 1813636 54587) (floats 8 435 550) (intervals 56 24349 524) (buffers 992 23)) --=20 "I love deadlines. I love the whooshing noise they make as they go by." -- = Douglas Adams, The Salmon of Doubt Rudolf Adamkovi=C4=8D Studenohorsk=C3=A1 25 84103 Bratislava Slovakia [he/him]