Gnus development mailing list
 help / color / mirror / Atom feed
* Viewing HTML-mails with external browsers - proposed code
@ 2005-12-18 21:49 Hynek Schlawack
  2006-01-13 13:42 ` Hynek Schlawack
  2006-01-19 19:35 ` Reiner Steib
  0 siblings, 2 replies; 20+ messages in thread
From: Hynek Schlawack @ 2005-12-18 21:49 UTC (permalink / raw)


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

Hi,

first of all: Gmane hates me. It really does. Or it hates my code. Well,
HTML-mails are really a plague but...this is just about reading...I hope
the mailinglist software shows more mercy. I guess this mail will arrive
in a few days again but I can't be sure, so please apologize this
double-post in advance. ;)

Anyway: As I started to get more and more Mails (mostly newsletters etc)
that make sense only if readen with an graphical browser like Firefox, I
was wondering whether there's some easy way to display them in Gnus? As
I haven't found anything, I wrote a little elisp to solve this. It's
kindof my first lisp ever, so please be tolerant. ;) Nevertheless it
actually works; even with recursevly hidden HTML-parts.

I'm sending the code attached, maybe everyone has something like that in
his .gnus, then please nevermind. I'd be happy about some feedback or
even inclusion though.

-hs

[-- Attachment #2: hs-show-html-mail.el --]
[-- Type: application/emacs-lisp, Size: 2509 bytes --]

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

* Re: Viewing HTML-mails with external browsers - proposed code
  2005-12-18 21:49 Viewing HTML-mails with external browsers - proposed code Hynek Schlawack
@ 2006-01-13 13:42 ` Hynek Schlawack
  2006-01-13 15:57   ` Reiner Steib
  2006-01-19 19:35 ` Reiner Steib
  1 sibling, 1 reply; 20+ messages in thread
From: Hynek Schlawack @ 2006-01-13 13:42 UTC (permalink / raw)


Hynek Schlawack <hynek@ularx.de> wrote:

[snip]

Just being curious: Is it the code-quality or the purpose of the code
that made you totally ignore me?



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-01-13 13:42 ` Hynek Schlawack
@ 2006-01-13 15:57   ` Reiner Steib
  2006-01-13 17:13     ` Hynek Schlawack
  0 siblings, 1 reply; 20+ messages in thread
From: Reiner Steib @ 2006-01-13 15:57 UTC (permalink / raw)
  Cc: ding

On Fri, Jan 13 2006, Hynek Schlawack wrote:

> Hynek Schlawack <hynek@ularx.de> wrote:
>
> [snip]
>
> Just being curious: Is it the code-quality 

No, I didn't read the code yet. ;-)

> or the purpose of the code 

Personally, I'm quite happy with the text part.  If this fails or is
not present, emacs-w3m is sufficient for me.

> that made you totally ignore me?

On Sun, Dec 18 2005, Hynek Schlawack wrote:

> Anyway: As I started to get more and more Mails (mostly newsletters etc)
> that make sense only if readen with an graphical browser like Firefox, I
> was wondering whether there's some easy way to display them in Gnus? As
> I haven't found anything, I wrote a little elisp to solve this. 

My first though was: We probably already have something similar in
Gnus.  But I couldn't find it.

> It's kindof my first lisp ever, so please be tolerant. ;)

There are some minor issues.

> I'd be happy about some feedback or even inclusion though.

If we don't have such a feature already, I think it would be good to
install your code.

But the code is larger than 10-15 lines (i.e. it's not a "tiny
change") so we'd need legal papers to install it.  Gnus is a part of
Emacs and since Emacs is a core GNU project, the Free Software
Foundation (FSF) requires an assignment of copyright for
contributions, so that it is able to defend Emacs' legal status
without doubts, should the need arise.  You can either sign papers
only for Gnus or for Emacs (which covers Gnus, too).

AFAICS, you haven't filed a copyright assignment for work on Gnus or
Emacs to the Free Software Foundation yet.  If you're willing to
assign your code, I can send you the required request form.  After the
assignment process completes (you get sent forms which you have to
read and sign and send back), we can install your code.

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



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-01-13 15:57   ` Reiner Steib
@ 2006-01-13 17:13     ` Hynek Schlawack
  0 siblings, 0 replies; 20+ messages in thread
From: Hynek Schlawack @ 2006-01-13 17:13 UTC (permalink / raw)


Reiner Steib <reinersteib+gmane@imap.cc> wrote:

>> Just being curious: Is it the code-quality 
> No, I didn't read the code yet. ;-)

I nearly guessed so. ;)

>> or the purpose of the code 
> Personally, I'm quite happy with the text part.  If this fails or is
> not present, emacs-w3m is sufficient for me.

This was my position for a pretty long time too. But there are
exceptions and I though, it might open Gnus even a bit more to a broader
audience.

>> Anyway: As I started to get more and more Mails (mostly newsletters
>> etc) that make sense only if readen with an graphical browser like
>> Firefox, I was wondering whether there's some easy way to display
>> them in Gnus? As I haven't found anything, I wrote a little elisp to
>> solve this.
> My first though was: We probably already have something similar in
> Gnus.  But I couldn't find it.

Well, I searched pretty hard too. Good to know, that if there is code,
it isn't obvious.

>> It's kindof my first lisp ever, so please be tolerant. ;)
> There are some minor issues.

I'd be glad to hear them.

>> I'd be happy about some feedback or even inclusion though.
> If we don't have such a feature already, I think it would be good to
> install your code.

Nice to hear.

[ Legal ]
> AFAICS, you haven't filed a copyright assignment for work on Gnus or
> Emacs to the Free Software Foundation yet.  If you're willing to
> assign your code, I can send you the required request form.  After the
> assignment process completes (you get sent forms which you have to
> read and sign and send back), we can install your code.

I'd be happy to sign it for Emacs do that so go on and send them. Is it
a file I can print out or do you need my postal address?

Meanwhile, could we start making the code "technically" installable
(ie. resolve issues)?

Cheers,
-hs



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2005-12-18 21:49 Viewing HTML-mails with external browsers - proposed code Hynek Schlawack
  2006-01-13 13:42 ` Hynek Schlawack
@ 2006-01-19 19:35 ` Reiner Steib
  2006-01-22 12:40   ` Hynek Schlawack
  1 sibling, 1 reply; 20+ messages in thread
From: Reiner Steib @ 2006-01-19 19:35 UTC (permalink / raw)


On Sun, Dec 18 2005, Hynek Schlawack wrote:

> Anyway: As I started to get more and more Mails (mostly newsletters etc)
> that make sense only if readen with an graphical browser like Firefox, I
> was wondering whether there's some easy way to display them in Gnus? As
> I haven't found anything, I wrote a little elisp to solve this. It's
> kindof my first lisp ever, so please be tolerant. ;) Nevertheless it
> actually works; even with recursevly hidden HTML-parts.

JFTR: It failed with "Mail doesn't contain a HTML-part!" on the
following forwarded message:

|   <* mixed> Fwd: RE: Termine
|   <1 text>
|   <2 rfc822>
|   <2.* alternative> RE: Termine
|   <2.1 text>
|   <2.2 html>

> I'm sending the code attached, maybe everyone has something like that in
> his .gnus, then please nevermind. I'd be happy about some feedback or
> even inclusion though.

I think (when your assignment is completed), we should add both
functions to `gnus-art.el' and add a key binding (suggestions?) and
menu entries in `gnus-sum.el'.

As requested, some comments/suggestions on the code:

> (defun hs-show-html-list (LIST)

Rename to, say `gnus-article-browse-html-parts'.  Other suggestions?

Instead of LIST, you should write list (in lowercase).

>   "View all HTML-parts from 'LIST'.

  "View all \"text/html\" parts from LIST.

(Only here in the doc string it must be uppercase.)

> Recurse into multiparts."
>
>   (let ((showed))

Maybe "done" instead of "showed"?

>     ;; Find and show the html-parts.
>     (dolist (elt LIST)
>       ;; If HTML, show it
>       (cond ((and (listp elt)

Maybe rename "elt" to "handle"?

Basically you have:

(cond ((and a b c)
       (do-something))
      ((and a s d (do-other-things))))

Maybe it would be more clear to write it as follows.  But it could be
just a matter of taste.

(when a
  (cond ((and b c)
	 (do-something))
	((and s d)
	 (do-other-things))

> 		  (bufferp (car elt))

Isn't (car elt) the same as (mm-handle-buffer elt)?  

> 		  (string-match "text/html" (car (mm-handle-type elt))))
> 	     (let ((tmp (format "%s-%s.html"

Maybe "file" instead of "tmp"?

> 				(make-temp-name "/tmp/gnus-html-")
> 				(user-login-name))))

  (mm-make-temp-file (expand-file-name "mm" mm-tmp-directory) nil ".html")

Maybe even (convert-standard-filename (mm-make-temp-file ...))  like
in `browse-url-of-buffer' is required?

> 	       (mm-save-part-to-file elt tmp)
> 	       (browse-url tmp)

It would be nice to remove the tmp file after proceeding to the next
article or leaving the summary buffer (maybe similar to
`mm-remove-part').  But it might depend on the browser and the user if
this is desired.  Or it could be removed here:

  (when (gnus-y-or-n-p "Remove temp file? ") (delete-file tmp))

> 	       (setq showed t)))
> 	    ;; If multipart, recurse
> 	    ((and (listp elt)
> 		  (stringp (car elt))
> 		  (string-match "multipart/" (substring (car elt) 0 10))

  (string-match "^multipart/" (car elt))


> 		  (setq showed (or showed (hs-show-html-list elt)))))))
>     showed))
>
> (defun hs-show-html-mail ()

  (defun gnus-article-browse-html-article

Other suggestions?

>   "View HTML-parts of the current Gnus-Article in a graphical browser."

    "View \"text/html\" parts of the current article with a WWW browser."

See `C-h f browse-url RET'.

>   (interactive)
>   
>   (save-window-excursion
>     ;; Open raw article and select the buffer
>     (gnus-summary-show-article t)
>     (gnus-summary-select-article-buffer)
>     (let ((parts (mm-dissect-buffer t t)))
>
>       ;; If singlepart, enforce a list.
>       (when (and (bufferp (car parts))
> 		 (stringp (car (mm-handle-type parts))))
> 	(setq parts (list parts)))
>
>       ;; Process the list
>       (unless (hs-show-html-list parts)
> 	(message "Mail doesn't contain a HTML-part!"))

Either (gnus-message 3 ...) or even (gnus-error ...) should be used
here, I think.

>       (gnus-summary-show-article))))

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




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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-01-19 19:35 ` Reiner Steib
@ 2006-01-22 12:40   ` Hynek Schlawack
  2006-01-25 14:44     ` Reiner Steib
  0 siblings, 1 reply; 20+ messages in thread
From: Hynek Schlawack @ 2006-01-22 12:40 UTC (permalink / raw)


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

* Reiner Steib <reinersteib+gmane@imap.cc> wrote:

> JFTR: It failed with "Mail doesn't contain a HTML-part!" on the
> following forwarded message:
>
> |   <* mixed> Fwd: RE: Termine
> |   <1 text>
> |   <2 rfc822>
> |   <2.* alternative> RE: Termine
> |   <2.1 text>
> |   <2.2 html>

Hm, would you mind to forward some look-a-like to me?

> I think (when your assignment is completed), 

It's up to our patience right now. ;)

> we should add both functions to `gnus-art.el' and add a key binding
> (suggestions?) 

Well, _I_ use "v", but I guess I won't be able to push that. ;)

> As requested, some comments/suggestions on the code:

Thanks!

>> (defun hs-show-html-list (LIST)
> Rename to, say `gnus-article-browse-html-parts'.  Other suggestions?
> Instead of LIST, you should write list (in lowercase).

*done*

>>   "View all HTML-parts from 'LIST'.
>   "View all \"text/html\" parts from LIST.

*done*

>>   (let ((showed))
> Maybe "done" instead of "showed"?

I'm not sure whether "done" exactly reflects the purpose of "showed".

>>     ;; Find and show the html-parts.
>>     (dolist (elt LIST)
>>       ;; If HTML, show it
>>       (cond ((and (listp elt)
> Maybe rename "elt" to "handle"?

*done* I've been lacking imagination in that point.

[ Factoring out cond ]

Yeah you're right. The routines grew a bit...evolutionary.

>> 		  (bufferp (car elt))
> Isn't (car elt) the same as (mm-handle-buffer elt)?  

Yes...but we don't know exactly whether it's a buffer (look at the
second condition), so I guess car is more appropriate here.

>> 		  (string-match "text/html" (car (mm-handle-type elt))))
>> 	     (let ((tmp (format "%s-%s.html"
> Maybe "file" instead of "tmp"?

I went for "tmp-file" if it's okay for you.

>> 				(make-temp-name "/tmp/gnus-html-")
>> 				(user-login-name))))
>
>   (mm-make-temp-file (expand-file-name "mm" mm-tmp-directory) nil ".html")
> Maybe even (convert-standard-filename (mm-make-temp-file ...))  like
> in `browse-url-of-buffer' is required?

Uhm, so what's your final suggestion here? :)

>> 	       (mm-save-part-to-file elt tmp)
>> 	       (browse-url tmp)
> It would be nice to remove the tmp file after proceeding to the next
> article or leaving the summary buffer (maybe similar to
> `mm-remove-part').  But it might depend on the browser and the user if
> this is desired.  Or it could be removed here:
>   (when (gnus-y-or-n-p "Remove temp file? ") (delete-file tmp))

Yes it would be nice and the only way would be this asking as we can't
delete it, before it has been showed...

>> 	       (setq showed t)))
>> 	    ;; If multipart, recurse
>> 	    ((and (listp elt)
>> 		  (stringp (car elt))
>> 		  (string-match "multipart/" (substring (car elt) 0 10))
>   (string-match "^multipart/" (car elt))

*done*

>> 		  (setq showed (or showed (hs-show-html-list elt)))))))
>>     showed))
>> (defun hs-show-html-mail ()
>   (defun gnus-article-browse-html-article

*done*

> Other suggestions?

I'm fine with it.

>>   "View HTML-parts of the current Gnus-Article in a graphical browser."
>
>     "View \"text/html\" parts of the current article with a WWW browser."
> See `C-h f browse-url RET'.

Ehm, for what exactly?

>> 	(message "Mail doesn't contain a HTML-part!"))
> Either (gnus-message 3 ...) or even (gnus-error ...) should be used
> here, I think.

Ok, I wasn't sure about what to use.

-hs


[-- Attachment #2: hs-show-html-mail.el --]
[-- Type: application/emacs-lisp, Size: 2684 bytes --]

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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-01-22 12:40   ` Hynek Schlawack
@ 2006-01-25 14:44     ` Reiner Steib
  2006-01-25 16:29       ` Hynek Schlawack
  0 siblings, 1 reply; 20+ messages in thread
From: Reiner Steib @ 2006-01-25 14:44 UTC (permalink / raw)


On Sun, Jan 22 2006, Hynek Schlawack wrote:

> * Reiner Steib <reinersteib+gmane@imap.cc> wrote:
>
>> JFTR: It failed with "Mail doesn't contain a HTML-part!" on the
>> following forwarded message:  [...]
> Hm, would you mind to forward some look-a-like to me?

I will sent you a look-alike off-list.

>> I think (when your assignment is completed), 
>
> It's up to our patience right now. ;)
>
>> we should add both functions to `gnus-art.el' and add a key binding
>> (suggestions?) 
>
> Well, _I_ use "v", but I guess I won't be able to push that. ;)

The very few remaining single letter keys should be reserved for very
frequently used commands.

In fact, `v' is a good candidate for a (prefix) key we could reserve
for the user in Gnus, see <news:v9u0bsv0at.fsf@marauder.physik.uni-ulm.de>.

>>>   (let ((showed))
>> Maybe "done" instead of "showed"?
>
> I'm not sure whether "done" exactly reflects the purpose of "showed".

I didn't read the code very carefully, so I probably misunderstood its
purpose.

>>> 				(make-temp-name "/tmp/gnus-html-")
>>> 				(user-login-name))))
>>
>>   (mm-make-temp-file (expand-file-name "mm" mm-tmp-directory) nil ".html")
>> Maybe even (convert-standard-filename (mm-make-temp-file ...))  like
>> in `browse-url-of-buffer' is required?
>
> Uhm, so what's your final suggestion here? :)

I looked at `browse-url-of-buffer' and saw that there we have (Emacs
22 / CVS):

(setq browse-url-temp-file-name
      (convert-standard-filename
       (make-temp-file
	(expand-file-name "burl" browse-url-temp-dir)
	nil ".html")))

The doc string says:

,----[ <f1> f convert-standard-filename RET ]
| convert-standard-filename is a compiled Lisp function in `files.el'.
| (convert-standard-filename filename)
| 
| Convert a standard file's name to something suitable for the OS.
| This means to guarantee valid names and perhaps to canonicalize
| certain patterns.
| 
| filename should be an absolute file name since the conversion rules
| sometimes vary depending on the position in the file name.  E.g. c:/foo
| is a valid DOS file name, but c:/bar/c:/foo is not.
| 
| This function's standard definition is trivial; it just returns
| the argument.  However, on Windows and DOS, replace invalid
| characters.  On DOS, make sure to obey the 8.3 limitations.  On
| Windows, turn Cygwin names into native names, and also turn
| slashes into backslashes if the shell requires it (see
| `w32-shell-dos-semantics').
| 
| See Info node `(elisp)Standard File Names' for more details.
`----

We don't use `convert-standard-filename' at all in Gnus upto now.  I
don't use those systems (Windows, DOS, Cygwin) so I'm not sure if we
also need to add `convert-standard-filename' when we use
`mm-make-temp-file' in Gnus.  Maybe the use in `browse-url-of-buffer'
isn't necessary?

>>>   "View HTML-parts of the current Gnus-Article in a graphical browser."
>>
>>     "View \"text/html\" parts of the current article with a WWW browser."
>> See `C-h f browse-url RET'.
>
> Ehm, for what exactly?

Well, "graphical browser" might not be correct, depending on the
user's environment and preferences.

,----[ <f1> f browse-url RET ]
| browse-url is an interactive autoloaded Lisp function in `browse-url'.
| (browse-url url &rest args)
| 
| Ask a WWW browser to load url.
| Prompts for a url, defaulting to the url at or before point.  Variable
| `browse-url-browser-function' says which browser to use.
`----

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




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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-01-25 14:44     ` Reiner Steib
@ 2006-01-25 16:29       ` Hynek Schlawack
  2006-01-25 17:41         ` Reiner Steib
  0 siblings, 1 reply; 20+ messages in thread
From: Hynek Schlawack @ 2006-01-25 16:29 UTC (permalink / raw)


* Reiner Steib <reinersteib+gmane@imap.cc> wrote:

>>> we should add both functions to `gnus-art.el' and add a key binding
>>> (suggestions?) 
>> Well, _I_ use "v", but I guess I won't be able to push that. ;)
> The very few remaining single letter keys should be reserved for very
> frequently used commands.

Well, something behind an attachment-related prefix then?

> In fact, `v' is a good candidate for a (prefix) key we could reserve
> for the user in Gnus, see <news:v9u0bsv0at.fsf@marauder.physik.uni-ulm.de>.

I read it and I knew what inspired you. ;)

>>>>   (let ((showed))
>>> Maybe "done" instead of "showed"?
>> I'm not sure whether "done" exactly reflects the purpose of "showed".
> I didn't read the code very carefully, so I probably misunderstood its
> purpose.

Well, it indicates, whether a (or more) HTML-attachment has been
shown. "done" sounds like "we've done our job successfully and can
quit".

>>>> 				(make-temp-name "/tmp/gnus-html-")
>>>> 				(user-login-name))))
>>>   (mm-make-temp-file (expand-file-name "mm" mm-tmp-directory) nil ".html")
>>> Maybe even (convert-standard-filename (mm-make-temp-file ...))  like
>>> in `browse-url-of-buffer' is required?
>> Uhm, so what's your final suggestion here? :)

[...]

> We don't use `convert-standard-filename' at all in Gnus upto now.  I
> don't use those systems (Windows, DOS, Cygwin) so I'm not sure if we
> also need to add `convert-standard-filename' when we use
> `mm-make-temp-file' in Gnus.  Maybe the use in `browse-url-of-buffer'
> isn't necessary?

I'd say, mm-make-temp-file should take care of this as it also takes
care where to put the tmp-file to.

>>>>   "View HTML-parts of the current Gnus-Article in a graphical browser."
>>>     "View \"text/html\" parts of the current article with a WWW browser."
>>> See `C-h f browse-url RET'.
>> Ehm, for what exactly?
> Well, "graphical browser" might not be correct, depending on the
> user's environment and preferences.

Ok, but that's fixed now anyway.

So, there's the bug with your mail and the temp-file-stuff left, iirc?

-hs



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-01-25 16:29       ` Hynek Schlawack
@ 2006-01-25 17:41         ` Reiner Steib
  2006-01-31 12:38           ` Hynek Schlawack
  0 siblings, 1 reply; 20+ messages in thread
From: Reiner Steib @ 2006-01-25 17:41 UTC (permalink / raw)


On Wed, Jan 25 2006, Hynek Schlawack wrote:

> * Reiner Steib <reinersteib+gmane@imap.cc> wrote:
[...]
> I read it and I knew what inspired you. ;)

No, you reminded me that I indented to suggests this years ago. ;-)
IIRC when introducing `W Y ...'.

>> We don't use `convert-standard-filename' at all in Gnus upto now.  I
>> don't use those systems (Windows, DOS, Cygwin) so I'm not sure if we
>> also need to add `convert-standard-filename' when we use
>> `mm-make-temp-file' in Gnus.  Maybe the use in `browse-url-of-buffer'
>> isn't necessary?
>
> I'd say, mm-make-temp-file should take care of this as it also takes
> care where to put the tmp-file to.

