[PATCH 1 of 2] Abstract the functionality of calling an editor into the 'edit' function to prevent
Mads Kiilerich
mads at kiilerich.com
Sun Apr 4 23:21:59 UTC 2010
Itamar Ravid wrote, On 04/05/2010 01:06 AM:
> On Mon, Apr 5, 2010 at 1:07 AM, Mads Kiilerich <mads at kiilerich.com
> <mailto:mads at kiilerich.com>> wrote:
>
> I think that this is a nice-to-have, but also that it complicates
> the code and makes it harder for the next guy to customize the
> code to fit his need. The more I look at the code the more I think
> the cost in increased complexity is too high.
>
> Anyway, why not do something like this:
>
> --- a/hgeditor
> +++ b/hgeditor
> @@ -12,11 +12,15 @@
>
> emacs)
> EDITOR="$EDITOR -nw"
> ;;
> - gvim|vim)
> - EDITOR="$EDITOR -f -o"
> - ;;
> esac
>
> +vim() {
> + if [ "$2" ]; then
> + "$(which vim)" "+e $2" "+set buftype=help" "+split $1"
> + else
> + "$(which vim)" -f -o "$1"
> + fi
> +}
>
> HGTMP=""
> cleanup_exit() {
>
>
> Nice! This is elegant and fine by me - as long as we get the
> functionality in :) I do tend to think that trapping the areas other
> customizers need to touch within a single function is preferable, but
> this does seem less complex.
>
> Should I submit another patch or will you push this change?
I'm not convinced this change is a good idea at all, so please take what
you can use and improve on it and advocate it ;-)
(Perhaps it would be prettier if the function was called something like
vimwrapperfunction and the gvim|vim case changed EDITOR to that. And we
need gvim handling as well. And the -f -o options should considered. Are
they needed now, why, and why not in the two-file-case?)
/Mads
More information about the Mercurial
mailing list