Read-Only does not work
-
When I right-click a tab and “Clear Read-Only Flag”, it works correctly, and I can edit the file. But when I click “Read-Only”, Notepad++ shows the file as “Read Only”, but Windows still shows the file as unlocked. If I close and re-open the file, it is editable (the Read-Only flag is cleared). Is there a setting or permissions that could be off?
I think this is a different issue than the one here: their files are locked for a minute, mine are never set to read-only. I have to go back to windows file explorer to set the file back to Read-Only.
-
Somewhat confusingly, these two features are not designed to be strictly complementary.
Ideally there would be three options:
- clear readonly (as it now functions)
- make readonly in Notepad++ (as it now functions – only disallows you from editing in the buffer – file system attribute unaffected)
- set readonly (currently missing! would set the readonly attribute in the file system as well as disallow editing in N++ buffer)
I currently do the missing function with a Pythonscript.
If there’s interest in this approach, I could publish the script here. -
Related discussion from a few months back: here
If there’s interest in this approach, I could publish the script here.
Please share it, even if OP is not interested. (There may end up being a link back to the workaround from the usermanual in the future.)
Also, I have created usermanual issue #249 to clarify the usermanual Edit menu description on those two menu commands.
-
Addenda: Also found another discussion from last year, which shows a macro to clear those flags and PythonScript to clear those flags (with an if-statement to decide if it needs a second) that I developed to clear those flags. But there aren’t the right messages to set the OS Read-Only flag.
-
How does this phrasing look for clarifying what the two menu entries actually do?
(@Future-Readers: That link may not exist once the PR has been placed and incorporated into the main repo)
-
@PeterJones said in Read-Only does not work:
Please share it
# -*- coding: utf-8 -*- import os import stat if notepad.messageBox("You have chosen to make this file READ-ONLY.\n\nDo you really want to do this?", "Confirm!", MESSAGEBOXFLAGS.YESNO | MESSAGEBOXFLAGS.DEFBUTTON2 | MESSAGEBOXFLAGS.ICONEXCLAMATION) == MESSAGEBOXFLAGS.RESULTYES: # set the read-only attribute on the file: os.chmod(notepad.getCurrentFilename(), stat.S_IREAD) # at this point, the disk icon on the tab is not grey like a readonly file should be notepad.menuCommand(MENUCOMMAND.EDIT_SETREADONLY) # now the disk icon is grey
-
@PeterJones said in Read-Only does not work:
How does this phrasing look for clarifying what the two menu entries actually do?
Phrasing looks good; thanks for your efforts.
-
A Alan Kilborn referenced this topic on
-
@Alan-Kilborn said:
Ideally there would be three options:
- clear readonly (as it now functions)
- make readonly in Notepad++ (as it now functions – only disallows you from editing in the buffer – file system attribute unaffected)
- set readonly (currently missing! would set the readonly attribute in the file system as well as disallow editing in N++ buffer)
In Notepad++ 8.8.2 and later are two “new” checkmarkable choices at the bottom of the Edit menu:
I use quotes because they aren’t entirely new; they replace old items whose functionality has been reworked a bit to cover all needs.
The menu text is fairly self-explanatory for the functionality.
Really, the only new part of it is that the readonly attribute in the file system can now be set as well as cleared.
One more bit of newness: When the file system’s readonly attribute is set on a file, its tab icon will appear with an
F
on it, presumably standing for “File System”. (Truly, it would have been better for the menu text to have been “Read-Only Attribute in File System”…)Also, there can be a double level of protection: If Read-Only in Notepad++ is set first, then the Read-Only Attribute in Windows is applied, Read-Only in Notepad++ will be greyed but still checkmarked. Later if Read-Only Attribute in Windows is removed, Read-Only in Notepad++ will again be enforced.
I’m sure all this and more appears in the user manual, I’m just modernizing an old thread here in case someone reading this is confused by the now outdated info above.