From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.bugs Subject: bug#25987: 25.2; support gcc fixit notes Date: Sun, 05 Mar 2017 14:47:57 -0700 Message-ID: <87lgsj1jle.fsf@tromey.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 1488750552 21567 195.159.176.226 (5 Mar 2017 21:49:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Mar 2017 21:49:12 +0000 (UTC) To: 25987@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Mar 05 22:49:07 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1cke1a-00057q-Oc for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Mar 2017 22:49:07 +0100 Original-Received: from localhost ([::1]:40512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cke1g-0005xV-Va for geb-bug-gnu-emacs@m.gmane.org; Sun, 05 Mar 2017 16:49:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cke1Z-0005xE-FP for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 16:49:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cke1W-0007Fo-4f for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 16:49:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43250) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cke1W-0007FV-0O for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 16:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cke1V-0000Mn-Qy for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 16:49:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tom Tromey Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Mar 2017 21:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25987 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14887505241381 (code B ref -1); Sun, 05 Mar 2017 21:49:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Mar 2017 21:48:44 +0000 Original-Received: from localhost ([127.0.0.1]:41449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cke1D-0000MC-QX for submit@debbugs.gnu.org; Sun, 05 Mar 2017 16:48:44 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cke1B-0000Lz-0Q for submit@debbugs.gnu.org; Sun, 05 Mar 2017 16:48:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cke14-0006r9-3l for submit@debbugs.gnu.org; Sun, 05 Mar 2017 16:48:35 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:42094) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cke14-0006qy-0B for submit@debbugs.gnu.org; Sun, 05 Mar 2017 16:48:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cke12-0005s4-5X for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 16:48:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cke0y-0006nc-SJ for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 16:48:32 -0500 Original-Received: from gproxy3-pub.mail.unifiedlayer.com ([69.89.30.42]:55020) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1cke0y-0006kJ-8L for bug-gnu-emacs@gnu.org; Sun, 05 Mar 2017 16:48:28 -0500 Original-Received: (qmail 14469 invoked by uid 0); 5 Mar 2017 21:48:06 -0000 Original-Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy3.mail.unifiedlayer.com with SMTP; 5 Mar 2017 21:48:06 -0000 Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id sMo11u0072f2jeq01Mo4bY; Sun, 05 Mar 2017 14:48:06 -0700 X-Authority-Analysis: v=2.1 cv=WOnsABcR c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=6Iz7jQTuP9IA:10 a=ZZ9aQZciIvDeoGKFjbAA:9 a=ao9AAyzj6h5c4hyZ:21 a=uWkv48RfckupUjmw:21 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=4xvU36TKnclxafVxEo3+zRiGEgFIhIWJv7OtpqdOQDM=; b=Kx/YAPUCkc5HWpOPW/S3kJfTzC U2RYl3cigW6J6MLEkt3al4zEKMLIqq4ciPMNIxl8v8zzglYuSrMJXl24XNZQzJOL0Lywj12Q2ESzQ ZhrrOYY+6Jw6PWbsoq0Evqfr0; Original-Received: from 71-218-43-111.hlrn.qwest.net ([71.218.43.111]:54548 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cke0W-0001Xk-Uz; Sun, 05 Mar 2017 14:48:01 -0700 X-Attribution: Tom X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.218.43.111 X-Exim-ID: 1cke0W-0001Xk-Uz X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-43-111.hlrn.qwest.net (bapiya) [71.218.43.111]:54548 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:130226 Archived-At: With -fdiagnostics-parseable-fixits, GCC can emit "fixit" notes that tell how to apply a patch to fix a problem. For example for this: struct x { int field; }; struct x y; int main() { return y.feld; } I get: q.c: In function =E2=80=98main=E2=80=99: q.c:8:12: error: =E2=80=98struct x=E2=80=99 has no member named =E2=80=98fe= ld=E2=80=99; did you mean =E2=80=98field=E2=80=99? return y.feld; ^~~~ field fix-it:"q.c":{8:12-8:16}:"field" The documentation, from the gcc manual: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @item -fdiagnostics-parseable-fixits @opindex fdiagnostics-parseable-fixits Emit fix-it hints in a machine-parseable format, suitable for consumption by IDEs. For each fix-it, a line will be printed after the relevant diagnostic, starting with the string ``fix-it:''. For example: @smallexample fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all" @end smallexample The location is expressed as a half-open range, expressed as a count of bytes, starting at byte 1 for the initial column. In the above example, bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the given string: @smallexample 00000000011111111112222222222 12345678901234567890123456789 gtk_widget_showall (dlg); ^^^^^^^^^^^^^^^^^^ gtk_widget_show_all @end smallexample The filename and replacement string escape backslash as ``\\", tab as ``\t'= ', newline as ``\n'', double quotes as ``\"'', non-printable characters as oct= al (e.g. vertical tab as ``\013''). An empty replacement string indicates that the given range is to be removed. An empty range (e.g. ``45:3-45:3'') indicates that the string is to be inserted at the given position. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D I think Emacs should support this in compilation mode buffers. A few thoughts on the implementation: * The filename quoting stuff will require a bit of unquoting * The offsets are byte offsets, not columns, which is a bit of a pain (or at least, it is for me since I don't know how to handle that in elisp) * One way for this to work would be to display the buffer and=20 show the proposed change as an overlay; and then use y-or-n-p to ask whether it should be applied. I was thinking something like: (defun compilation--fixit-make-overlay (start end text) (let ((overlay (make-overlay start end))) (overlay-put overlay 'face 'diff-removed) (overlay-put overlay 'after-string (propertize text 'face 'diff-added)) overlay)) With this approach perhaps nothing could be done if the fixit was already visited, or if the buffer text already matches the replacement. * However other approaches are possible, like letting the user request no confirmation, or request "auto-apply all changes" or something. Maybe a fixit should be associated with the previous error somehow. * Allowing "fixit" to be handled specially in compile mode might mean adding a new "type" value, not sure. Tom In GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.8) of 2017-03-02 built on bapiya Repository revision: 6e788ef0e262fafc014c21f4ad52cc5dc9f1715b Windowing system distributor 'Fedora Project', version 11.0.11901000 System Description: Fedora release 25 (Twenty Five) Configured using: 'configure --prefix=3D/home/tromey/Emacs/install/ --with-modules' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES Important settings: value of $LANG: en_US.utf8 value of $XMODIFIERS: @im=3Dibus locale-coding-system: utf-8-unix Major mode: Emacs-Lisp Minor modes in effect: shell-dirtrack-mode: t diff-auto-refine-mode: t flyspell-mode: t which-function-mode: t global-auto-revert-mode: t erc-services-mode: t erc-list-mode: t erc-menu-mode: t erc-autojoin-mode: t erc-ring-mode: t erc-networks-mode: t erc-pcomplete-mode: t erc-track-mode: t erc-match-mode: t erc-netsplit-mode: t erc-hl-nicks-mode: t erc-button-mode: t erc-fill-mode: t erc-stamp-mode: t erc-irccontrols-mode: t erc-noncommands-mode: t erc-move-to-prompt-mode: t erc-readonly-mode: t savehist-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-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 column-number-mode: t line-number-mode: t auto-fill-function: do-auto-fill transient-mark-mode: t Recent messages: Discard changes to this group and exit? (y or n) y Are you sure you want to quit reading news? (y or n) y Saving Gnus registry (13456 entries) to ~/.gnus.registry.eieio... Saving Gnus registry (size 13456) to ~/.gnus.registry.eieio...done Saving file /home/tromey/.newsrc... Wrote /home/tromey/.newsrc Saving /home/tromey/.newsrc.eld... Saving file /home/tromey/.newsrc.eld... Wrote /home/tromey/.newsrc.eld Saving /home/tromey/.newsrc.eld...done Load-path shadows: /home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/ins= tall/share/emacs/25.2/lisp/play/bubbles /home/tromey/.emacs.d/elpa/soap-client-3.1.1/soap-inspect hides /home/trome= y/Emacs/install/share/emacs/25.2/lisp/net/soap-inspect /home/tromey/.emacs.d/elpa/soap-client-3.1.1/soap-client hides /home/tromey= /Emacs/install/share/emacs/25.2/lisp/net/soap-client Features: (org-bullets org-element org-rmail org-mhe org-irc org-info org-gnus org-docview doc-view image-mode org-bibtex bibtex org-bbdb org-w3m org org-macro org-footnote org-pcomplete org-list org-faces org-entities noutline outline org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint ob-core ob-eval org-compat org-macs org-loaddefs gnus-html xml url-cache mm-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf gnus-draft xref project mail-hist nnir url-util url-parse url-vars shr-color shr dom subr-x browse-url flow-fill mm-archive smiley gnus-cite gnus-async gnus-bcklg qp gnus-ml disp-table gnus-topic nndraft nnmh nnfolder utf-7 bbdb-gnus bbdb-mua bbdb-com crm gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg nntp gnus-cache gnus-registry registry eieio-compat eieio-base gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range gnus-win gnus gnus-ems nnheader cus-edit find-dired bug-reference texinfo vc-mtn vc-hg tabify man term/xterm xterm shadow emacsbug network-stream nsm starttls tls gnutls mailalias smtpmail sort mailcap bbdb-message sendmail mail-extr vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs whitespace log-edit message idna dired rfc822 mml mml-sec epg mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils gmm-utils mailheader pcvs-util cc-mode cc-fonts cc-guess cc-menus cc-cmds shell rx dabbrev eieio-opt speedbar sb-image ezimage dframe find-func copyright debug add-log vc-git diff-mode easy-mmode misearch multi-isearch jka-compr flyspell ispell diminish edmacro kmacro projectile grep compile ibuf-ext ibuffer dash appt diary-lib diary-loaddefs cal-menu calendar cal-loaddefs which-func imenu minimap autorevert filenotify cus-start cus-load status erc-services erc-list erc-menu erc-join erc-ring erc-networks erc-pcomplete pcomplete erc-track erc-match erc-netsplit erc-hl-nicks color erc-button erc-fill erc-stamp wid-edit erc-goodies erc erc-backend erc-compat format-spec auth-source eieio gnus-util mm-util help-fns mail-prsvr password-cache thingatpt pp warnings advice vc-dir ewoc vc vc-dispatcher cc-styles cc-align cc-engine cc-vars cc-defs bbdb bbdb-site timezone ange-ftp comint ansi-color ring server savehist finder-inf dwarf-mode-autoloads gdb-shell-autoloads eieio-core lisppaste-autoloads pydoc-info-autoloads info-look cl-seq cl-macs cl weblogger-autoloads info package epg-config seq byte-opt gv bytecomp byte-compile cl-extra help-mode easymenu cconv cl-loaddefs pcase cl-lib bbdb-loaddefs time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame 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 charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 997972 86208) (symbols 48 117986 0) (miscs 40 21518 46) (strings 32 431164 32131) (string-bytes 1 10881610) (vectors 16 99059) (vector-slots 8 2222084 4114) (floats 8 851 728) (intervals 56 31730 1034) (buffers 976 62))