Community
    • Login

    Read-Only does not work

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 2.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Robert OrnelasR
      Robert Ornelas
      last edited by

      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.

      Alan KilbornA 1 Reply Last reply Reply Quote 1
      • Alan KilbornA
        Alan Kilborn @Robert Ornelas
        last edited by Alan Kilborn

        @Robert-Ornelas

        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.

        PeterJonesP Alan KilbornA 3 Replies Last reply Reply Quote 1
        • PeterJonesP
          PeterJones @Alan Kilborn
          last edited by

          @Robert-Ornelas ,

          Related discussion from a few months back: here

          @Alan-Kilborn ,

          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.

          PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 2
          • PeterJonesP
            PeterJones @PeterJones
            last edited by

            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.

            1 Reply Last reply Reply Quote 1
            • PeterJonesP
              PeterJones @Alan Kilborn
              last edited by

              @Alan-Kilborn ,

              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)

              Alan KilbornA 1 Reply Last reply Reply Quote 2
              • Alan KilbornA
                Alan Kilborn @PeterJones
                last edited by

                @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
                
                1 Reply Last reply Reply Quote 2
                • Alan KilbornA
                  Alan Kilborn @PeterJones
                  last edited by

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

                  1 Reply Last reply Reply Quote 1
                  • Alan KilbornA Alan Kilborn referenced this topic on
                  • Alan KilbornA
                    Alan Kilborn @Alan Kilborn
                    last edited by Alan Kilborn

                    @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:

                    5886cb49-dc35-4684-a952-f1d43fd6906e-image.png

                    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.

                    1 Reply Last reply Reply Quote 2
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors