Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Diff could also show the changes within lines
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 33 of 33 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom  
View profile  
 More options Nov 15 2012, 1:54 pm
Newsgroups: gnu.emacs.help
From: Tom <adatgyu...@gmail.com>
Date: Thu, 15 Nov 2012 18:53:57 +0000 (UTC)
Local: Thurs, Nov 15 2012 1:53 pm
Subject: Re: Diff could also show the changes within lines

Sebastien Vauban <wxhgmqzgwmuf@...> writes:

> And the results of the jury are:
> - it works for the refining of *all* hunks

Cool. I think the last hunk is actually processed twice, once when
you call the refine function explicitly and once when the timer mentioned
in the bug report explanation kicks in. But it's not a big deal, probably
does not add a noticable delay.

> - it does not work wrt the position of the cursor, that is it's at the end of
>   the buffer...

I have no idea what causes this. You can try adding a (goto-char (point-min))
call to the end of the refine all function or if it does not work then you
can try using a null timer for this, so it is called after the command is
finished, and hopefully after that code is finished which moves the cursor:

(run-at-time 0.0 nil (lambda () (goto-char (point-min))))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastien Vauban  
View profile  
 More options Nov 15 2012, 4:34 pm
Newsgroups: gnu.emacs.help
From: "Sebastien Vauban" <wxhgmqzgw...@spammotel.com>
Date: Thu, 15 Nov 2012 22:34:57 +0100
Local: Thurs, Nov 15 2012 4:34 pm
Subject: Re: Diff could also show the changes within lines
Tom,

Did not work.

> or if it does not work then you can try using a null timer for this, so it
> is called after the command is finished, and hopefully after that code is
> finished which moves the cursor:

> (run-at-time 0.0 nil (lambda () (goto-char (point-min))))

Like this?

--8<---------------cut here---------------start------------->8---
  (defun my/diff-refine-all-hunks ()
    (interactive)
    (condition-case nil
        (save-excursion
          (goto-char (point-min))
          (while (not (eobp))
            (diff-hunk-next)
            (diff-refine-hunk)))
      (error nil))
    (run-at-time 0.0 nil (lambda () (goto-char (point-min)))))
--8<---------------cut here---------------end--------------->8---

Yep!  This does work perfectly: all hunks refined, and pointer at beginning of
buffer...

Thanks a lot for your more than precious help!

Best regards,
  Seb

--
Sebastien Vauban


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom  
View profile  
 More options Nov 16 2012, 11:24 am
Newsgroups: gnu.emacs.help
From: Tom <adatgyu...@gmail.com>
Date: Fri, 16 Nov 2012 16:24:38 +0000 (UTC)
Local: Fri, Nov 16 2012 11:24 am
Subject: Re: Diff could also show the changes within lines

Sebastien Vauban <wxhgmqzgwmuf@...> writes:

> Yep!  This does work perfectly: all hunks refined, and pointer at beginning of
> buffer...

> Thanks a lot for your more than precious help!

No problem. I'll also need it when I upgrade emacs, so I helped
my future self as well. :)

BTW, highlighting within the lines is helpful in most of the cases, but
sometimes when the diff is very convoluted it can get in the way. To remedy
this I added a key (f7) which when pressed in the diff buffer toggles
the in-line highlight on and off.

I put it here in case someone else also finds it useful:

(add-hook 'diff-mode-hook 'my-diff-stuff)

(setq my-diff-refine-change-color "yellow1")