At least in Emacs, `mm-make-temp-file' is just an alias for
`make-temp-file'.  We could ask on emacs-devel if the use of
`convert-standard-filename' in `browse-url-of-buffer' makes sense or
not.

As for your code, it's fine for now if you use `mm-make-temp-file'
instead of `make-temp-name'.

> So, there's the bug with your mail and the temp-file-stuff left,
> iirc?

You mean removing the temp file(s)?  Yes, and waiting for your
assignment.

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




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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-01-25 17:41         ` Reiner Steib
@ 2006-01-31 12:38           ` Hynek Schlawack
  2006-02-10 18:15             ` Reiner Steib
  0 siblings, 1 reply; 20+ messages in thread
From: Hynek Schlawack @ 2006-01-31 12:38 UTC (permalink / raw)


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

* Reiner Steib <reinersteib+gmane@imap.cc> wrote:

> As for your code, it's fine for now if you use `mm-make-temp-file'
> instead of `make-temp-name'.

Done. I've attached it - would some Win32-user care to test whether it
works as expected _please_? Thanks!

>> So, there's the bug with your mail and the temp-file-stuff left,
>> iirc?
> You mean removing the temp file(s)?  

I'm still pondering how to get that best. I'll definitely add an
argument for that because _I_ don't want to be bothered everytime I look
at a HTML-mail. But any other suggestions? C'mon guys/gals, it's not
only Reiner reading here. ;)

> Yes, and waiting for your assignment.

I've sent it out yesterday by airmail. Btw, are the cool
GNU/Linux-stickers the $1 that is mentioned in the assignment? ;)


[-- Attachment #2: hs-show-html-mail.el --]
[-- Type: application/emacs-lisp, Size: 2668 bytes --]

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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-01-31 12:38           ` Hynek Schlawack
@ 2006-02-10 18:15             ` Reiner Steib
  2006-02-13  0:06               ` Katsumi Yamaoka
  0 siblings, 1 reply; 20+ messages in thread
From: Reiner Steib @ 2006-02-10 18:15 UTC (permalink / raw)


On Tue, Jan 31 2006, Hynek Schlawack wrote:

> * Reiner Steib <reinersteib+gmane@imap.cc> wrote:
>
>> As for your code, it's fine for now if you use `mm-make-temp-file'
>> instead of `make-temp-name'.
>
> Done. I've attached it - would some Win32-user care to test whether it
> works as expected _please_? Thanks!
>
>>> So, there's the bug with your mail and the temp-file-stuff left,
>>> iirc?
>> You mean removing the temp file(s)?  
>
> I'm still pondering how to get that best. I'll definitely add an
> argument for that because _I_ don't want to be bothered everytime I look
> at a HTML-mail. But any other suggestions? 

Here is an idea:

Store each used temp-filename in a list (internal variable).  Add a
function `gnus-article-browse-delete-temp-files' (better name?)  that
walks through this list and deletes the files (remove deleted files
from the list).  This function can be added to a suitable
gnus-*-exit-hook [1] (say on summary exit or on exit from Gnus).

Add a customizable variable (a list) specifying *when* to delete the
files and whether to prompt the user or not.
E.g. `gnus-article-browse-delete-temp' (better name?).

(memq t gnus-article-browse-delete-temp)    -> prompt before deleting
(eq nil gnus-article-browse-delete-temp)    -> delete w/o prompt

(memq 'summary gnus-article-browse-delete-temp)
  -> run `gnus-article-browse-delete-temp-files' on summary exit
(memq 'gnus gnus-article-browse-delete-temp)
  -> run `gnus-article-browse-delete-temp-files' on exit from Gnus
Maybe not useful:
(memq 'emacs gnus-article-browse-delete-temp)
  -> run `gnus-article-browse-delete-temp-files' on exit from Emacs

Depending on the value of `gnus-article-browse-delete-temp',
`gnus-article-browse-html-parts' does e.g.
(add-hook 'gnus-summary-exit-hook 'gnus-article-browse-delete-temp-files).

(Hm, this would lead to "CHANGED outside Customize" message in
customize.  But `spam-initialize' also does this.)

More simple approach: Run `gnus-article-browse-delete-temp-files' from
`gnus-summary-prepare-exit-hook' and `gnus-exit-gnus-hook'.  Allow
only the values `t' (delete w/o prompt), `nil' (don't delete) and
`ask' for the `gnus-article-browse-delete-temp' variable.

Opinions?

> C'mon guys/gals, it's not only Reiner reading here. ;)

Maybe we get more feedback now that I committed it to `gnus-art.el'.

Bye, Reiner.

[1]
,----
| gnus-after-exiting-gnus-hook
|   Variable: Hook called after exiting Gnus.
| gnus-exit-gnus-hook
|   Variable: Hook called when exiting Gnus.
| gnus-exit-group-hook
|   Variable: *A hook called when exiting summary mode.
| gnus-summary-exit-hook
|   Variable: *A hook called on exit from the summary buffer.
| gnus-summary-prepare-exit-hook
|   Variable: *A hook called when preparing to exit from the summary buffer.
`----
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-02-10 18:15             ` Reiner Steib
@ 2006-02-13  0:06               ` Katsumi Yamaoka
  2006-02-13 14:53                 ` Reiner Steib
  0 siblings, 1 reply; 20+ messages in thread
From: Katsumi Yamaoka @ 2006-02-13  0:06 UTC (permalink / raw)


>>>>> In <v9ek2b84hk.fsf@marauder.physik.uni-ulm.de> Reiner Steib wrote:

> On Tue, Jan 31 2006, Hynek Schlawack wrote:

[...]

>> C'mon guys/gals, it's not only Reiner reading here. ;)

> Maybe we get more feedback now that I committed it to `gnus-art.el'.

;-)

I make a proposal to make `mm-make-temp-file' the copy of
`make-temp-file' which is defined in Emacs 22.  Now
`mm-make-temp-file' is an alias to `make-temp-file' which
doesn't allow the optional 3rd argument in Emacs 21.  To do it
solves some problems.  For instance, in mm-decode.el,
`mm-display-external' uses `rename-file' to add a suffix to a
temp file name which `mm-make-temp-file' makes, and
`mm-create-image-xemacs' doesn't achieve the purpose of making a
temp file name which has the `.xbm' suffix.



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-02-13  0:06               ` Katsumi Yamaoka
@ 2006-02-13 14:53                 ` Reiner Steib
  2006-02-13 15:24                   ` Hynek Schlawack
  2006-02-13 15:37                   ` Hynek Schlawack
  0 siblings, 2 replies; 20+ messages in thread
From: Reiner Steib @ 2006-02-13 14:53 UTC (permalink / raw)


On Mon, Feb 13 2006, Katsumi Yamaoka wrote:

>>>>>> In <v9ek2b84hk.fsf@marauder.physik.uni-ulm.de> Reiner Steib wrote:
>> Maybe we get more feedback now that I committed it to `gnus-art.el'.
>
> ;-)
>
> I make a proposal to make `mm-make-temp-file' the copy of
> `make-temp-file' which is defined in Emacs 22.  Now
> `mm-make-temp-file' is an alias to `make-temp-file' which
> doesn't allow the optional 3rd argument in Emacs 21. [...]

Please do if you think it make sense.

In the mean time I've added a quick workaround (concat ... ".html")
for the suffix and fixed the other compiler warning
(`hs-show-html-list' should be `gnus-article-browse-html-parts').
Thanks for pointing this out.

BTW: Suggestions for a key binding are still wanted.

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




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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-02-13 14:53                 ` Reiner Steib
@ 2006-02-13 15:24                   ` Hynek Schlawack
  2006-02-13 15:37                   ` Hynek Schlawack
  1 sibling, 0 replies; 20+ messages in thread
From: Hynek Schlawack @ 2006-02-13 15:24 UTC (permalink / raw)


* Reiner Steib <reinersteib+gmane@imap.cc> wrote:

> In the mean time I've added a quick workaround (concat ... ".html")
> for the suffix and fixed the other compiler warning
> (`hs-show-html-list' should be `gnus-article-browse-html-parts').

Ugh, that's an embarrassing one. :(



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-02-13 14:53                 ` Reiner Steib
  2006-02-13 15:24                   ` Hynek Schlawack
@ 2006-02-13 15:37                   ` Hynek Schlawack
  2006-02-13 22:16                     ` Reiner Steib
  1 sibling, 1 reply; 20+ messages in thread
From: Hynek Schlawack @ 2006-02-13 15:37 UTC (permalink / raw)


* Reiner Steib <reinersteib+gmane@imap.cc> wrote:

>>> Maybe we get more feedback now that I committed it to `gnus-art.el'.
>> ;-)
>> I make a proposal to make `mm-make-temp-file' the copy of
>> `make-temp-file' which is defined in Emacs 22.  Now
>> `mm-make-temp-file' is an alias to `make-temp-file' which
>> doesn't allow the optional 3rd argument in Emacs 21. [...]
> Please do if you think it make sense.
> In the mean time I've added a quick workaround (concat ... ".html")
> for the suffix

Unfortunately, this ain't a viable way to go. Because make-temp-file
apparently creates the file which leads to two temp-files per call (one
empty without .html and the actual file). :(

Suggestions?



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-02-13 15:37                   ` Hynek Schlawack
@ 2006-02-13 22:16                     ` Reiner Steib
  2006-02-14  0:11                       ` Katsumi Yamaoka
  0 siblings, 1 reply; 20+ messages in thread
From: Reiner Steib @ 2006-02-13 22:16 UTC (permalink / raw)


On Mon, Feb 13 2006, Hynek Schlawack wrote:

> * Reiner Steib <reinersteib+gmane@imap.cc> wrote:
>> In the mean time I've added a quick workaround (concat ... ".html")
>> for the suffix
>
> Unfortunately, this ain't a viable way to go. Because make-temp-file
> apparently creates the file which leads to two temp-files per call (one
> empty without .html and the actual file). :(

Oops.

> Suggestions?

Either adding `make-temp-file' from Emacs 22 as suggested or do the
`rename-file' thingie as in ``mm-display-external'.

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




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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-02-13 22:16                     ` Reiner Steib
@ 2006-02-14  0:11                       ` Katsumi Yamaoka
  2006-02-14 11:50                         ` Katsumi Yamaoka
  2006-02-14 20:08                         ` Viewing HTML-mails with external browsers - proposed code Hynek Schlawack
  0 siblings, 2 replies; 20+ messages in thread
From: Katsumi Yamaoka @ 2006-02-14  0:11 UTC (permalink / raw)


>>>>> In <v9lkweucoj.fsf@marauder.physik.uni-ulm.de> Reiner Steib wrote:

> Either adding `make-temp-file' from Emacs 22 as suggested or do the
> `rename-file' thingie as in ``mm-display-external'.

I'll add the Emacs 22 version of make-temp-file.  (Now I'm
modifying gnus-draft.el, so I'll do it after that.)



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-02-14  0:11                       ` Katsumi Yamaoka
@ 2006-02-14 11:50                         ` Katsumi Yamaoka
  2006-02-15  8:39                           ` mm-make-temp-file (was Re: Viewing HTML-mails with external browsers - proposed code) Katsumi Yamaoka
  2006-02-14 20:08                         ` Viewing HTML-mails with external browsers - proposed code Hynek Schlawack
  1 sibling, 1 reply; 20+ messages in thread
From: Katsumi Yamaoka @ 2006-02-14 11:50 UTC (permalink / raw)


>>>>> In <b4m3bimer4f.fsf@jpl.org> Katsumi Yamaoka wrote:

> I'll add the Emacs 22 version of make-temp-file.

I've added it to the trunk and made it work with XEmacs as well.
However, it is a bit unsafe with XEmacs.  It is thought that a
sly attacker can make a temp file (which can be read by him) of
the same name just before a user makes it.  Therefore, XEmacs
users had better set a secure temp directory which only you can
access.

#v+
`temp-directory' is a built-in function
(temp-directory)

Documentation:
Return the pathname to the directory to use for temporary files.
On MS Windows, this is obtained from the TEMP or TMP environment
variables, defaulting to / if they are both undefined.
On Unix it is obtained from TMPDIR, with /tmp as the default.
#v-

The former one was rather unsafe if a user doesn't use a secure
temp directory, though.  In addition, the way that
`mm-display-external' used (i.e., `rename-file' after
`mm-make-temp-file') was also a bit unsafe for the same reason.

The function can be modified so that it may work also with Emacs
20, but it will be a bit unsafe as well as XEmacs.

P.S.  APEL provides a pretty good version of `make-temp-file'.
If you load `poe' before `mm-util', `mm-make-temp-file' will be
an alias to it.  I think the one defined in mm-util.el is
sufficient, though.



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

* Re: Viewing HTML-mails with external browsers - proposed code
  2006-02-14  0:11                       ` Katsumi Yamaoka
  2006-02-14 11:50                         ` Katsumi Yamaoka
@ 2006-02-14 20:08                         ` Hynek Schlawack
  1 sibling, 0 replies; 20+ messages in thread
From: Hynek Schlawack @ 2006-02-14 20:08 UTC (permalink / raw)


Katsumi Yamaoka <yamaoka@jpl.org> writes:

>> Either adding `make-temp-file' from Emacs 22 as suggested or do the
>> `rename-file' thingie as in ``mm-display-external'.
> I'll add the Emacs 22 version of make-temp-file.

Thanks!

Reiner, care to fix the CVS again? :)



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

* mm-make-temp-file (was Re: Viewing HTML-mails with external browsers - proposed code)
  2006-02-14 11:50                         ` Katsumi Yamaoka
@ 2006-02-15  8:39                           ` Katsumi Yamaoka
  0 siblings, 0 replies; 20+ messages in thread
From: Katsumi Yamaoka @ 2006-02-15  8:39 UTC (permalink / raw)


>>>>> In <b4mek2640rl.fsf@jpl.org> Katsumi Yamaoka wrote:

> I've added it to the trunk and made it work with XEmacs as well.

I've added the Emacs 22 version of make-temp-file also to the
v5-10 branch.  It supports Emacs 20 as well.

(No need to merge the change into the trunk.)



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

end of thread, other threads:[~2006-02-15  8:39 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-18 21:49 Viewing HTML-mails with external browsers - proposed code Hynek Schlawack
2006-01-13 13:42 ` Hynek Schlawack
2006-01-13 15:57   ` Reiner Steib
2006-01-13 17:13     ` Hynek Schlawack
2006-01-19 19:35 ` Reiner Steib
2006-01-22 12:40   ` Hynek Schlawack
2006-01-25 14:44     ` Reiner Steib
2006-01-25 16:29       ` Hynek Schlawack
2006-01-25 17:41         ` Reiner Steib
2006-01-31 12:38           ` Hynek Schlawack
2006-02-10 18:15             ` Reiner Steib
2006-02-13  0:06               ` Katsumi Yamaoka
2006-02-13 14:53                 ` Reiner Steib
2006-02-13 15:24                   ` Hynek Schlawack
2006-02-13 15:37                   ` Hynek Schlawack
2006-02-13 22:16                     ` Reiner Steib
2006-02-14  0:11                       ` Katsumi Yamaoka
2006-02-14 11:50                         ` Katsumi Yamaoka
2006-02-15  8:39                           ` mm-make-temp-file (was Re: Viewing HTML-mails with external browsers - proposed code) Katsumi Yamaoka
2006-02-14 20:08                         ` Viewing HTML-mails with external browsers - proposed code Hynek Schlawack

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