`flet’ is an obsolete macro のエラーメッセージの原因はこれだった

だいぶ前から、Emacsの起動時に

`flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.

というメッセージが出てきていました。自分の設定ファイルが悪いとは思っていなかったのですが、間違いでした。

以前に設定した

(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
        "Prevent annoying \"Active processes exist\" query when you quit Emacs."
        (flet ((process-list ())) ad-do-it))

が原因でした(汗)。これはEmacsを終了しようとする度に”Active processes exist”と言われるのを抑制するためのものです。

最近はfletはobsoleteなので、以下のように書き換えるようです(Stackoverflowから)。


(require 'cl-lib)
(defadvice save-buffers-kill-emacs (around no-query-kill-emacs activate)
  "Prevent annoying \"Active processes exist\" query when you quit Emacs."
  (cl-letf (((symbol-function #'process-list) (lambda ())))
    ad-do-it))

ちなみに、Artur Malabarbaさんによれば fletの置き換えは cl-letfが良いらしいです。メッセージではcl-flet or cl-letfの両方がでていますが…。

(symbol-function SYMBOL)

の置き換えも必要です。

Understanding letf and how it replaces flet · Endless Parentheses

Once you’ve come to terms with power of setf, it is time to meet its older sister, cl-letf. As the name implies, letf is to setf like let is to setq, but, once again, that is only the tip of the iceberg.

Adsense広告