PreviousNextTracker indexSee it online !

(43/212) 134 - another read-only mode

Currently when we toggle read-only status jEdit changes file attribute on disk. In many cases such change is acceptable. In some cases it's a bad idea. For example, I want to open a file in save mode on Windows platform.I toggle read-only, jEdit changes the file status to read only. Later I can't overwrite this file with different FTP clients or changes this file with another programs. I should go to any file manager and change the file status back. The most of other editors just keep read-only as the status of the buffer and the editor doesn't allow to overwrite the original file.
This issue is especially important when we use FTP plug-in and open a file directly from FTP server. I don't see here any option to prevent occasional overwriting.
I think it's easy to add the second mode of read-only status as the buffer attribute and not on file system level only. I am sure we can write a simple plug-in for it, but I believe read-only buffer status should be in jEdit core.

Thanks\!



Submitted yurad - 2007-04-10 18:15:58 Assigned
Priority 5 Labels core
Status open Group None
Resolution None

Comments

2007-04-13 05:57:31
elvez671

Logged In: YES
user_id=1768417
Originator: NO

Why not just create a macro that does this after opening a file:

view.getBuffer().setReadOnly(true);

2007-04-13 14:04:15
yurad

Logged In: YES
user_id=1342234
Originator: YES

Yes, macro works fine, but again I would add "read-only" to buffer options just for consistency. However, providing a macro is also good solution, if this macro will be included in the standard jEdit installation, like all other standard macros. Otherwise all new users are confused with this issue.
BTW, generally speaking, the spreading functionalities between internal functions, macros and plug-ins makes much more difficult to start with this great editor.

2007-04-13 16:11:02
elvez671

Logged In: YES
user_id=1768417
Originator: NO

What I would like to do, if it's possible, is to:

1) Add a "Read Only" checkbox to the Open File dialog. This checkbox will only set that buffer's read-only flag and it won't make any changes to the file's permissions on disk.

2) Add a menu option to toggle the current buffer's read-only flag.

3) Add a read-only toggle switch to the flags section of the status bar, possibly to the left of the "word wrap mode" flag.

I hope to work on these changes myself, unless someone else has already taken up the task. Wish me luck.

As far as the "spreading functionalities," I actually like it because it lets you work more efficiently. If you need to do something small and you need it right away, script it in a macro. But if you need something more complex, create a plugin.

2007-04-26 03:34:27
yurad

Logged In: YES
user_id=1342234
Originator: YES

I think Read only checkbox in the Open File dialog should change the file permissions and not the buffer status. Otherwise we will have the same problem working with FTP files. Also it will allow to change file permissions to the group of files in much faster way.

items 2 and 3 sound great. However the simplest and sufficient solution could be just to rename the current macro to something else like "Toggle Read-only File" (or shorter) and add to Misc macros another one "Toggle read-only buffer"
I created the simple macro:
if (view.getBuffer().isReadOnly())
{
view.getBuffer().setReadOnly(false);
buffer.reload(view);}
else
{
view.getBuffer().setReadOnly(true);
buffer.reload(view);
}
and I am completely happy with it now. Just I use the same lock indicator.