When I create a new frame with make-frame-command, it automatically opens the currently open buffer in the new frame. Is it possible to change this to open the scratch buffer instead? I'm using perspective.el.
1 Answer
You can add a function that switches to the desired buffer, to the hook after-make-frame-functions:
(defun my/switch-to-scratch (frame) (switch-to-buffer "*scratch*")) (add-hook 'after-make-frame-functions #'my/switch-to-scratch t) Do C-h v after-make-frame-functions for more info.
- Thanks for the trick. I had to add
(select-frame frame)before modifying the buffer with(dired "~"). Otherwise,diredwas performed in the old frame.Lalylulelo– Lalylulelo2023-07-20 06:48:27 +00:00Commented Jul 20, 2023 at 6:48