all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Calling Ediff which ignores whitespaces from VC Dir
@ 2013-08-01 14:28 Sebastien Vauban
  2013-08-01 15:37 ` Stefan Monnier
       [not found] ` <mailman.2315.1375371479.12400.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Sebastien Vauban @ 2013-08-01 14:28 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Hello,

I'm trying to call my version of `vc-diff' from VC Dir. It simply is a wrapper
above `vc-diff' where I enforce the fact that whitespaces must be ignored.

I thought this would make it:

--8<---------------cut here---------------start------------->8---
    ;; hide up-to-date and unregistered files
    (add-hook  'vc-dir-mode-hook
               (lambda ()
                 (define-key vc-dir-mode-map
                   (kbd "E") 'vc-ediff-ignore-whitespace)))

    (defun vc-ediff-ignore-whitespace ()
      "Ignore regions that differ in white space & line breaks only."
      (interactive)
      (let ((ediff-ignore-similar-regions t))
        (vc-ediff)))
--8<---------------cut here---------------end--------------->8---

but I always get the error:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 0)
  vc-ediff()
  (let ((ediff-ignore-similar-regions t)) (vc-ediff))
  vc-ediff-ignore-whitespace(nil t)
  call-interactively(vc-ediff-ignore-whitespace nil nil)
--8<---------------cut here---------------end--------------->8---

which I don't really understand.

With no certainty, I've tried to copy the parameters of `vc-ediff':

--8<---------------cut here---------------start------------->8---
    (defun vc-ediff-ignore-whitespace (historic &optional not-urgent)
      "Ignore regions that differ in white space & line breaks only."
      (interactive (list current-prefix-arg t))
      (let ((ediff-ignore-similar-regions t))
        (vc-ediff historic not-urgent)))
--8<---------------cut here---------------end--------------->8---

then it worked further...

Though, I now have:

    call-interactively: Symbol's value as variable is void:
    ediff-ignore-similar-regions

when pressing `n' to go to the first difference region.

Any help?

Best regards,
  Seb

-- 
Sebastien Vauban


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

* Re: Calling Ediff which ignores whitespaces from VC Dir
  2013-08-01 14:28 Calling Ediff which ignores whitespaces from VC Dir Sebastien Vauban
@ 2013-08-01 15:37 ` Stefan Monnier
       [not found] ` <mailman.2315.1375371479.12400.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-08-01 15:37 UTC (permalink / raw)
  To: help-gnu-emacs

> Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 0)

0 is the number of args you have provided.  (1 . 2) is the min and max
number of args expected by the function.

> With no certainty, I've tried to copy the parameters of `vc-ediff':

> --8<---------------cut here---------------start------------->8---
>     (defun vc-ediff-ignore-whitespace (historic &optional not-urgent)
>       "Ignore regions that differ in white space & line breaks only."
>       (interactive (list current-prefix-arg t))
>       (let ((ediff-ignore-similar-regions t))
>         (vc-ediff historic not-urgent)))

You could also use (call-interactively 'vc-ediff) instead.

>     call-interactively: Symbol's value as variable is void:
>     ediff-ignore-similar-regions

That's because ediff was (auto)loaded while ediff-ignore-similar-regions
was let-bound.  So at the end of the let, ediff-ignore-similar-regions
was reset to its previous value (i.e. unbound).

That's a long standing problem.  To work around such issues, you want to
explicitly load ediff before doing the let.


        Stefan




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

* Re: Calling Ediff which ignores whitespaces from VC Dir
       [not found] ` <mailman.2315.1375371479.12400.help-gnu-emacs@gnu.org>
@ 2013-08-02  9:11   ` Sebastien Vauban
  2013-08-02 14:39     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastien Vauban @ 2013-08-02  9:11 UTC (permalink / raw)
  To: help-gnu-emacs-mXXj517/zsQ

Stefan Monnier wrote:
>> Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 0)
>
> 0 is the number of args you have provided.  (1 . 2) is the min and max
> number of args expected by the function.
>
>> With no certainty, I've tried to copy the parameters of `vc-ediff':
>
>> --8<---------------cut here---------------start------------->8---
>>     (defun vc-ediff-ignore-whitespace (historic &optional not-urgent)
>>       "Ignore regions that differ in white space & line breaks only."
>>       (interactive (list current-prefix-arg t))
>>       (let ((ediff-ignore-similar-regions t))
>>         (vc-ediff historic not-urgent)))
>
> You could also use (call-interactively 'vc-ediff) instead.

OK, less error-prone (in case arguments to `vc-ediff' would change).

>>     call-interactively: Symbol's value as variable is void:
>>     ediff-ignore-similar-regions
>
> That's because ediff was (auto)loaded while ediff-ignore-similar-regions
> was let-bound.  So at the end of the let, ediff-ignore-similar-regions
> was reset to its previous value (i.e. unbound).
>
> That's a long standing problem.  To work around such issues, you want to
> explicitly load ediff before doing the let.

When you say "load ediff", I assume you mean writing a `require' call, right?
That way, it's not loaded multiple times?

OK. Latest version, then:

--8<---------------cut here---------------start------------->8---
    (defun vc-ediff-ignore-whitespace (historic &optional not-urgent)
      "Ignore regions that differ in white space & line breaks only."
      (interactive (list current-prefix-arg t))
      (require 'ediff)
      (let ((ediff-ignore-similar-regions t))
        (call-interactively 'vc-ediff)))
--8<---------------cut here---------------end--------------->8---

Though there is no error anymore, it does not work: "similar regions" are not
skipped as expected.

Something due to the fact that the variable `ediff-ignore-similar-regions' is
a local one? When checking its value in the Ediff control window, I see it's
nil -- which confirms the fact that the `let' is somehow not "applied"
correctly.

Is there a way to work around this?

Best regards,
  Seb

-- 
Sebastien Vauban


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

* Re: Calling Ediff which ignores whitespaces from VC Dir
  2013-08-02  9:11   ` Sebastien Vauban
@ 2013-08-02 14:39     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-08-02 14:39 UTC (permalink / raw)
  To: help-gnu-emacs

> When you say "load ediff", I assume you mean writing a `require' call, right?

Right.

> Though there is no error anymore, it does not work: "similar regions" are not
> skipped as expected.
> Something due to the fact that the variable `ediff-ignore-similar-regions' is
> a local one?

No.

> When checking its value in the Ediff control window, I see it's
> nil -- which confirms the fact that the `let' is somehow not "applied"
> correctly.

No, it's simply that by that time, the let has already ended.
The call to `vc-ediff' sets up the various windows/buffers and puts
the buffers in the proper modes, and then returns.


        Stefan




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

end of thread, other threads:[~2013-08-02 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-01 14:28 Calling Ediff which ignores whitespaces from VC Dir Sebastien Vauban
2013-08-01 15:37 ` Stefan Monnier
     [not found] ` <mailman.2315.1375371479.12400.help-gnu-emacs@gnu.org>
2013-08-02  9:11   ` Sebastien Vauban
2013-08-02 14:39     ` Stefan Monnier

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.