cerhovice
cerhovice

Reputation: 686

emacs make frame switch buffer

I want to create a function in emacs that will create a new frame and then, in that new frame, fetch the list of buffers. I tried this:

(defun get-buffer-menu-in-new-frame (arg)
(make-frame)
(switch-to-buffer-other-frame ( list-buffers)))

I was working in init.el. I added this to call it:

(get-buffer-menu-in-new-frame)

Then I ran "eval-buffer". This seems to have worked: I got new frame, and it has the buffer list in it (I hope this result was not a coincidence.

But then I tried this:

(global-set-key (kbd "<f4>") 'get-buffer-menu-in-new-frame)

Then I hit the function4 key, but I got:

recursive-edit: Wrong type argument: commandp, get-buffer-menu-in-new-frame

What am I doing wrong?

Upvotes: 1

Views: 389

Answers (1)

Nicolas Dudebout
Nicolas Dudebout

Reputation: 9262

You need to make your function into a command by using interactive.

(defun get-buffer-menu-in-new-frame ()
  (interactive)
  (switch-to-buffer-other-frame (list-buffers-noselect)))

I also removed arg that was not used.

Upvotes: 4

Related Questions