Gnus development mailing list
 help / color / mirror / Atom feed
From: Jaap-Henk Hoepman <hoepman@cs.utwente.nl>
Subject: Patch (mm-encode.el): delayed destroy of external mime viewers
Date: 04 May 2001 21:27:40 +0200	[thread overview]
Message-ID: <kpelu4j4nn.fsf@utip202.cs.utwente.nl> (raw)

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


The following patch implements delayed destroy of external mime viewers. All
external mime viewers on parts whose type is a member of the list
        mm-keep-viewer-alive-types
will not be destroyed when switching to another article or to another group. 
Instead, these viewers stay open until they are explicitly closed by the user,
or until gnus is exited. Any remaining temporary files are removed when
exiting gnus.

Could someone please commit this patch, and perhaps look at a more suitable
default for mm-keep-viewer-alive-types

Thanks,
Jaap-Henk


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mm-decode.el.patch --]
[-- Type: text/x-patch, Size: 3418 bytes --]

--- mm-decode.el.orig	Fri May  4 21:17:17 2001
+++ mm-decode.el	Fri May  4 21:18:23 2001
@@ -22,6 +22,14 @@
 
 ;;; Commentary:
 
+;; Jaap-Henk Hoepman (jhh@xs4all.nl): 
+;;
+;; Added support for delayed destroy of external MIME viewers. All external
+;; viewers for mime types in mm-keep-viewer-alive-types will remain active
+;; after switching articles or groups, and will only be removed when exiting
+;; gnus.
+;; 
+
 ;;; Code:
 
 (require 'mail-parse)
@@ -32,6 +40,8 @@
 (eval-and-compile
   (autoload 'mm-inline-partial "mm-partial"))
 
+(add-hook 'gnus-exit-gnus-hook 'mm-destroy-postponed-undisplay-list)
+
 (defgroup mime-display ()
   "Display of MIME in mail and news articles."
   :link '(custom-manual "(emacs-mime)Customization")
@@ -158,6 +168,15 @@
   "List of media types that are to be displayed inline."
   :type '(repeat string)
   :group 'mime-display)
+
+(defcustom mm-keep-viewer-alive-types
+  '("application/postscript" "application/msword" "application/vnd.ms-excel"
+    "application/pdf" "application/x-dvi"
+   )
+  "List of media types for which the external viewer will not be killed
+when selecting a different article."
+  :type '(repeat string)
+  :group 'mime-display)
   
 (defcustom mm-automatic-display
   '("text/plain" "text/enriched" "text/richtext" "text/html"
@@ -212,6 +231,7 @@
 (defvar mm-dissection-list nil)
 (defvar mm-last-shell-command "")
 (defvar mm-content-id-alist nil)
+(defvar mm-postponed-undisplay-list nil)
 
 ;; According to RFC2046, in particular, in a digest, the default
 ;; Content-Type value for a body part is changed from "text/plain" to
@@ -229,6 +249,35 @@
 
 ;;; The functions.
 
+(defun mm-keep-viewer-alive-p (handle)
+  "Say whether external viewer for HANDLE should stay alive."
+  (let ((types mm-keep-viewer-alive-types)
+	(type (mm-handle-media-type handle))
+	ty)
+    (catch 'found
+      (while (setq ty (pop types))
+	(when (string-match ty type)
+	  (throw 'found t))))))
+
+(defun mm-handle-set-external-undisplayer (handle function)
+ "Set the undisplayer for this handle; postpone undisplaying of viewers
+for types in mm-keep-viewer-alive-types."
+  (if (mm-keep-viewer-alive-p handle)
+    (progn
+     (setq new-handle (copy-sequence handle))
+     (mm-handle-set-undisplayer new-handle function)
+     (mm-handle-set-undisplayer handle nil)
+     (push new-handle mm-postponed-undisplay-list)
+    )
+  (mm-handle-set-undisplayer handle function)
+  )
+)
+
+(defun mm-destroy-postponed-undisplay-list ()
+  (message "Destroying external MIME viewers")
+  (mm-destroy-parts mm-postponed-undisplay-list)
+)
+
 (defun mm-dissect-buffer (&optional no-strict-mime)
   "Dissect the current buffer and return a list of MIME handles."
   (save-excursion
@@ -432,7 +481,7 @@
 				    shell-command-switch
 				    (mm-mailcap-command
 				     method file (mm-handle-type handle)))
-		   (mm-handle-set-undisplayer handle (cons file buffer)))
+		   (mm-handle-set-external-undisplayer handle (cons file buffer)))
 		 (message "Displaying %s..." (format method file))
 		 'external)
 		(copiousoutput
@@ -468,7 +517,7 @@
 				    shell-command-switch
 				    (mm-mailcap-command
 				     method file (mm-handle-type handle)))
-		   (mm-handle-set-undisplayer handle (cons file buffer)))
+		   (mm-handle-set-external-undisplayer handle (cons file buffer)))
 		 (message "Displaying %s..." (format method file))
 		 'external)))))))
   

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


-- 
Jaap-Henk Hoepman             | Come sail your ships around me
Dept. of Computer Science     | And burn your bridges down
University of Twente          |       Nick Cave - "Ship Song"
Email: hoepman@cs.utwente.nl === WWW: www.cs.utwente.nl/~hoepman
Phone: +31 53 4893795 === Secr: +31 53 4893770 === Fax: +31 53 4894590
PGP ID: 0xF52E26DD  Fingerprint: 1AED DDEB C7F1 DBB3  0556 4732 4217 ABEF

                 reply	other threads:[~2001-05-04 19:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kpelu4j4nn.fsf@utip202.cs.utwente.nl \
    --to=hoepman@cs.utwente.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).