Gnus:如何一次保存*所有*附件?

发布于 2024-12-19 04:53:13 字数 410 浏览 0 评论 0 原文

我想一次将所有附件保存到电子邮件中。因此,我将 gnus-summary-save-parts-default-mime 设置为“.* /.*”。但是,当使用“X m”时,我不仅获得所有附件,还获得名为“[email protected]/INBOX.2393.1"(指我正在阅读电子邮件的帐户),其中包含我收到的电子邮件的签名。如何排除这种“类型”的文件保存在“X m”上?换句话说:如何为 gnus-summary-save-parts-default-mime 指定正确的正则表达式以防止保存此文件?

I would like to save all attachments to an email at once. I therefore set gnus-summary-save-parts-default-mime to ".* /.*". However, when using "X m", I not only get all attachments, but also a file named "[email protected]/INBOX.2393.1" (referring to the account I'm reading emails from) which contains the signature of the email I received. How can I exclude files of this "type" from being saved on "X m"? In other words: How can I specify the correct regexp for gnus-summary-save-parts-default-mime to prevent this file from being saved, too?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云朵有点甜 2024-12-26 04:53:13

这个 defadvice 将通过排除任何没有文件名的部分来完成您目前想要的操作(在本例中,文章本身就是如此):

(defadvice gnus-summary-save-parts-1 (around gnus-summary-save-parts-exclude-self activate)
  (let ((handle (ad-get-arg 2)))
    (unless (and (not (stringp (car handle)))
                 (not (mm-handle-filename handle)))
      ad-do-it)))

我正在使用 Gnus v5.13;如果您也使用相同或相似的版本,请告诉我此修改版本的 gnus-summary-save-parts-1 是否适合您;您需要将gnus-summary-save-parts-exclude-article设置为t。如果它对你有用,我将向 Gnus 项目提交一个补丁。

请注意,可以使用上面的 defadvice OR 使用下面的代码,但不要同时使用两者。 defadvice 是一个简单的快速修复方法,您可以暂时使用。下面的代码我将作为 Gnus 项目的补丁提交,我在这里仅包含此代码供您测试,看看它是否适用于您的系统(如果您也使用 Gnus v5.13)。如果他们接受这个补丁并将其作为未来版本的一部分,那么您将不需要上面的 defadvice ;相反,您只需自定义 gnus-summary-save-parts-exclude-article 变量即可。

(require 'gnus)
(require 'gnus-sum)

(defcustom gnus-summary-save-parts-exclude-article nil
  "If non-nil don't save article along with attachments."
  :group 'gnus-article-mime
  :type 'boolean)

(defun gnus-summary-save-parts-1 (type dir handle reverse)
  (if (stringp (car handle))
      (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
          (cdr handle))
    (when (if reverse
          (not (string-match type (mm-handle-media-type handle)))
        (string-match type (mm-handle-media-type handle)))
      (let* ((name (or
                    (mm-handle-filename handle)
                    (unless gnus-summary-save-parts-exclude-article
                      (format "%s.%d.%d" gnus-newsgroup-name
                              (cdr gnus-article-current)
                              gnus-summary-save-parts-counter))))
             (file (when name
                     (expand-file-name
                      (gnus-map-function
                       mm-file-name-rewrite-functions
                       (file-name-nondirectory
                        name))
                      dir))))
        (when file
          (incf gnus-summary-save-parts-counter)
          (unless (file-exists-p file)
            (mm-save-part-to-file handle file)))))))

This defadvice will do what you want for the moment by excluding any parts that do not have filenames (in this case that is true of the article itself):

(defadvice gnus-summary-save-parts-1 (around gnus-summary-save-parts-exclude-self activate)
  (let ((handle (ad-get-arg 2)))
    (unless (and (not (stringp (car handle)))
                 (not (mm-handle-filename handle)))
      ad-do-it)))

I am using Gnus v5.13; if you're also using the same or similar version, let me know if this modified version of gnus-summary-save-parts-1 works for you; you will want to set gnus-summary-save-parts-exclude-article to t. If it works for you, I will submit a patch for it to the Gnus projects.

Note, either use the above defadvice OR use the code below, but do not use both together. The defadvice is an easy quick fix that you can use for the moment. The code below I will submit as a patch to the Gnus project and I only included this here for you to test to see if it works on your system if you are also using Gnus v5.13. If they accept this patch and make it part of a future release then you will not need the defadvice above; instead you'll just be able to customize the gnus-summary-save-parts-exclude-article variable.

(require 'gnus)
(require 'gnus-sum)

(defcustom gnus-summary-save-parts-exclude-article nil
  "If non-nil don't save article along with attachments."
  :group 'gnus-article-mime
  :type 'boolean)

(defun gnus-summary-save-parts-1 (type dir handle reverse)
  (if (stringp (car handle))
      (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
          (cdr handle))
    (when (if reverse
          (not (string-match type (mm-handle-media-type handle)))
        (string-match type (mm-handle-media-type handle)))
      (let* ((name (or
                    (mm-handle-filename handle)
                    (unless gnus-summary-save-parts-exclude-article
                      (format "%s.%d.%d" gnus-newsgroup-name
                              (cdr gnus-article-current)
                              gnus-summary-save-parts-counter))))
             (file (when name
                     (expand-file-name
                      (gnus-map-function
                       mm-file-name-rewrite-functions
                       (file-name-nondirectory
                        name))
                      dir))))
        (when file
          (incf gnus-summary-save-parts-counter)
          (unless (file-exists-p file)
            (mm-save-part-to-file handle file)))))))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文