Documents and Files

19 views
Skip to first unread message

Bruce Golling

unread,
Sep 9, 2022, 10:33:38 AM9/9/22
to niceeditor
I am somewhat confused about Documents.  My understanding is that in order to have more than one file available in the same session, a new new document should be started and then a file opened into that space.
My question is:  can I open another file (in the same session) and have both available, say with F4 in one step?  Sort of like the way vim does it.

todd_...@unc.edu

unread,
Sep 9, 2022, 12:00:08 PM9/9/22
to niceeditor
I'm not exactly sure what you're asking, but the short answer is "yes".

The whole Documents vs Files thing is confusing only because of the words. Most people have the concept, but they label them in their heads different ways.
Documents are in RAM; Files are on disk.
Documents are what goes away when you quit `ne`; Files remain.
Documents are listed by the F4 key; Files are listed by the `ls` command in your shell.
Where it gets confusing is the mapping between the two. Not all documents have an associated file. Any given document is associated with zero or at most one file. Any given file may be associated with any number of documents. (Most files are associated with zero documents, because nobody opens all nine-zillion files on a system in an editor, but you could try!)

Here's where we start to split hairs – but not windows! Some editors (like vim) allow you to split a window and have multiple views of a single in-RAM copy of some text (what `ne` calls a Document). But `ne` doesn't do that. In `ne`, you only every have one view on any given document; there's only one cursor position, and there is at most one "selection" in any document.

You can have multiple documents all of which got their content from a single file, but internally they are completely separate copies and are oblivious to each other's existence.

Say you have three files, named "test1.txt", "test2.txt", and "test3.txt" in your current directory.

Scenario 1: You can open all three at once from your shell like so:
   ne test1.txt test2.txt test3.txt
Then within ne you hit F4 and see all three documents listed.

Scenario 2: You open ne with only the first file. Later, from within ne you want to open additional files. (And by "open" I mean "create a new document, populate it with the contents of a particular file, and associate it with that file for saving.)
   ne test1.txt
Then from within ne, you may either:
  • select "File»Open_New…" from the menu and select "test2.txt" from ne's file requester
  • hit ^K and enter "on test2.txt" on ne's command line
  • hit Alt-N and select "test2.txt" from ne's file requester
all of which create a new Document populated by the contents of the file "test2.txt". Then repeat that process for "test3.txt" or any other files you want opened.

What you can't do: There's currently no way from within ne with a single command to create more than one new Documents and have them populated them from multiple files. I wish there were something like "OpenNew+" where I could give a sequence of patterns with wildcards etc. that would work pretty much the same way as the shell when first starting ne.

What else you can't do: There's no way at present (though I've thought about it lately) of going to the shell and saying "$magic-expression test2.txt test3.txt" where "$magic-expression" would somehow tell an already running `ne` to open additional documents for files "test2.txt" and "test3.txt". We'd have to add some sort of API port to make that work.

One more thing you can't do: Let's say you start ne with 3 copies of the same content in three Documents, like so:
   ne test1.txt test1.txt test1.txt
That part works fine. Now you cycle through all three of these initially identical Documents and change each of them (we don't care how). That part works fine, too!

So, without checking, what do you think will happen if you hit Alt-X (SaveAll and Exit) when you have three changed Documents all associated with the same file? What do you think ought to happen?

What actually happens is:
  • ne saves the first document to the file "test1.txt" but does not close the document.
  • ne attempts to save the 2nd document also to the file "test1.txt", but can't because the modification time of the file is now newer (due to the previous Save) than it was when this document was initially populated from the file, and there's no user interaction for overriding that check in a SaveAll.
  • since the SaveAll failed, the Exit is not attempted, and instead you get the message, "Can't save a document. Exit suspended." No documents were closed.
I hope somewhere in there is an answer to whatever your question actually was!

Cheers — Todd

Bruce Golling

unread,
Sep 9, 2022, 2:40:41 PM9/9/22
to niceeditor
Thanks for clearing that up.  Now all you have to do is code ne to show tabs making it really easy for folks like me.  Just kidding.....but I do think that ne is great piece of software
Regards
Bruce
Reply all
Reply to author
Forward
0 new messages