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.
-