openSession from dblclick



  • Hi, I am storing sessionfiles as .npp.

    ftype npp.session="c:\Program Files (x86)\Notepad++\notepad++.exe" -openSession "%0"
    assoc .npp=npp.session
    

    should allow to open a session from doubleclicking the NPP-file.

    The commandline is fine in CMD, but on dblclick it will open the NPP-file for edit instead of the files listed inside. Any ideas?

    How could I debug what is passed to NPP?



  • @MysticJay ,

    I would have expected it to be "%1", not "%0". (though some searching found this, which seems to imply they are identical)

    How could I debug what is passed to NPP?

    You could change to ftype npp.session=cmd /K echo "c:\Program Files (x86)\Notepad++\notepad++.exe" -openSession "%0", which will open up a cmd window, echo out the old command, and leave that command window open for you to see the results.



  • I am giving up on that idea, but mainly as there is a built-in option in NPP:

    1. save a session with a filename and extension that you prefer, e.g. .npp, .nsf or .nxml

    2. in NPP/Settings/preferences/MISC enter your preferred extension (npp .nsf or nxml) into “Session file ext.:”

    Do a test and open the session file with NPP for edit. If that opens your files in the saved session and NOT the session file:

    1. rightclick on your sessionfile and choose “Open with”. In this standard Windows dialog associate the filetype to Notepad++.EXE.

    Now you should be able to dblclick on your sessionfile and NPP should open your files IN the session file NOT the session file itself.



  • There is one cutback: if you close NPP, then open it again using a different session file it will first reopen the previous files saved, plus those in your session file.
    While you can switch off “remember current session for next launch” in Preferences /Backup this is not really helpful, as it disables intermediate saving.

    Any ideas on that?



  • @MysticJay said in openSession from dblclick:

    it will first reopen the previous files saved, plus those in your session file

    I did some experiments and I think this might do what you want:

    notepad++.exe -nosession -openSession test_session.xml

    The -nosession seems to be processed first, clearing out any files from “intermediate saving”; then the specified session file (I just used .xml for its extension in my test) is loaded, leaving only the desired files loaded when Notepad++ appears.

    Side note: It was rather annoying during my testing, because I was experimenting with -openSession first, and then when I went to add -nosession to the mix, of course I was specifying it as -noSession and nothing was working. Not sure why the casing of the “s” is different in these 2 command line arguments!!



  • Hi,

    yes the -nosession will actully “forget” the previous session but also forget al pending changes to the files is that session. IMHO not how it should be handled.

    Also, as in my initial post menioned, this does not help, as the commandline parameters do not seem to be passed correctly to NPP when launching from Windows dblclick.

    But as I learned this is no BUG or feature request forum so there will be no one to fix this.

    Thanks for you help.
    M.



  • @MysticJay

    I’m not really following your meanings.

    but also forget al pending changes to the files is that session

    What does that mean?
    If you are invoking Notepad++ (from a no-Notepad++ -running situation), what pending changes would there be to “forget”?


    commandline parameters do not seem to be passed correctly to NPP when launching from Windows dblclick

    Well, my first comment on this would be “Notepad++ cannot control how it is invoked, so I’d think if command line arguments are not passed correctly, you should think about blaming whatever is running Notepad++, not Notepad++ itself”.

    However, there should be an easy test for this, as in your earlier post you said:

    The commandline is fine in CMD

    How could I debug what is passed to NPP?

    Do this:

    Close Notepad++ and then invoke the CMD command line and then go to the ? menu in Notepad++ and choose Debug Info. This will show the Command line: that Notepad++ was run with. Copy this data somewhere else.

    Then close Notepad++ and repeat the Debug Info check after running with your “double-click” setup. Compare the results with the CMD line approach’s results.


    But as I learned this is no BUG or feature request forum so there will be no one to fix this.

    We haven’t even determined what there is to fix yet.


Log in to reply