How do I combine the two variants of a conflict in emacs' emerge?

前端 未结 2 1777
旧时难觅i
旧时难觅i 2021-02-09 23:39

Using emerge in Emacs, I have a session like this:

<<<<<<< variant A
            522ADC9C14B2FD9D00F56BAD /* close_test_button.png          


        
相关标签:
2条回答
  • 2021-02-09 23:56

    Use the shortcut:

    x-c   (combine the two versions of the difference)
    

    This will insert the two conflicting regions sequentially, yielding an output something like:

    vvvvvvvvvvvvvvvvvvvv
    #ifdef NEW
    522ADC9C14B2FD9D00F56BAD /* close_test_button.png in Resources */,
    522ADC9D14B2FD9D00F56BAD /* close_test_button@2x.png in Resources */,
    522ADCA014B2FDB100F56BAD /* test_failed.png in Resources */,
    522ADCA114B2FDB100F56BAD /* test_failed@2x.png in Resources */,
    #else /* not NEW */
    EC1633C014B2F3E3004B52E7 /* arrow.png in Resources */,
    EC1633C114B2F3E3004B52E7 /* arrow@2x.png in Resources */,
    EC1633C214B2F3E3004B52E7 /* groups.png in Resources */,
    EC1633C314B2F3E3004B52E7 /* groups@2x.png in Resources */,
    #endif /* not NEW */
    ^^^^^^^^^^^^^^^^^^^^
    

    From there, you can go into edit mode (shortcut: 'e') remove the #ifdef macros as necessary to create the final merge that you desire.

    0 讨论(0)
  • 2021-02-10 00:05

    Just use C-hm within the emerge buffer to see the help for the current modes. As is typical for most modes, the Emerge minor mode displays its key bindings in this help text.

    That help shows that you can insert the content of variant A or B with: ia and ib, so you can use that feature to insert whichever variant isn't currently selected.

    You can also switch from the default 'fast' mode to emerge 'edit' mode to directly edit the merged text. Use C-cC-cf in edit mode to get back to fast mode (because in edit mode, all emerge commands need to be prefixed by C-cC-c).

    The Emerge manual has more details:
    M-: (info "(emacs) Emerge") RET

    In particular, it explains the behaviour of the xc binding, which combines the two variants in a single step using a pre-defined template string:
    M-: (info "(emacs) Combining in Emerge") RET

    The default template uses C preprocessor conditional syntax, however, so you would almost certainly want to override that. You can set the template via the Emerge Options menu or with emerge-set-combine-template. For the template syntax see:
    C-hv emerge-combine-versions-template RET

    0 讨论(0)
提交回复
热议问题