kiwanami/emacs-anything-books — Issue #4: Problem when manipulating file with run-with-idle-timer
Author: tkf
Created: 2012-01-31 18:44:08+00:00
State: open

run-with-idle-timer でファイルを保存する関数(recentf-save-list など)を呼ぶと、ウィンドウ構成が崩れてしまうようです。以下のファイルを `emacs -l file` で読み込んで起動させると、問題を再現できます。例えば、 e2wm:dp-magit を開き、 Magit Logs window で log を前後して、 `*magit-commit*` window を表示させ、5秒まつとこの `*magit-commit*` window が消え、元の `*magit: REPO*` buffer が表示されてしまいます。

my-recentf-auto-save-list-workaround を呼ぶとこの問題は起きないのですが、代わりに warning message が出てしまいます。ちなみに、idleに入る前に e2wm 管理下に無いフレームに居た場合はこの問題は起きません。

```lisp
(add-to-list 'load-path "~/.emacs.d/el-get/e2wm/")
(add-to-list 'load-path "~/.emacs.d/el-get/window-layout/")
(add-to-list 'load-path "~/.emacs.d/el-get/magit/")
(add-to-list 'load-path "~/.emacs.d/el-get/monky/")

(require 'recentf)
(require 'e2wm-config)
(require 'e2wm-vcs)

(run-with-idle-timer 5 t 'recentf-save-list)
;; (run-with-idle-timer 5 t 'my-recentf-auto-save-list-workaround)

(defun my-recentf-auto-save-list-workaround ()
(flet ((warn (fmt &rest args) (apply 'message fmt args))
;; a hack to make things ignored by e2wm
(e2wm:pst-get-instance (&optional frame) nil))
(recentf-save-list)))

(recentf-mode 1)
(e2wm:start-management)

;; How to reproduce:
;; 1. Open some file (in Git repository)
;; 2. M-x e2wm:dp-magit
;; 3. Open some other buffer in the main window
;; 4. Wait 5 sec, then the default window set appears automatically

;; When my-recentf-auto-save-list-workaround is used, you will see an Error:
;; recentf mode: Wrong type argument: arrayp, nil
```