unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* highlighting one buffer according to another
@ 2022-09-15  3:09 Samuel Wales
  2022-09-15  3:18 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Wales @ 2022-09-15  3:09 UTC (permalink / raw)
  To: help-gnu-emacs

this is probably much too much for me but i thought i'd bring it up anyway.

i have a derivative of diff-mode that has special gutter characters.

it captures the diff, its contents, from any other buffer.  suppose
the buffer it captures from is called orig.  it could be magit or
anything else.  and suppose the name of the buffer with special gutter
characters is mydiff.

what i want to do is mark every - or + line in orig, if the
corresponding line in mydiff contains a special gutter character.  for
marking, i haven't decided fully,  but it can maybe change the face
for the - or + line to inverse video.

so part of the problem is finding the corresponding line in orig for
each line in mydiff, and part of it is changing the face of lines in
orig.  [or in principle using fringe or something, but starting with
inverse video seems reasonable.]

a test for plain equality of lines after eliminating gutter etc. would
be sufficient, but some kind of @@ line number syncing or wiggling
might or might not be in principle possible for more accuracy of which
line mydiff refers to.

ideas welcome.  or any code.  i don't have more specific qs than this
beause this is where i got in this.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: highlighting one buffer according to another
  2022-09-15  3:09 highlighting one buffer according to another Samuel Wales
@ 2022-09-15  3:18 ` Stefan Monnier via Users list for the GNU Emacs text editor
  2022-09-15  4:36   ` Samuel Wales
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-09-15  3:18 UTC (permalink / raw)
  To: help-gnu-emacs

> it captures the diff, its contents, from any other buffer.  suppose
> the buffer it captures from is called orig.  it could be magit or
> anything else.  and suppose the name of the buffer with special gutter
> characters is mydiff.

I'm afraid your description is a bit too vague for me to be able to give
you much advice.

How do the original (say diff-mode) buffer and your mydiff buffer differ
(or how are they related)?
Is `mydiff` generated from `diff`?
What do you mean by "gutter"?

> so part of the problem is finding the corresponding line in orig for
> each line in mydiff,

If `mydiff` is generated from `diff`, presumably you can get this info
by remembering this original mapping (e.g. adding text-properties in
`mydiff` that point to the origin, so that as you modify `mydiff`, the
origin info is preserved).


        Stefan




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: highlighting one buffer according to another
  2022-09-15  3:18 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2022-09-15  4:36   ` Samuel Wales
  0 siblings, 0 replies; 3+ messages in thread
From: Samuel Wales @ 2022-09-15  4:36 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

more below.

On 9/14/22, Stefan Monnier via Users list for the GNU Emacs text
editor <help-gnu-emacs@gnu.org> wrote:
> How do the original (say diff-mode) buffer and your mydiff buffer differ
> (or how are they related)?
> Is `mydiff` generated from `diff`?
> What do you mean by "gutter"?

mydiff's major mode is a derived mode of diff-mode.  gutter is the
place where - and + are in diff -u format.

capturing orig line by line and placing each line as some type of
global marker or soemhing in a text property on each line in mydiff is
something that i have considered, but i'm not sure if i want to do
that or can or if it is the right thing to do in context.

registering aftr the fact could work better for the user, but i am
also not sure if that is the right thing to do.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-15  4:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-15  3:09 highlighting one buffer according to another Samuel Wales
2022-09-15  3:18 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-09-15  4:36   ` Samuel Wales

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).