Search code examples
jedit

Open the JEdit JDiff-Plugin from the command line


I am using JEdit with the JDiff plugin for file compares. Now I would like to open the JDiff plugin from another tool using command line parameters. Is this possible? So far I was only able to open the 2 files i want to compare in JEdit.


Solution

  • This almost works..... I just can't get the macro to execute after the other files are loaded...

    Put this macro in a file.

    view.splitVertically();
    editPane.prevBuffer();
    jdiff.DualDiff.toggleFor(view);
    

    If you on Linux or Mac, put it in ~/.jedit/macros/split_wins_and_jdiff.bsh. If you're on Windows, put it someplace... ( c:/split_wins_and_jdiff.bsh maybe?)

    Then run:

    java -jar jedit.jar -noserver  -norestore  \
        -run=$HOME/.jedit/macros/split_wins_and_jdiff.bsh\
        file_on_left file_on_right
    

    The problem is, I can't get the macro to run after initialization, so that method results in an error. If you're ok with doing a two step process, then you could do:

    Setup

    • Install the above macro in your macros area ( ~/.jedit/macros for linux, mac)
    • Create a shortcut for the macro:
      • click Utilities -> Global Options
      • in panel on the left, select "Shortcuts"
      • in the filter, type "split_wins_and_jdiff"
      • double-click on the cell to the right of "split_wins_and_jdiff" and below "primary shortcut"
      • do a command sequence ( my macro command sequences always begin with ctrl+m. I think that is a JEdit convention... )
      • save shortcut by clicking the "Ok" buttons

    How to Use

    Whenever you want to quickly jdiff two files: * Open the two files:

    java -jar jedit.jar -noserver  -norestore file_on_left file_on_right 
    
    • Right after jedit loads, run your macro with the shortcut you created.

    Without Macros

    Btw, you can do all this without the macro, if you create a shortcut for JDiff ( for me it is ctrl+shift+d, d)

    • Open the two files:

      java -jar jedit.jar -noserver -norestore file_on_left file_on_right

    • Split the screens vertically

      ctrl+3

    • On the right screen ( which is now selected after the split), cycle to the other buffer with ctrl+page-up.

    • Turn on JDiff with your shortcut ( for me ctrl+shift+d, d)

    Creating macros in jedit is dead simple. You can simply record them and they'll popup in a new buffer where you can view the actual macro code. This is what I did to create the macro. Try exploring the macro menu and macro usage.