From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.devel Subject: Re: Syntactic fontification of diff hunks Date: Fri, 17 Aug 2018 13:47:57 +0700 Message-ID: References: <87in4af29r.fsf@mail.linkov.net> 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 1534488371 992 195.159.176.226 (17 Aug 2018 06:46:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 17 Aug 2018 06:46:11 +0000 (UTC) Cc: Emacs developers To: =?UTF-8?Q?Andreas_R=C3=B6hler?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 17 08:46:07 2018 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 1fqYWL-00009d-Sf for ged-emacs-devel@m.gmane.org; Fri, 17 Aug 2018 08:46:05 +0200 Original-Received: from localhost ([::1]:60275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqYYS-00084Z-9a for ged-emacs-devel@m.gmane.org; Fri, 17 Aug 2018 02:48:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqYYM-00084S-Fp for emacs-devel@gnu.org; Fri, 17 Aug 2018 02:48:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqYYL-0003Dk-Np for emacs-devel@gnu.org; Fri, 17 Aug 2018 02:48:10 -0400 Original-Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:40930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqYYL-0003Cp-HL for emacs-devel@gnu.org; Fri, 17 Aug 2018 02:48:09 -0400 Original-Received: by mail-oi0-x22f.google.com with SMTP id w126-v6so12362865oie.7 for ; Thu, 16 Aug 2018 23:48:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=m88+MfC6E1gPplRKBa8uNifN5WOD/cY6ElqZkQQjHEc=; b=DXJsOSgU9maeL6qu9lOy4WnPQQwYcb4ausiu20CkptfnyX7o8S0qycz0xLsWuLsYQ7 +WCQum7I+e2V6nLsDkbklITrvnvgtLBxjxeW6YxLew+9Rxf71FAEt0VjP+RnPy13d+yF G0qWhL3+Kj0Cj8OD7wLZjFd50hCFTBFkxRt7628bgEKwMBhJ2A3Gc63LZ6rEo7UoWUKI jh8NH/RxCjREs9v2SfKS4S2+XoONHxHquyhbwOzptTQ4DqVlZYS6QWTcGVehgrMZMzj+ OsJwDTL3NE8QEcMObu+7OWQmU8LvTUOjFkbO2N4FNmTXDcALXA1fe0NXL25KZPn7ycfh QJmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=m88+MfC6E1gPplRKBa8uNifN5WOD/cY6ElqZkQQjHEc=; b=UJ25uf6sJDp+27pBznlu+Qy73PHQdY5yeMPKGp/yCYV4A1C1lNIyD7uPc32KH7GG/f HgRbDbxGXX/Y6dslySfBS4EdpjHhPb7B6V5SoaOW7DhgP3m9B6sF4qupQYCDFJ8eHnaN fQx/bPhLqOYia6KwvW98ATXYfVyCPu/vmxLDR0YAuAmhyH/vwRWLnHvkbZ+tE2U10G3W SasfMOUrd7gpd3urRYKAIh9Etf1bZoGiE3GUN5qNhfeqhjJIZHrwTzhKNBqfoZLCbbqz jaqzCrvVkS0dFnZHbzuYckPwwC383CbILiDgMMx3mK2m5gBlbPdN4RffXEc2rCuVns9U jYxw== X-Gm-Message-State: AOUpUlF9N0yMK31Yms4pbBs+m6hdwRZuo07z1gZUXd26IgyyOtPprE2K +GF/G1WUGqcjQ2eJxGX5P6mlT2g7/BBZmVM3beQ= X-Google-Smtp-Source: AA+uWPxMbcboqhxrtwIGNkrgV7zderGlkR5t64YpKYRNzcQ2hF52JR9GBB5fHzuS8fRhS1Ao8hp58rlitOUPaJCDD1s= X-Received: by 2002:aca:d0cc:: with SMTP id j73-v6mr1295846oiy.255.1534488488827; Thu, 16 Aug 2018 23:48:08 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22f 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:228623 Archived-At: On Fri, Aug 17, 2018 at 12:57 PM Andreas R=C3=B6hler wrote: > > Also, it looks like it=E2=80=99s going to be somewhere between slightly= and > > horribly inaccurate depending on where the hunk starts (e.g. in the > > middle of a string literal or comment)? > > Which probably thwarts the whole project. Not necessarily; I think it might be good enough for a major part of real-life use cases. Also, if the diff comes from an interactive tool, the user can probably just increase context size a few times so as to shift the balance towards =E2=80=9Cslightly inaccurate=E2=80=9D. > Theoretically if being behind > the end or start of a string could be fetched from source files - That condition is undecidable based on the hunk text alone. An implementation that has access to at least one of the source files could just fontify that whole file and extract fontification from that using hunk line offsets (assuming they are accurate). This probably covers Ediff, vc, and Magit, but not reading standalone patches. There is also the theoretical issue of syntax being changed by the patch =E2=80=94 e.g. introducing an unbalanced multiline string or comment opener or closer on a separate line. (defun foo () + " (bar baz) + " (quux xyzzy)) The middle line here has (punctuation identifier identifier punctuation) syntax according to the =E2=80=9Cbefore=E2=80=9D file, but (st= ring) according to =E2=80=9Cafter=E2=80=9D.