平衡点
2025/03/25
_ Wanderlustで日本語の添付ファイルを扱う defadvice を nadvice に書き換える(失敗?)
Emacs30 から defadvice
が obsolete となったので, 書き換えてみたり.
自分の設定ファイルを眺めてみたら,
書き換え対象は Wanderlust で日本語の添付ファイルを扱うための advice だった.
添付ファイル名が日本語の場合に正しく表示する advice
修正前
(leaf mime
:config
'(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))))
)
これを修正. ついでに eword-decode-string
が autoload される様にしてみたり.
(leaf eword-decode
:doc "クォートされた文字列もデコードするようにする"
:commands eword-decode-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)
)
;;
(leaf mime
:doc "日本語の添付ファイル名を正しく表示する"
:preface
;;;###autoload
(defun my:mime-entity-filename (orig-value)
"Decode eworded file name for *BROKEN* MUA."
(when (stringp orig-value)
(eword-decode-string orig-value t)))
:advice
(:filter-return mime-entity-filename
my:mime-entity-filename)
)
添付ファイル名が日本語の場合に正しくエンコードする advice
修正前. はて, 私はいつ use-package
に書き換えたんだろうか…?
(use-package std11
:config
'(defadvice std11-wrap-as-quoted-string (before encode-string activate)
"Encode a string."
(use-package eword-encode
(ad-set-arg 0 (or (eword-encode-string (ad-get-arg 0)) "" ))
)
))
これを修正. はて, 本当に filter-args
で良いのかな.
(leaf std11
:preface
(leaf eword-encode :commands eword-encode-string)
;;;###autoload
(defun std11-wrap-as-quoted-string-advice (string)
"Encode a string before wrapping as RFC 822 quoted-string."
(or (eword-encode-string string) ""))
:advice
((:filter-args std11-wrap-as-quoted-string
std11-wrap-as-quoted-string-advice)
)
)
…微妙に上手く動いていない, 様な? :around
なんだろうか?
ところで
これらの advice ってまだ必要なんだっけ?
[ツッコミを入れる]