added buffer functions from magnars @emacsrocks