Community
    • Login

    Read-Only does not work

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 3 Posters 1.9k 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 2 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 1
              • 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
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors