mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-10 16:20:17 -08:00
* lisp/gnus/nnml.el (nnml-request-accept-article): * lisp/gnus/nnmairix.el (nnmairix-request-marks): * lisp/gnus/nnmail.el (nnmail-get-new-mail-1): * lisp/gnus/mm-view.el (mm-inline-image) (mm-inline-text-html-render-with-w3m, mm-inline-text) (mm-insert-inline, mm-inline-message): * lisp/gnus/mm-partial.el (mm-inline-partial): * lisp/gnus/mm-archive.el (mm-archive-dissect-and-inline): * lisp/gnus/gnus-util.el (gnus-create-info-command): * lisp/gnus/gnus-topic.el (gnus-topic-edit-parameters) (gnus-topic-sort-topics-1): * lisp/gnus/gnus-sum.el (gnus-summary-edit-article): * lisp/gnus/gnus-srvr.el (gnus-server-edit-server): * lisp/gnus/gnus-msg.el (gnus-inews-make-draft) (gnus-inews-add-send-actions, gnus-summary-cancel-article) (gnus-summary-supersede-article, gnus-summary-resend-message) (gnus-configure-posting-styles): * lisp/gnus/gnus-kill.el (gnus-execute): * lisp/gnus/gnus-html.el (gnus-html-wash-images): * lisp/gnus/gnus-group.el (gnus-group-edit-group) (gnus-group-nnimap-edit-acl): * lisp/gnus/gnus-draft.el (gnus-draft-edit-message, gnus-draft-setup): * lisp/gnus/gnus-art.el (gnus-article-edit-part) (gnus-mm-display-part, gnus-article-edit): * lisp/gnus/gnus-agent.el (gnus-category-edit-predicate) (gnus-category-edit-score, gnus-category-edit-groups): Use closures instead of `(lambda ...). * lisp/gnus/nnoo.el (noo--defalias): New function. (nnoo-import-1, nnoo-define-skeleton-1): Use it to avoid `eval`.
111 lines
3.6 KiB
EmacsLisp
111 lines
3.6 KiB
EmacsLisp
;;; mm-archive.el --- Functions for parsing archive files as MIME -*- lexical-binding: t; -*-
|
|
|
|
;; Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
|
|
|
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
|
|
;; This file is part of GNU Emacs.
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
(require 'mm-decode)
|
|
(autoload 'gnus-recursive-directory-files "gnus-util")
|
|
(autoload 'gnus-get-buffer-create "gnus")
|
|
(autoload 'mailcap-extension-to-mime "mailcap")
|
|
|
|
(defvar mm-archive-decoders
|
|
'(("application/ms-tnef" t "tnef" "-f" "-" "-C")
|
|
("application/zip" nil "unzip" "-j" "-x" "%f" "-d")
|
|
("application/x-gtar-compressed" nil "tar" "xzf" "-" "-C")
|
|
("application/x-tar-gz" nil "tar" "xzf" "-" "-C")
|
|
("application/x-tar" nil "tar" "xf" "-" "-C")))
|
|
|
|
(defun mm-archive-decoders () mm-archive-decoders)
|
|
|
|
(defun mm-dissect-archive (handle)
|
|
(let* ((type (car (mm-handle-type handle)))
|
|
(decoder (cddr (assoc type mm-archive-decoders)))
|
|
dir)
|
|
(unless decoder
|
|
(error "No decoder found for %s" type))
|
|
(with-file-modes #o700
|
|
(setq dir (make-temp-file (expand-file-name "emm." mm-tmp-directory)
|
|
'dir)))
|
|
(unwind-protect
|
|
(progn
|
|
(mm-with-unibyte-buffer
|
|
(mm-insert-part handle)
|
|
(if (member "%f" decoder)
|
|
(let ((file (expand-file-name "mail.zip" dir)))
|
|
(write-region (point-min) (point-max) file nil 'silent)
|
|
(setq decoder (copy-sequence decoder))
|
|
(setcar (member "%f" decoder) file)
|
|
(apply #'call-process (car decoder) nil nil nil
|
|
(append (cdr decoder) (list dir)))
|
|
(delete-file file))
|
|
(apply #'call-process-region (point-min) (point-max) (car decoder)
|
|
nil (gnus-get-buffer-create "*tnef*")
|
|
nil (append (cdr decoder) (list dir)))))
|
|
`("multipart/mixed"
|
|
,handle
|
|
,@(mm-archive-list-files (gnus-recursive-directory-files dir))))
|
|
(delete-directory dir t))))
|
|
|
|
(defun mm-archive-list-files (files)
|
|
(let ((handles nil)
|
|
type disposition)
|
|
(dolist (file files)
|
|
(with-temp-buffer
|
|
(when (string-match "\\.\\([^.]+\\)$" file)
|
|
(setq type (mailcap-extension-to-mime (match-string 1 file))))
|
|
(unless type
|
|
(setq type "application/octet-stream"))
|
|
(setq disposition
|
|
(if (string-match "^image/\\|^text/" type)
|
|
"inline"
|
|
"attachment"))
|
|
(insert (format "Content-type: %s\n" type))
|
|
(insert "Content-Transfer-Encoding: 8bit\n\n")
|
|
(insert-file-contents file)
|
|
(push
|
|
(mm-make-handle (mm-copy-to-buffer)
|
|
(list type)
|
|
'8bit nil
|
|
`(,disposition (filename . ,file))
|
|
nil nil nil)
|
|
handles)))
|
|
handles))
|
|
|
|
(defun mm-archive-dissect-and-inline (handle)
|
|
(let ((start (point-marker)))
|
|
(save-restriction
|
|
(narrow-to-region (point) (point))
|
|
(dolist (handle (cddr (mm-dissect-archive handle)))
|
|
(goto-char (point-max))
|
|
(mm-display-inline handle))
|
|
(goto-char (point-max))
|
|
(mm-handle-set-undisplayer
|
|
handle
|
|
(let ((end (point-marker)))
|
|
(lambda ()
|
|
(let ((inhibit-read-only t))
|
|
(remove-images start end)
|
|
(delete-region start end))))))))
|
|
|
|
(provide 'mm-archive)
|
|
|
|
;; mm-archive.el ends here
|