Matthieu Moy <[EMAIL PROTECTED]> writes:

> Matthieu Moy <[EMAIL PROTECTED]> writes:
>
>> Matthieu Moy <[EMAIL PROTECTED]> writes:
>>
>>> I'll give that a try tonight.
>>
>> I've got something reasonable.
>
> I've been working a bit more on xgit. The diff-mode now has an
> additional menu "GIT-Diff" when it's an xgit buffer. That's done with
> derived mode and (dvc-function ... "diff-mode") instead of
> (dvc-diff-mode) in the diff function helpers.
>
> I'd prefer some additional items in the DVC-Diff menu, but I didn't
> find a way to do that. If an Emacs guru reads me ...

Did you try adding something to dvc-diff-mode-hook? That would be much
simpler. And that's what mode hooks are for, in the general Emacs
design.

The xgit hook function should check to see if xgit is the current dvc,
and then call easy-menu-add to add entries to dvc-diff-mode-menu.

That hook is defined for each mode by define-derived-mode, and run
after the main body of the derived mode function.

Or dvc-diff-mode could dispatch to a back-end function that is
expected to add to the diff-mode menu and keymap, but not do anything
else:

(funcall (dvc-function dvc "diff-mode-additions"))

That's more in the dvc style, and is functionally equivalent to a
hook. This way, the hook functions don't have to check whether their
dvc is the current one.

> (I don't use the menu in daily life, but I find it to be a very good
> place to get the list of features and keybindings, so it's cool to
> have a nice menu)

Yes. Menus are also an excellent way for new users to learn the
features available.

In general, I agree that putting back-end-specific entries on dvc
menus should be supported. There are some xmtn functions that would be
nice to have on the menu.

> I think that's a reasonable example of a way to make a back-end
> different from the other, while still reusing all of DVC.

I disagree; overriding the entire mode function is too heavy-handed.
There is nothing that prevents the backend from using an entirely new
function, not derived from dvc-diff-mode or diff-mode.

In your case, all you did in the overridden function is add more menu
entries; the mode hook is a better solution for that.

But if we allow the entire mode function to be overridden, it could do
something entirely different, which would be very confusing for new users.

And when someone improves dvc-diff-mode, the back-ends that totally
override it will not benefit.

-- 
-- Stephe

_______________________________________________
Dvc-dev mailing list
[email protected]
https://mail.gna.org/listinfo/dvc-dev

Reply via email to