all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuri Khan <yurivkhan@gmail.com>
To: "Andreas Röhler" <andreas.roehler@online.de>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Syntactic fontification of diff hunks
Date: Fri, 17 Aug 2018 13:47:57 +0700	[thread overview]
Message-ID: <CAP_d_8UxxuEv_Q8Dn0eFL_Oa4XnOGFw=8f2BRyN4oHrT-UFQng@mail.gmail.com> (raw)
In-Reply-To: <ab40c24d-5ba9-5f1e-5355-acec22c76c8b@online.de>

On Fri, Aug 17, 2018 at 12:57 PM Andreas Röhler
<andreas.roehler@online.de> wrote:

> > Also, it looks like it’s 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 “slightly inaccurate”.

> 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 — 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 “before” file, but (string)
according to “after”.



  reply	other threads:[~2018-08-17  6:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-16 21:08 Syntactic fontification of diff hunks Juri Linkov
2018-08-16 21:44 ` Kaushal Modi
2018-08-16 22:27   ` Juri Linkov
2018-08-16 22:33     ` Kaushal Modi
2018-08-16 22:41       ` Juri Linkov
2018-08-17  5:41 ` Yuri Khan
2018-08-17  6:00   ` Andreas Röhler
2018-08-17  6:47     ` Yuri Khan [this message]
2018-08-17 17:47       ` Juri Linkov
2018-08-17 18:34         ` Yuri Khan
2018-08-19 20:57           ` Juri Linkov
2018-08-18 20:02       ` Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8UxxuEv_Q8Dn0eFL_Oa4XnOGFw=8f2BRyN4oHrT-UFQng@mail.gmail.com' \
    --to=yurivkhan@gmail.com \
    --cc=andreas.roehler@online.de \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.