unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5273: 23.1; format-alist encode vs write-region-post-annotation-function
@ 2009-12-27  0:17 Kevin Ryde
       [not found] ` <jwveim53dzx.fsf-monnier+emacs@gnu.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2009-12-27  0:17 UTC (permalink / raw)
  To: bug-gnu-emacs

In a format-alist "TO-FN" encode function, the buffer provided to that
function to operate on has write-region-post-annotation-function set to
`kill-buffer'.

This is extremely dangerous, and almost certainly incompatible with past
emacs, as it means any write-region done by the encode function will
kill the buffer it's operating on, causing it to then mangle some other
buffer, quite possibly with no indication that this happened.

A write-region in an encode function is likely if the function works by
putting data through an external program.


I struck this in three of my file formats where I use make-temp-file.
(Two for an error files for call-process-region, one because the program
needed an actual file to write to, not a pipe etc.)  Because
make-temp-file does its job by a writing an empty string to the new
file, it ran the kill-buffer from write-region-post-annotation-function.

I'm was unsure if make-temp-file ought to guard itself against this.  My
inclination is not.  There's an awful lot of read/write hooks and stuff,
and to set them so "write a string to a file" means "kill the current
buffer" is so unreasonable that there's no point anticipating it in one
particular place when so many things will be similarly affected.


I couldn't tell what that write-region-post-annotation-function is
trying to achieve.  If it's to kill the temporary buffer after writing
then an unwind-protect would sound far better, or at least apply the
kill setting only after running the format-alist encode func.


In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5)
 of 2009-09-14 on raven, modified by Debian
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_AU
  value of $XMODIFIERS: nil
  locale-coding-system: iso-latin-1-unix
  default-enable-multibyte-characters: t







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

end of thread, other threads:[~2010-02-02 21:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-27  0:17 bug#5273: 23.1; format-alist encode vs write-region-post-annotation-function Kevin Ryde
     [not found] ` <jwveim53dzx.fsf-monnier+emacs@gnu.org>
2010-01-08 21:57   ` Kevin Ryde
2010-01-10  5:25     ` Stefan Monnier
2010-01-21 22:26       ` Kevin Ryde
2010-01-22 15:29         ` Stefan Monnier
2010-02-02 21:55           ` Kevin Ryde

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