From 120b2bb67b6186427ca1a007f1a11ddf3e220c5b Mon Sep 17 00:00:00 2001 From: Stephen Gildea Date: Mon, 23 Aug 2021 19:58:13 -0700 Subject: [PATCH] ; migrate MH-E to mail-parse library Move MH-E from low-level libraries to the high-level mail-parse library. * lisp/mh-e/mh-comp.el: replace ietf-drums-parse-address with mail-header-parse-address. * lisp/mh-e/mh-junk.el: replace ietf-drums-parse-address with mail-header-parse-address; remove mh-funcall-if-exists wrapper. * lisp/mh-e/mh-xface.el: replace ietf-drums-parse-address with mail-header-parse-address; remove fboundp wrapper. * lisp/mh-e/mh-mime.el: replace rfc2047-decode-region with mail-decode-encoded-word-region. --- lisp/mh-e/mh-comp.el | 3 ++- lisp/mh-e/mh-junk.el | 5 +++-- lisp/mh-e/mh-mime.el | 9 +++++---- lisp/mh-e/mh-xface.el | 7 ++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lisp/mh-e/mh-comp.el b/lisp/mh-e/mh-comp.el index 4fae69defaf..404b6b3ce75 100644 --- a/lisp/mh-e/mh-comp.el +++ b/lisp/mh-e/mh-comp.el @@ -38,6 +38,7 @@ (require 'sendmail) (autoload 'easy-menu-add "easymenu") +(autoload 'mail-header-parse-address "mail-parse") (autoload 'mml-insert-tag "mml") @@ -452,7 +453,7 @@ See also `mh-send'." ;; Header field exists and we have a value (let (address mailbox (alias (mh-alias-expand value))) (and alias - (setq address (ietf-drums-parse-address alias)) + (setq address (mail-header-parse-address alias)) (setq mailbox (car address))) ;; XXX - Need to parse all addresses out of field (if (and diff --git a/lisp/mh-e/mh-junk.el b/lisp/mh-e/mh-junk.el index 6c3674811b0..467667f5afd 100644 --- a/lisp/mh-e/mh-junk.el +++ b/lisp/mh-e/mh-junk.el @@ -31,6 +31,8 @@ (require 'mh-e) (require 'mh-scan) +(autoload 'mail-header-parse-address "mail-parse") + ;;;###mh-autoload (defun mh-junk-blocklist (range) "Blocklist RANGE as spam. @@ -312,8 +314,7 @@ See `mh-spamassassin-blocklist' for more information." "--ham" "--local" "--no-sync"))) (message "Allowlisting sender of message %d..." msg) (setq from - (car (mh-funcall-if-exists - ietf-drums-parse-address (mh-get-header-field "From:")))) + (car (mail-header-parse-address (mh-get-header-field "From:")))) (kill-buffer nil) (if (or (null from) (equal from "")) (message "Allowlisting sender of message %d...%s" diff --git a/lisp/mh-e/mh-mime.el b/lisp/mh-e/mh-mime.el index ef702525b7b..ad594aef906 100644 --- a/lisp/mh-e/mh-mime.el +++ b/lisp/mh-e/mh-mime.el @@ -51,6 +51,7 @@ (autoload 'article-emphasize "gnus-art") (autoload 'gnus-eval-format "gnus-spec") (autoload 'mail-content-type-get "mail-parse") +(autoload 'mail-decode-encoded-word-region "mail-parse") (autoload 'mail-decode-encoded-word-string "mail-parse") (autoload 'mail-header-parse-content-type "mail-parse") (autoload 'mail-header-strip-cte "mail-parse") @@ -61,7 +62,6 @@ (autoload 'mm-decode-body "mm-bodies") (autoload 'mm-uu-dissect "mm-uu") (autoload 'mml-unsecure-message "mml-sec") -(autoload 'rfc2047-decode-region "rfc2047") (autoload 'widget-convert-button "wid-edit") @@ -496,7 +496,7 @@ decoding the same message multiple times." "Decode RFC2047 encoded message header fields." (when mh-decode-mime-flag (let ((buffer-read-only nil)) - (rfc2047-decode-region (point-min) (mh-mail-header-end))))) + (mail-decode-encoded-word-region (point-min) (mh-mail-header-end))))) ;;;###mh-autoload (defun mh-decode-message-subject () @@ -504,8 +504,9 @@ decoding the same message multiple times." (when mh-decode-mime-flag (save-excursion (let ((buffer-read-only nil)) - (rfc2047-decode-region (progn (mh-goto-header-field "Subject:") (point)) - (progn (mh-header-field-end) (point))))))) + (mail-decode-encoded-word-region + (progn (mh-goto-header-field "Subject:") (point)) + (progn (mh-header-field-end) (point))))))) ;;;###mh-autoload (defun mh-mime-display (&optional pre-dissected-handles) diff --git a/lisp/mh-e/mh-xface.el b/lisp/mh-e/mh-xface.el index bc4cc6ecd7d..58177c1794e 100644 --- a/lisp/mh-e/mh-xface.el +++ b/lisp/mh-e/mh-xface.el @@ -27,6 +27,7 @@ (require 'mh-e) +(autoload 'mail-header-parse-address "mail-parse") (autoload 'message-fetch-field "message") (defvar mh-show-xface-function @@ -190,11 +191,7 @@ The directories are searched for in the order they appear in the list.") (let* ((from-field (ignore-errors (car (message-tokenize-header (mh-get-header-field "from:"))))) (from (car (ignore-errors - ;; Don't use mh-funcall-if-exists because - ;; ietf-drums-parse-address might exist at run-time but - ;; not at compile-time. - (when (fboundp 'ietf-drums-parse-address) - (ietf-drums-parse-address from-field))))) + (mail-header-parse-address from-field)))) (host (and from (string-match "\\([^+]*\\)\\(\\+.*\\)?@\\(.*\\)" from) (downcase (match-string 3 from)))) -- 2.39.2