Gnus development mailing list
 help / color / mirror / Atom feed
* [Patch] printing articles differently than displaying them
@ 2002-08-09 18:52 Reiner Steib
  2002-08-09 19:30 ` Simon Josefsson
  0 siblings, 1 reply; 4+ messages in thread
From: Reiner Steib @ 2002-08-09 18:52 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1623 bytes --]

I use normally use (setq gnus-treat-hide-citation t). But when I print
some process marked articles I'd like to see the cited text in the
printed version. Well, I could change `gnus-treat-hide-citation'
before (and after) printing manually, but I think there should be a
hook to do this job. `gnus-ps-print-hook' comes too late.

I'm quite new to elisp, so I'd appreciate comments. Maybe my patch is
nonsense. ;-)

I added a hook that is run from `gnus-summary-print-article'
(whereas `gnus-ps-print-hook' is run from `gnus-print-buffer').

But even if I toggle `gnus-treat-hide-citation' I have to re-display
the current article again, because `gnus-summary-select-article' is
called with FORCE (2nd optional arg) set to nil. Therefore I added a
variable to customize this: `gnus-ps-print-refetch-selected-article'.

Inside `gnus-summary-print-article' I made `gnus-treat-hide-citation'
and `gnus-treat-hide-citation-maybe' local variables.

Now I'm able to print w/o hidden citations:

(setq gnus-ps-print-refetch-selected-article t)
(add-hook 'gnus-ps-print-select-article-hook 
	  '(lambda ()
	     (setq gnus-treat-hide-citation nil)))

The patch may also be useful if someone wants to read with citations
and print without citations.

The current behavior of `gnus-summary-print-article' is not changed
(`gnus-ps-print-select-article-hook' and
`gnus-ps-print-refetch-selected-article' are nil by default).

In case the patch will be accepted, I could write some lines for
<info://gnus/Article+Commands> too. There's the documentation for
`gnus-summary-print-article' and `gnus-ps-print-hook'.

So, here's the patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch for gnus-summary-print-article --]
[-- Type: text/x-patch, Size: 1773 bytes --]

--- gnus-sum.el	2002/08/03 23:06:05	6.220
+++ gnus-sum.el	2002/08/08 21:16:50
@@ -833,6 +833,11 @@
   :group 'gnus-summary
   :type 'hook)
 
+(defcustom gnus-ps-print-select-article-hook nil
+  "*A hook run before selecting an article for ps-printing."
+  :group 'gnus-summary
+  :type 'hook)
+
 (defcustom gnus-summary-display-arrow
   (and (fboundp 'display-graphic-p)
        (display-graphic-p))
@@ -1016,6 +1021,12 @@
   :group 'gnus-summary
   :type '(choice boolean regexp))
 
+(defcustom gnus-ps-print-refetch-selected-article nil
+  "Whether Gnus should re-fetch articles before printing."
+  :version "21.3"
+  :type 'boolean
+  :group 'gnus-article)
+
 (defcustom gnus-summary-muttprint-program "muttprint"
   "Command (and optional arguments) used to run Muttprint."
   :version "21.3"
@@ -8182,12 +8193,16 @@
 that name.  If FILENAME is a number, prompt the user for the name of the file
 to save in."
   (interactive (list (ps-print-preprint current-prefix-arg)))
-  (dolist (article (gnus-summary-work-articles n))
-    (gnus-summary-select-article nil nil 'pseudo article)
-    (gnus-eval-in-buffer-window gnus-article-buffer
-      (gnus-print-buffer))
-    (gnus-summary-remove-process-mark article))
-  (ps-despool filename))
+  (let ((gnus-treat-hide-citation)
+	(gnus-treat-hide-citation-maybe))
+    (gnus-run-hooks 'gnus-ps-print-select-article-hook)
+    (dolist (article (gnus-summary-work-articles n))
+      (gnus-summary-select-article nil gnus-ps-print-refetch-selected-article
+       'pseudo article)
+      (gnus-eval-in-buffer-window gnus-article-buffer
+	(gnus-print-buffer))
+      (gnus-summary-remove-process-mark article))
+    (ps-despool filename)))
 
 (defun gnus-print-buffer ()
   (let ((buffer (generate-new-buffer " *print*")))

[-- Attachment #3: Type: text/plain, Size: 116 bytes --]


Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/

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

end of thread, other threads:[~2002-08-12 20:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-09 18:52 [Patch] printing articles differently than displaying them Reiner Steib
2002-08-09 19:30 ` Simon Josefsson
2002-08-09 21:53   ` Reiner Steib
2002-08-12 20:48     ` Toby Speight

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 NNTP newsgroup(s).