简体   繁体   中英

emacs-25.2 not writing to user owned read-only files on Fedora

This is emacs-25.2 question on Fedora.

For quite some time I have been using the 'trick' of saving a group of certain files that I often edit as read-only in the filesystem to prevent unintended edits, while I am looking at one file/buffer, with the focus being elsewhere.

The default action when using (find-file) makes the buffer read-only, which was what I wanted. Then, if I indeed needed to edit the buffer, it was toggled with Cx Cq, edits made, the file saved with Cx Cs, then set back to read-only with Cx Cq.

At some point, this behavior, as a regular user, has been sidetracked. It still works for root, apparently, but I can't see where any hooks or unusual variables are different.

Has anyone else solved this?

All right, here is how to demonstrate, as regular user:

$ touch bar
$ ls -l
total 0
-rw-r-----. 1 dithot dithot 0 Sep 13 21:28 bar
$ chmod 0440 bar
$ ls -l
total 0
-r--r-----. 1 dithot dithot 0 Sep 13 21:28 bar
$ emacs -Q bar
> C-xC-q
> edit...
> C-xC-s
> msg: File bar is write-protected; try to save anyway? (yes or no)
> reply yes
> file is saved.
> C-x C-q
$ ls -l
total 4
-r--r-----. 1 dithot dithot 10 Sep 13 21:30 bar
-r--r-----. 1 dithot dithot  0 Sep 13 21:28 bar~

I notice a backup file is made, which I normally have disabled, not sure if that is relevant. Note this all works fine if I am root, but am not root generally.

That said, this looks like some lisp code I have prevents this from working once all my config is loaded.

So, I know where to look now.

Are you actually sure that emacs ever had the behaviour you want? I certainly don't remember that being ever being the case.

Cx Cq toggles whether the buffer is read-only or not, so of course as a regular user, toggling the read-only status of the buffer doesn't mean you can write it back to a file that has read-only permissions. As a root user, of course you can bypass file permissions, so it will work as you wish.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM