emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: need help tracking down a subtle bug with unrmail/mail-strip-quoted-


From: Mark Lillibridge
Subject: Re: need help tracking down a subtle bug with unrmail/mail-strip-quoted-names
Date: Mon, 27 Dec 2010 15:56:09 -0800

    Ah!  I found the bug.  I will submit a bug report with a patch, but
for those curious, here's what the problem was:

unrmail starts with a with-temp-buffer, which switches to the buffer
" *temp*" because it does not yet exist:

  (defmacro with-temp-buffer (&rest body)
    "Create a temporary buffer, and evaluate BODY there like `progn'.
  See also `with-temp-file' and `with-output-to-string'."
    (declare (indent 0) (debug t))
    (let ((temp-buffer (make-symbol "temp-buffer")))
      `(let ((,temp-buffer (generate-new-buffer " *temp*")))
         ;; FIXME: kill-buffer can change current-buffer in some odd cases.
         (with-current-buffer ,temp-buffer
           (unwind-protect
             (progn ,@body)
             (and (buffer-name ,temp-buffer)
                  (kill-buffer ,temp-buffer)))))))

When mail-strip-quoted-names does the following:

           (with-current-buffer (get-buffer-create " *temp*")
             (erase-buffer)
             ...

it erases that buffer!  The code above is simply wrong as it erases a
possibly existing buffer.  It should be:

           (with-temp-buffer
              ...

This will not step on any existing buffers and avoids the need for
erasing any buffers.

- Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]