unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13197: 24.3.50; org-odt.el code that kills modified buffers
@ 2012-12-15 22:35 Drew Adams
  2012-12-16  4:37 ` Jambunathan K
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2012-12-15 22:35 UTC (permalink / raw)
  To: 13197

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 eggert@cs.ucla.edu-20121213021749-eyqqen0ewhn2hogq
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'
 






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13197: 24.3.50; org-odt.el code that kills modified buffers
  2012-12-15 22:35 bug#13197: 24.3.50; org-odt.el code that kills modified buffers Drew Adams
@ 2012-12-16  4:37 ` Jambunathan K
  2012-12-16 23:15   ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Jambunathan K @ 2012-12-16  4:37 UTC (permalink / raw)
  To: Drew Adams; +Cc: 13197

"Drew Adams" <drew.adams@oracle.com> writes:

> 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?

It looks like a slip on my part.  In all other places in org-odt.el, I
do

    (with-current-buffer (find-file-noselect )

      )

When an error is thrown during the export process, the buffer will be in
modified but unsaved state.  I forcibly mark the buffer as modified
before killing it.

Let me put in a fix in Org repo.  Next merge will take care of this
issue.
-- 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13197: 24.3.50; org-odt.el code that kills modified buffers
  2012-12-16  4:37 ` Jambunathan K
@ 2012-12-16 23:15   ` Bastien
  2012-12-20 15:07     ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien @ 2012-12-16 23:15 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 13197

Hi Jambunathan,

Jambunathan K <kjambunathan@gmail.com> writes:

> Let me put in a fix in Org repo.

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

Let me know if you're with sending a patch to the mailing list or 
if you plan to contribute back and want push access.

Best,

-- 
 Bastien





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13197: 24.3.50; org-odt.el code that kills modified buffers
  2012-12-16 23:15   ` Bastien
@ 2012-12-20 15:07     ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2012-12-20 15:07 UTC (permalink / raw)
  To: Jambunathan K; +Cc: 13197-done

Hi Drew and Jambunathan,

Bastien <bzg@altern.org> 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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-20 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-15 22:35 bug#13197: 24.3.50; org-odt.el code that kills modified buffers Drew Adams
2012-12-16  4:37 ` Jambunathan K
2012-12-16 23:15   ` Bastien
2012-12-20 15:07     ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).