平衡点


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 ってまだ必要なんだっけ?


連絡先など
最近の日記
  • 2025/03/25
    • 1. Wanderlustで日本語の添付ファイルを扱う defadvice を nadvice に書き換える(失敗?)
  • 2025/03/06
    • 1. Emacs30 で lookup-el が動かなくなった.
  • 2025/02/20
    • 1. Thinkpad X13 Gen5 を購入した.
  • 2024/12/05
    • 1. 11月末〜12月の出張三昧がようやく一段落
    • 2. サイトの scss を Dart Sass v3.5 に対応
  • 2024/10/09
    • 1. Mastodon でのメール通知, というか Exim4 と Apparmor
一覧
2006|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|02|03|04|08|09|10|11|12|
2013|01|02|03|04|05|06|08|09|10|11|12|
2014|01|02|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|09|10|
2016|02|03|
2017|01|02|03|05|06|07|09|11|12|
2018|03|06|07|10|11|12|
2019|01|02|03|04|05|07|10|12|
2020|01|02|03|04|05|08|09|10|11|12|
2021|01|02|03|05|06|07|08|09|11|12|
2022|01|02|03|04|05|06|08|10|11|12|
2023|02|03|04|06|08|09|11|12|
2024|01|02|03|04|05|06|10|12|
2025|02|03|
Back to Top ▲