• Login
Community
  • Login

Read-Only does not work

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 3 Posters 2.0k 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.
  • R
    Robert Ornelas
    last edited by Jun 23, 2021, 7:30 PM

    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.

    A 1 Reply Last reply Jun 23, 2021, 7:36 PM Reply Quote 1
    • A
      Alan Kilborn @Robert Ornelas
      last edited by Alan Kilborn Jun 23, 2021, 7:37 PM Jun 23, 2021, 7:36 PM

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

      P 2 Replies Last reply Jun 23, 2021, 7:57 PM Reply Quote 1
      • P
        PeterJones @Alan Kilborn
        last edited by Jun 23, 2021, 7:57 PM

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

        P A 2 Replies Last reply Jun 23, 2021, 8:08 PM Reply Quote 2
        • P
          PeterJones @PeterJones
          last edited by Jun 23, 2021, 8:08 PM

          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
          • P
            PeterJones @Alan Kilborn
            last edited by Jun 23, 2021, 8:42 PM

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

            A 1 Reply Last reply Jun 23, 2021, 9:04 PM Reply Quote 1
            • A
              Alan Kilborn @PeterJones
              last edited by Jun 23, 2021, 9:03 PM

              @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
              • A
                Alan Kilborn @PeterJones
                last edited by Jun 23, 2021, 9:04 PM

                @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
                • A Alan Kilborn referenced this topic on Dec 16, 2021, 7:57 PM
                1 out of 7
                • First post
                  1/7
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors