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

* Re: [Patch] printing articles differently than displaying them
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Josefsson @ 2002-08-09 19:30 UTC (permalink / raw)


Reiner Steib <4uce.02.r.steib@gmx.net> writes:

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

You could also press W W c before printing the article, does that
work?

> So, here's the patch:

I think it solves a general problem only in a very specific situation.
It would be nice to solve this more generically, but I'm not sure how
to.  The problem is that users might not want to print the article the
same way they display it.  One way to solve it would be to make
printing use completely different article treatment than displaying --
by default it would be normal Gnus display look, plus maybe a fancy
Gnus icon or something to make it spiffy.  Is this overkill?  I don't
know how hard it would be, but just an idea.




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

* Re: [Patch] printing articles differently than displaying them
  2002-08-09 19:30 ` Simon Josefsson
@ 2002-08-09 21:53   ` Reiner Steib
  2002-08-12 20:48     ` Toby Speight
  0 siblings, 1 reply; 4+ messages in thread
From: Reiner Steib @ 2002-08-09 21:53 UTC (permalink / raw)


On Fri, Aug 09 2002, Simon Josefsson wrote:

> Reiner Steib <4uce.02.r.steib@gmx.net> writes:

>> 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.
>
> You could also press W W c before printing the article, does that
> work?

Sure, but `W W c' only affects the _current_ article. When printing
several process marked articles, it's not useful.

> I think it solves a general problem only in a very specific
> situation.

ACK. I just had in mind (un)hiding citation, but many other
gnus-treat-* variables might be relevant too. (E.g. `g-t-date-lapsed'
doesn't make much sense on paper.)

FWIW, we already have some specific treatment: Setting
`g-t-highlight-signature' and/or `g-t-highlight-citation' have no
effect for printing. In `gnus-print-buffer' citation and signature are
always highlighted:

,----
|   (when (gnus-visual-p 'article-highlight 'highlight)
|     ;; Copy-to-buffer doesn't copy overlay.  So redo
|     ;; highlight.
|     (let ((gnus-article-buffer buffer))
|       (gnus-article-highlight-citation t)
|       (gnus-article-highlight-signature)))
`----

> The problem is that users might not want to print the article the
> same way they display it.

Yes, that was exactly my motivation.

> One way to solve it would be to make printing use completely
> different article treatment than displaying -- by default it would
> be normal Gnus display look, plus maybe a fancy Gnus icon or
> something to make it spiffy. Is this overkill?

I guess Gnus users are used to feature overkill. ;-) It would (more or
less) require a set of ~48 gnus-treat-print-* variables and new (or
modified) display functions.

> I don't know how hard it would be, but just an idea.

If it's too hard: could we have one hook before and one after
printing? Or is if possible to use defadvice instead?

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

* Re: [Patch] printing articles differently than displaying them
  2002-08-09 21:53   ` Reiner Steib
@ 2002-08-12 20:48     ` Toby Speight
  0 siblings, 0 replies; 4+ messages in thread
From: Toby Speight @ 2002-08-12 20:48 UTC (permalink / raw)


0> In article <v9adnvog1l.fsf@marauder.physik.uni-ulm.de>,
0> Reiner Steib <URL:mailto:4uce.02.r.steib@gmx.net> ("Reiner") wrote:

Reiner> It would (more or less) require a set of ~48 gnus-treat-print-*
Reiner> variables and new (or modified) display functions.

Not necessarily:

(setq gnus-print-treatment
      ;; Syntax similar to `let'...
      '((gnus-treat-display-smileys nil)
        (gnus-treat-strip-pgp t)
        gnus-treat-hide-citation
        (gnus-treat-display-xface nil)
        ;;; etc
        ))

All you need now is the code to use it.  I'll leave that as an exercise
for the reader.



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