平衡点
2025/08/09
_ Wanderlustで日本語の添付ファイルを扱う defadvice を nadvice に書き換える(again)
前回, うまく動いてなかったので revert したのだけれど, うまくできたので変更.
やりたいこと
Emacs30 から defadvice
が obsolete となったので,
nadvice
向けに処理を書き換える.
変更前
(with-eval-after-load 'eword-decode
(mime-set-field-decoder
'From nil 'eword-decode-and-unfold-unstructured-field-body)
(mime-set-field-decoder
'CC nil 'eword-decode-and-unfold-unstructured-field-body)
(mime-set-field-decoder
'To nil 'eword-decode-and-unfold-unstructured-field-body))
;;; ファイル名が日本語の添付ファイルをデコードする [semi-gnus-ja: 4332]
(eval-after-load "mime"
'(defadvice mime-entity-filename
(after eword-decode-for-broken-MUA activate)
"Decode eworded file name for *BROKEN* MUA."
(when (stringp ad-return-value)
(setq ad-return-value (eword-decode-string ad-return-value t)))))
(eval-after-load "std11"
'(defadvice std11-wrap-as-quoted-string (before encode-string activate)
"Encode a string."
(require 'eword-encode)
(ad-set-arg 0 (or (eword-encode-string (ad-get-arg 0)) "" )) ))
変更後
(leaf eword-decode
;; 日本語ファイル名の添付ファイルを処理するための advice で使うために
;; 以下の二つを autoload 扱いにしておく
:commands (eword-decode-string
eword-encode-string)
:config
(mime-set-field-decoder
'From nil 'eword-decode-and-unfold-unstructured-field-body)
(mime-set-field-decoder
'CC nil 'eword-decode-and-unfold-unstructured-field-body)
(mime-set-field-decoder
'To nil 'eword-decode-and-unfold-unstructured-field-body)
)
;;; ファイル名が日本語の添付ファイルをデコードする: 元ネタ [semi-gnus-ja: 4332]
;;; ...所で, semi-gnus-ja のアーカイブってどこにあるのかしらん...
(leaf mime
:preface
;;;###autoload
(defun my:decode-mime-filename-around (orig-fun &rest args)
"Decode the filename returned by the original function if it's a string."
(let ((return-value (apply orig-fun args)))
(if (stringp return-value)
(progn
(eword-decode-string return-value t))
return-value)))
:advice
(:around mime-entity-filename
my:decode-mime-filename-around)
)
(leaf std11
:preface
;;;###autoload
(defun my:encode-string-filter-args (args)
"Encode the first argument in a list of ARGS."
(let* ((original-string (car args))
(encoded-string (or (eword-encode-string original-string) "")))
(cons encoded-string (cdr args))))
:advice
(:filter-args encode-string
my:encode-string-filter-args)
)
というわけで.
手元の設定ファイルからは defadvice
は無くなりました.
[ツッコミを入れる]