Subject: bug#13197: closed (Re: bug#13197: 24.3.50; org-odt.el code that kills modified buffers)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 20 Dec 2012 15:08:03 +0000

Your bug report

#13197: 24.3.50; org-odt.el code that kills modified buffers

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
13197: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13197
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#13197: 24.3.50; org-odt.el code that kills modified buffers
From: Bastien <[email-masked]>
To: Jambunathan K <[email-masked]>
Cc: [email-masked]
Date: Thu, 20 Dec 2012 16:07:16 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Drew and Jambunathan,

Bastien <[email-masked]> writes:

> thanks for taking care of this in Org's repo.

I've taken care of it in Org's maint branch, it will be
part of the next merge with the emacs-24 branch.

Thanks,

-- 
 Bastien

Subject: 24.3.50; org-odt.el code that kills modified buffers
From: "Drew Adams" <[email-masked]>
To: <[email-masked]>
Date: Sat, 15 Dec 2012 14:35:45 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

This is a question, but it might also be a bug report regarding the code
cited.
 
IIUC, `set-buffer-modified-p' (and also `restore-buffer-modified-p',
which is a lousy name BTW) always acts on the current buffer.  There is
no way to tell it which buffer to act on, other than, say, using
`with-current-buffer'.
 
I use `find-file-noselect' over a large set of files, and at a later
point I kill many such visited-file buffers.  But even just
`find-file-no-select' can cause visiting to modify some buffers.  So
when I go to kill them I need to prevent the user being queried about
killing a modified buffer.
 
I was grepping some source files to see how other code handles this kind
of thing, and I came across this in org-odt.el (in
`org-odt-cleanup-xml-buffers'):
 
(mapc (lambda (file)
        (let ((buf (find-file-noselect
                     (expand-file-name file org-odt-zip-dir) t)))
          (when (buffer-name buf)
            (set-buffer-modified-p nil)
            (kill-buffer buf))))
      xml-files)
 
I don't see how that can work properly, since `find-file-noselect' does
not make the visited-file buffer current, and `set-buffer-modified-p'
acts only on the current buffer.
 
Am I missing something here, or is that a bug?
 
In any case, I would like to learn more about this.  Currently I am
doing this (since this code is for Emacs 23+, which has
`restore-buffer-modified-p'):
 
(with-current-buffer buf
  (restore-buffer-modified-p nil)
  (kill-buffer buf))
 
Is there a way to accomplish that without making BUF current?

In GNU Emacs 24.3.50.1 (i386-mingw-nt5.1.2600)
 of 2012-12-13 on ODIEONE
Bzr revision: 111211 [email-masked]
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (4.7) --no-opt --enable-checking --cflags
 -IC:/Devel/emacs/build/include -Wall -Wextra -Wno-sign-compare
 -Wno-type-limits -Wno-missing-field-initializers -Wno-pointer-sign
 -Wdeclaration-after-statement --ldflags -LC:/Devel/emacs/build/lib'