(gnus-print-buffer): Rewrite to use with-temp-buffer.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Mon, 1 Nov 2010 18:53:12 +0000 (19:53 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Mon, 1 Nov 2010 18:53:12 +0000 (19:53 +0100)
lisp/ChangeLog
lisp/gnus-sum.el

index 4bb5723..3c1b16e 100644 (file)
@@ -1,5 +1,7 @@
 2010-11-01  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * gnus-sum.el (gnus-print-buffer): Rewrite to use with-temp-buffer.
+
        * nnimap.el (nnimap-request-group): Store the new updated info.
        (nnimap-request-group): Select the group when we don't know whether it
        exists or not.
index dd9c60c..2e793dd 100644 (file)
@@ -9330,41 +9330,38 @@ to save in."
   (ps-despool filename))
 
 (defun gnus-print-buffer ()
-  (let ((buffer (generate-new-buffer " *print*")))
-    (unwind-protect
-       (progn
-         (copy-to-buffer buffer (point-min) (point-max))
-         (set-buffer buffer)
-         (gnus-remove-text-with-property 'gnus-decoration)
-         (when (gnus-visual-p 'article-highlight 'highlight)
-           ;; Copy-to-buffer doesn't copy overlays.  So redo the
-           ;; highlighting.
-           (let ((gnus-article-buffer buffer))
-             (gnus-article-highlight-citation t)
-             (gnus-article-highlight-signature)
-             (gnus-article-emphasize)
-             (gnus-article-delete-invisible-text)))
-         (let ((ps-left-header
-                (list
-                 (concat "("
-                         (gnus-summary-print-truncate-and-quote
-                          (mail-header-subject gnus-current-headers)
-                          66) ")")
-                 (concat "("
-                         (gnus-summary-print-truncate-and-quote
-                          (mail-header-from gnus-current-headers)
-                          45) ")")))
-               (ps-right-header
-                (list
-                 "/pagenumberstring load"
-                 (concat "("
-                         (mail-header-date gnus-current-headers) ")"))))
-           (gnus-run-hooks 'gnus-ps-print-hook)
-           (save-excursion
-             (if ps-print-color-p
-                 (ps-spool-buffer-with-faces)
-               (ps-spool-buffer)))))
-      (kill-buffer buffer))))
+  (let ((buffer (current-buffer)))
+    (with-temp-buffer
+      (insert-buffer-substring buffer)
+      (gnus-remove-text-with-property 'gnus-decoration)
+      (when (gnus-visual-p 'article-highlight 'highlight)
+       ;; Copy-to-buffer doesn't copy overlays.  So redo the
+       ;; highlighting.
+       (let ((gnus-article-buffer buffer))
+         (gnus-article-highlight-citation t)
+         (gnus-article-highlight-signature)
+         (gnus-article-emphasize)
+         (gnus-article-delete-invisible-text)))
+      (let ((ps-left-header
+            (list
+             (concat "("
+                     (gnus-summary-print-truncate-and-quote
+                      (mail-header-subject gnus-current-headers)
+                      66) ")")
+             (concat "("
+                     (gnus-summary-print-truncate-and-quote
+                      (mail-header-from gnus-current-headers)
+                      45) ")")))
+           (ps-right-header
+            (list
+             "/pagenumberstring load"
+             (concat "("
+                     (mail-header-date gnus-current-headers) ")"))))
+       (gnus-run-hooks 'gnus-ps-print-hook)
+       (save-excursion
+         (if ps-print-color-p
+             (ps-spool-buffer-with-faces)
+           (ps-spool-buffer)))))))
 
 (defun gnus-summary-show-complete-article ()
   "Show a complete version of the current article.