(defun my-toggle-diff-refine-change-color()
  (interactive)
  (if (face-background 'diff-refine-change)
      (set-face-background 'diff-refine-change nil)
    (set-face-background 'diff-refine-change my-diff-refine-change-color)))

(defun my-diff-stuff ()
  (set-face-background 'diff-refine-change my-diff-refine-change-color)
  (local-set-key (kbd "<f7>") 'my-toggle-diff-refine-change-color)

  (unless (or (eq this-command 'dvc-diff)
              (eq this-command 'dvc-generic-refresh)
              (> (buffer-size) 20000))
    (my-refine-all-diff-hunks)))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stefan Monnier  
View profile  
 More options Nov 16 2012, 10:30 am
Newsgroups: gnu.emacs.help
From: Stefan Monnier <monn...@iro.umontreal.ca>
Date: Fri, 16 Nov 2012 10:30:22 -0500
Local: Fri, Nov 16 2012 10:30 am
Subject: Re: Diff could also show the changes within lines

> That explains it. I'm on Emacs 24.1 and it does not have this
> scheduling code, so that's why it works for me. I didn't think
> they changed this recently.
> Anyway, you can try calling diff-refine-hunk explicitly after
> diff-hunk-next then:
>   (condition-case nil      
>       (save-excursion
>         (goto-char (point-min))
>         (while (not (eobp))
>           (diff-hunk-next)
>           (diff-refine-hunk)))
>     (error nil)))
> I can't try it, because I use 24.1, but it may work.

If you let-bind diff-auto-refine-mode to nil in the above code, not only
you'll be able to test it on Emacs-24.1 (and earlier), but you'll avoid
refining the hunks redundantly when diff-hunk-next does it.

        Stefan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom  
View profile  
 More options Nov 16 2012, 11:41 am
Newsgroups: gnu.emacs.help
From: Tom <adatgyu...@gmail.com>
Date: Fri, 16 Nov 2012 16:40:56 +0000 (UTC)
Local: Fri, Nov 16 2012 11:40 am
Subject: Re: Diff could also show the changes within lines
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> If you let-bind diff-auto-refine-mode to nil in the above code, not only
> you'll be able to test it on Emacs-24.1 (and earlier), but you'll avoid
> refining the hunks redundantly when diff-hunk-next does it.

Good suggestion. Thank you.

What I did not get in the new diff-mode implementation is why it
uses run-at-time instead of run-with-idle-timer?

run-at-time is for specifying a timer which runs at a specific time
while run-with-idle-timer runs it when emacs becomes idle. Isn't
using run-with-idle-timer is more appropriate (makes the code clearer)
in this case?

And why the code uses 0.0 instead of just 0? Is there a difference?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastien Vauban  
View profile  
 More options Nov 19 2012, 7:51 am
Newsgroups: gnu.emacs.help
From: "Sebastien Vauban" <wxhgmqzgw...@spammotel.com>
Date: Mon, 19 Nov 2012 13:51:00 +0100
Subject: Re: Diff could also show the changes within lines
Hi Tom,

After a couple of days using this, I've observed a very tricky collateral
damage in Gnus...

Let's assume I have received 5 mails:

--8<---------------cut here---------------start------------->8---
*   18 Sun 14:25   0.2k Foo  Mail #1 Hello
    18 Sun 14:25   0.4M Bar  Mail #2 How are you?
    18 Sun 17:58   6.9k Baz  Mail #3 [diff] Fix bug
    18 Sun 18:06   4.1k Baz  Mail #4 [diff] Fix doc
    18 Sun 18:27   3.1k Baz  Mail #5 I've done it
--8<---------------cut here---------------end--------------->8---

* = position of the cursor

... and I want first to read the 3rd one. I position the cursor on that one...

--8<---------------cut here---------------start------------->8---
    18 Sun 14:25   0.2k Foo  Mail #1 Hello
    18 Sun 14:25   0.4M Bar  Mail #2 How are you?
*   18 Sun 17:58   6.9k Baz  Mail #3 [diff] Fix bug
    18 Sun 18:06   4.1k Baz  Mail #4 [diff] Fix doc
    18 Sun 18:27   3.1k Baz  Mail #5 I've done it
--8<---------------cut here---------------end--------------->8---

... press RET, get a new buffer created on the mid-right pane, and read it.

--8<---------------cut here---------------start------------->8---
*   18 Sun 14:25   0.2k Foo  Mail #1 Hello           |
    18 Sun 14:25   0.4M Bar  Mail #2 How are you?    |
    18 Sun 17:58   6.9k Baz  Mail #3 [diff] Fix bug  | (contents of 3rd email)
    18 Sun 18:06   4.1k Baz  Mail #4 [diff] Fix doc  |
    18 Sun 18:27   3.1k Baz  Mail #5 I've done it    |
--8<---------------cut here---------------end--------------->8---

Then, as I always do, I simply press "n" to read the "next one" (4th)... but
Gnus displays me the 1st one!

Why?  Because the cursor has been positioned on the first line of my *summary*
buffer (on the left), after displaying the contents of the "Fix bug" email (on
the right).

Why?  Because diff-mode is called (as that email contains a diff), and some
some effect -- which I don't understand -- is that *the cursor is repositioned
onto the first line of the summary buffer* (while the code is supposed to be
executed in the other window, the one with the *contents* of the mail).

So, here, to reproduce the problem, I have to:

- have emails with diffs in them (otherwise, diff-mode won't be called)

- skip reading the first email (so that, clicking "n" does open the "next"
  unread email... from the current cursor position, which is wrong here...)

I know describing a dynamic behavior is not obvious per email. So, did you
understand the description of the problem, at least?

Do you understand why this is occurring, or have some helpful ideas?

Best regards,
  Seb

--
Sebastien Vauban


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stefan Monnier  
View profile  
 More options Nov 19 2012, 9:48 am
Newsgroups: gnu.emacs.help
From: Stefan Monnier <monn...@iro.umontreal.ca>
Date: Mon, 19 Nov 2012 09:48:46 -0500
Local: Mon, Nov 19 2012 9:48 am
Subject: Re: Diff could also show the changes within lines

>> If you let-bind diff-auto-refine-mode to nil in the above code, not only
>> you'll be able to test it on Emacs-24.1 (and earlier), but you'll avoid
>> refining the hunks redundantly when diff-hunk-next does it.
> Good suggestion. Thank you.
> What I did not get in the new diff-mode implementation is why it
> uses run-at-time instead of run-with-idle-timer?
> run-at-time is for specifying a timer which runs at a specific time
> while run-with-idle-timer runs it when emacs becomes idle.  Isn't
> using run-with-idle-timer is more appropriate (makes the code clearer)
> in this case?

run-at-time timers don't run while Elisp is running either, they only
run when Elisp is being interrupted (e.g. during redisplay, or while
running process filters).  So the difference is pretty slim (more
specifically, there's only a difference in the case where diff-hunk-next
is run from code which later calls something like sit-for or redisplay).

> And why the code uses 0.0 instead of just 0?

I can't remember.

> Is there a difference?

No, no difference.

        Stefan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom  
View profile  
 More options Nov 19 2012, 12:46 pm
Newsgroups: gnu.emacs.help
From: Tom <adatgyu...@gmail.com>
Date: Mon, 19 Nov 2012 17:45:20 +0000 (UTC)
Local: Mon, Nov 19 2012 12:45 pm
Subject: Re: Diff could also show the changes within lines

Sebastien Vauban <wxhgmqzgwmuf@...> writes:

>  Why?  Because diff-mode is called (as that email contains a
> diff), and some some effect -- which I don't understand -- is
> that *the cursor is repositioned onto the first line of the
> summary buffer* (while the code is supposed to be executed in
> the other window, the one with the *contents* of the mail).

I don't use Gnus, but from your decription it seem this line

(run-at-time 0.0 nil (lambda () (goto-char (point-min)))))

causes the problem. It is executed after the current command is
finished and I guess Gnus puts back the cursor to the summary
buffer, so this delayed (goto-char (point-min)) is executed
there.

An obvious fix is to execute the delayed goto-char only if
the cursor is in a diff buffer after the command, that is
don't do it in the Gnus summary buffer:

(run-at-time 0.0 nil (lambda ()
                       (if (eq major-mode 'diff-mode)
                           (goto-char (point-min)))))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »