GNU bug report logs - #64821
30.0.50; write-region errs when overwriting an already open file

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Mon, 24 Jul 2023 07:13:02 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #28 received at 64821 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>
Cc: 64821 <at> debbugs.gnu.org, yantar92 <at> gmail.com
Subject: Re: bug#64821: 30.0.50; write-region errs when overwriting an already
 open file
Date: Thu, 27 Jul 2023 22:02:45 +0300
> From: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>
> Date: Thu, 27 Jul 2023 19:47:46 +0200
> Cc: yantar92 <at> gmail.com,
>  64821 <at> debbugs.gnu.org
> 
> 27 juli 2023 kl. 18.31 skrev Eli Zaretskii <eliz <at> gnu.org>:
> 
> > Is that this line:
> > 
> >          (with-current-buffer (get-file-buffer (file-truename filename))
> >            (set-visited-file-modtime))
> 
> Right, and it's probably because ERT creates temporary files in /var/something but on macOS, /var is a symlink to /private/var. In the lines above, filename (and file-truename) is the "/private/var/..." version.
> Thus get-file-buffer won't return anything because buffer-file-name contains the non-true name, "/var/...".
> 
> I have no idea if this is the right solution (probably not) but it makes filelock-tests all pass:

Thanks, but I think we should make userlock.el robust in the face of
such applications.  How about the patch below instead?

diff --git a/lisp/userlock.el b/lisp/userlock.el
index 96de17d..92fea11 100644
--- a/lisp/userlock.el
+++ b/lisp/userlock.el
@@ -141,8 +141,10 @@ userlock--check-content-unchanged
           ;; modtime in that buffer, to cater to use case where the
           ;; file is about to be written to from some buffer that
           ;; doesn't visit any file, like a temporary buffer.
-          (with-current-buffer (get-file-buffer (file-truename filename))
-            (set-visited-file-modtime))
+          (let ((buf (get-file-buffer (file-truename filename))))
+            (when buf
+              (with-current-buffer buf
+                (set-visited-file-modtime))))
           'unchanged)))))
 
 ;;;###autoload




This bug report was last modified 1 year and 299 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.