kiwanami / emacs-window-manager

Customizable window manager for emacs
230 stars 28 forks source link

fix error at e2wm:dp-dashboard-insert-summary-info in Emacs 24.3.1 of Ubuntu12.04 #74

Closed aki2o closed 9 years ago

aki2o commented 9 years ago

dashboardパースペクティブを起動しようとしたら、以下のエラーが発生しました。

e2wm:dp-dashboard-insert-summary-info: Wrong type argument: number-or-marker-p, conses

対象環境について

当方の環境は、Ubuntu12.04のEmacs24.3.1です。 Emacsは、以下の手順でインストールしたと記憶してます。

sudo add-apt-repository ppa:cassou/emacs
sudo apt-get update
sudo apt-get install emacs24 emacs24-el emacs24-common-non-dfsg emacs-snapshot-el emacs-snapshot-gtk emacs-snapshot

原因について

調べると、どうもgarbage-collectの戻り値が実装されているロジックの想定と異なるようです。 当方では、以下のような値が返ってきます。

(garbage-collect) ; => ((conses 8 1829449 59472) (symbols 24 82827 72) (miscs 20 348 1178) (strings 16 439083 8091) (string-bytes 1 9935470) (vectors 12 63292) (vector-slots 4 1819420 112158) (floats 8 1057 887) (intervals 28 2010 1478) (buffers 504 39) (heap 1024 55090 3579))

また、(describe-function 'garbage-collect)で得られたドキュメントは以下です。

garbage-collect is an interactive built-in function in `C source
code'.

(garbage-collect)

Reclaim storage for Lisp objects no longer needed.
Garbage collection happens automatically if you cons more than
`gc-cons-threshold' bytes of Lisp data since previous garbage collection.
`garbage-collect' normally returns a list with info on amount of space in use,
where each entry has the form (NAME SIZE USED FREE), where:
- NAME is a symbol describing the kind of objects this entry represents,
- SIZE is the number of bytes used by each one,
- USED is the number of those objects that were found live in the heap,
- FREE is the number of those objects that are not live but that Emacs
  keeps around for future allocations (maybe because it does not know how
  to return them to the OS).
However, if there was overflow in pure space, `garbage-collect'
returns nil, because real GC can't be done.
See Info node `(elisp)Garbage Collection'.

[back]

修正内容について

当環境向けに、garbage-collectをパースする関数を別途用意しています。 この修正により、当環境ではdashboardパースペクティブが正常に開けていると感じています。

ただ、e2wm:dp-dashboard-parse-garbage-collectの実装は、暫定的な感じです。 とりあえずは、パースする関数の候補を1つずつ試していって、要素全て数値の結果が得られたら、 それを採用してます。 また、ここでエラーが発生してしまうと、popwin.elとかのウィンドウ分割機能も動作しなくなってしまいました。 なので、エラー回避のために、パースが失敗したら全要素0の結果を返すようにしています。

kiwanami commented 9 years ago

最近全然使っていませんでしたので、気づきませんでした。ありがとうございます! 実装もこの方法でいいと思います。gcの統計情報を使うアプリなんてあまりないでしょうね。。。