.LOG without ANSI version

banjomike
2012-10-12
2012-11-13
  • banjomike
    banjomike
    2012-10-12

    Now that there is no longer an ANSI version of NP++ is there any way to get the .LOG function when editing in a text file?

     
  • cchris
    cchris
    2012-10-21

    The easiest way I can think of is contacting the author of the log mlugin and massage that person into releasing an unicode build….

    CChris

     
  • banjomike
    banjomike
    2012-10-21

    I did think about doing that but since the existing ANSI version hadn't been touched since 2008 I doubted that Nicholas Heckman would be keen on producing an essentially new version for the new UNICODE-only release of NP++.

    Disappointing.  I started using NP++ as a replacement for Notepad, in part, because the .LOG function worked so nicely with my existing files.  I suppose I will now have to start looking at alternatives to NP++.  I expect this is the wrong place to ask if anyone has any suggestions for something as good as Notepad++ but with a .LOG option.

     
  • To simply add the date at the end of the file, if the file begins with ".LOG", it can easily be added to my ModelineParser plugin. You need to have PythonScript plugin, download ModelineParser https://sourceforge.net/projects/npppythonplugsq/files/Modeline%20Parser/, and install it.  To detect .LOG and insert the date, simply add the following script:

    from Npp import *
    import ModelineParser_dll
    import datetime
    ModelineParser_dll.modeline_add_preparse(lambda settings, name, path, text:
        text.startswith('.LOG') and (
            editor.setSelectionStart(editor.getLength())
            or editor.newLine()
            or editor.addText(datetime.datetime.now().strftime('%Y-%m-%d %H:%M'))
            or editor.newLine()
            or editor.scrollCaret()
            )
        )
    

    You will probably have to change the date format to match what you like; see http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior.

     
  • banjomike
    banjomike
    2012-10-21

    That looks good.  I'll install the latest UNICODE version of NP++ (obviously I only have ANSI version installed) and give it a try.

    Thanks.

     
  • banjomike
    banjomike
    2012-10-22

    I've now installed Notepad++ 6.2 unicode, Python Script 0.9.2.0 which included Python 2.7.1, and ModelineParser_0.2.

    Python Script starts OK, the Python Script console will display if I select it, ATSTARTUP is selected.  Modeline Parser shows on the Plugins menu.  The ModelineLog.py script is in the "Notepad++\plugins\PythonScript\lib" folder.

    Everything looks fine except that when I open a txt file that starts with .LOG nothing happens.

    What have I missed?

     
  • To automatically load the plugin on Notepad++ startup, you need to add the following lines to the startup.py script (in Notepad++\plugins\PythonScript\scripts):

    import ModelineParser_dll
    import ModelineLog
    ModelineParser_dll.modeline_start()
    

    Is it working?

     
  • banjomike
    banjomike
    2012-10-22

    That was it.  I hadn't added the ModelineLog entry.  Done it now and it works perfectly.

    Thanks.