#628 Empty $file_path

closed-fixed
nobody
None
5
2008-06-10
2008-03-04
No

When you start NEdit without a particular file, you get a document labelled "Unknown". It is created without a file path, which can be a big problem if you execute macros from it using $file_name.

This is easy to fix in function EditNewFile() in file.c, where window->path is assigned:

strcpy(window->path, defaultPath ? defaultPath : "");

Instead of "", call GetCurrentDir() (in util/utils.c).
On Unix/Linux/Posix/Cygwin you'll need to add a "/" to that, since that's how file paths are normally terminated in NEdit. (On VMS, I expect this is not necessary, but I don't have such a system to play with. I don't know about other file path conventions on other systems.)

Having made the change results in a correctly assigned $file_path value for these documents. This path is visible in the statistics line (if you use that), another useful feature.

Discussion

  • Bert Wesarg

    Bert Wesarg - 2008-03-04

    Logged In: YES
    user_id=122956
    Originator: NO

    Great, I noticed this too, while we both discuss your relativeFileNormalization patch, but haven't time to look at this. Thanks.

     
  • Nobody/Anonymous

    Logged In: NO

    By calling GetCurrentDir() you can have the path visible in the statistics line but not in the window title (even if you choose to show it).

     
  • Bert Wesarg

    Bert Wesarg - 2008-03-11

    Logged In: YES
    user_id=122956
    Originator: NO

    The path in the window is not shown, because an Untitled document has no real filename and NEdit prevents than to show the path.

     
  • Nobody/Anonymous

    Logged In: NO

    I think logically if there is a path, and if it can be shown in the statistics line, why can't it be shown on the title?

     
  • Bert Wesarg

    Bert Wesarg - 2008-03-11

    Logged In: YES
    user_id=122956
    Originator: NO

    Than feel free to open a new bug report. this bug affects only the first Untitled document, if you start NEdit without a given file name. New Untitled documents if other files are open, has already a path attached.

     
  • Nobody/Anonymous

    Logged In: NO

    I think maybe it is better to have a more complicated fix other than breaking the logicality and consistency with a simple fix.

     
  • Bert Wesarg

    Bert Wesarg - 2008-03-11

    Logged In: YES
    user_id=122956
    Originator: NO

    It is currently possible to have an Untitled document/tab which have a path attached. so this bug closes only a gap, that not all Untitled documents have a path attached.

    If you don't know this: start NEdit with an file argument, be sure you see the stats line, than open a new tab, you will see that this new untitled tab has a path attached.

     
  • Nobody/Anonymous

    Logged In: NO

    My key is:

    1) should a "untitled" file have a path?

    2)If you think it should, then apply the mentioned fix and make the same path can ALSO be seen on the window title.

    3)If you think it shouldn't, then we can think about another fix and keep the concept that an "unititled" file doesn't have a path as it is not a real file.

    You can choose either 2 or 3, but you can't mix them!

    As far as that you mentioned an "untitled" file has a (strange) path attached (with the current nedit), this is a bug and we should fix it.

     
  • Bert Wesarg

    Bert Wesarg - 2008-03-11

    Logged In: YES
    user_id=122956
    Originator: NO

    > 1) should a "untitled" file have a path?
    Obviously the reporter of this bug thinks so, and I too.

    > 2)If you think it should, then apply the mentioned fix and make the same
    > path can ALSO be seen on the window title.
    No, I think the question 'show path of untitled in window title?' stands alone from this bug report.

    > As far as that you mentioned an "untitled" file has a (strange) path
    > attached (with the current nedit), this is a bug and we should fix it.
    The path is not strange, its that of the window from wich you call the new() function

     
  • Nobody/Anonymous

    Logged In: NO

    >> 1) should a "untitled" file have a path?
    >Obviously the reporter of this bug thinks so, and I too.

    No problem with me.

    >> 2)If you think it should, then apply the mentioned fix and make the
    >>same
    >> path can ALSO be seen on the window title.
    >No, I think the question 'show path of untitled in window title?' stands
    >alone from this bug report.

    No problem with me as long as you also think the path should be shown on the window title if users want. Once this fix is released, I'll make a bug report immediately :)

    Thanks for the discussion.

     
  • Tony Balinski

    Tony Balinski - 2008-03-11

    Logged In: YES
    user_id=618141
    Originator: YES

    Bert is right IMO.

    The problem I found is primarily one of macro coding. Having no path for Untitled is a big mistake for the interaction between shell commands executed in the document's context (which use the nedit process' cwd) and macro commands (which, currently, have an empty path). Sometimes your macro code (mine at least) will require a path, especially if this is for storing per-document information in a multidocument session. Having no $file_path value forces the use of a replacement path-"finder" which goes back to the shell to execute "pwd"! Ridiculous when nedit should be providing it.

    As it is I have a patch that addresses the mismatch you can get between the read/write/append_file macro functions and the default shell directory in a document's context, as mentioned by Bert.

    The window title is just window-dressing in comparison (though personally I agree with Nobody on that issue). It's largely cosmetic and really has little to do with this.

     
  • Nobody/Anonymous

    Logged In: NO

    Agree with ajbj that window title is just a cosmetic thing. However, I did find it is the flag "filenameSet" that prevents the path of a "Untitled" from being shown in the window title (after apply ajbj's bug fix). It seems to work if I remove the following check condition:

    .....
    case 'd':
    .....
    if (filenameSet) {
    .....
    case '9':
    .....
    if (filenameSet) {

    ,but I am not quite sure.

     
  • Nobody/Anonymous

    Logged In: NO

    Sorry. I forgot to mention I was talking about the function FormatWindowTitle in windowTitle.c

     
  • Bert Wesarg

    Bert Wesarg - 2008-03-12

    Logged In: YES
    user_id=122956
    Originator: NO

    thats the right place.

    btw: I think we degrade your 'bug' to a feature request ;-) and I can't see a reason why you can't submit it right now, because the implication is from your feature request to this bug, but not the other way around

    also, I would vote for this feature request too, but only if its not changes current behavior, ie. add a new format specifier or option. I have for this two ideas: either use a 'D' instead of the 'd' or add a '*' to indicate "I want Untitled path's too".

     
  • Bert Wesarg

    Bert Wesarg - 2008-03-12

    Logged In: YES
    user_id=122956
    Originator: NO

    ohh, I think we should make this also somehow visible in the stats line, that this file actually has no filename set, my current idea is to set the path in [] if the filename is not set (ie, Untitled), and a 2nd thought is that its maybe useful to change this path by a macro routine, but this should only work or such 'files'.

     
  • Nobody/Anonymous

    Logged In: NO

    do you have a patch?

     
  • Tony Balinski

    Tony Balinski - 2008-03-15

    Logged In: YES
    user_id=618141
    Originator: YES

    I just committed a change for this which works as described. I included a little code for VMS, although I don't know how it'll behave. Anybody with VMS is welcome to try!

     
  • Tony Balinski

    Tony Balinski - 2008-06-10
    • status: open --> closed-fixed
     
  • Tony Balinski

    Tony Balinski - 2008-06-10

    Logged In: YES
    user_id=618141
    Originator: YES

    No news from VMS... closing (until such time as we get some decent file path management).

     
  • Bert Wesarg

    Bert Wesarg - 2008-10-01

    Tony,

    now that Untitled files have a path, I think we should at least change the backup file generation. Because currently all ~Untitled backups go into the HOME.

     
  • Bert Wesarg

    Bert Wesarg - 2008-10-01

    Ohh,

    I think we are not done with this bug:

    start nedit
    modifie the Untitled buffer
    close window without saving
    -> Untitled without path

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks