From af03f649d36c116d044658a9152dce1ed4177bd3 Mon Sep 17 00:00:00 2001 From: Constantine Vetoshev Date: Tue, 11 Aug 2020 22:48:50 -0700 Subject: Respect initial-buffer-choice when opening a new frame with emacsclient. --- perspective.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/perspective.el b/perspective.el index 5bcdd60..4d630b9 100644 --- a/perspective.el +++ b/perspective.el @@ -1038,8 +1038,16 @@ By default, this uses the current frame." (unless (member '(:eval (persp-mode-line)) global-mode-string) (setq global-mode-string (append global-mode-string '((:eval (persp-mode-line))))))) (persp-update-modestring)) + ;; A frame must open with a reasonable initial buffer in its main + ;; perspective. This behaves differently from an emacsclient invocation, but + ;; should respect `initial-buffer-choice'. (when (frame-parameter frame 'client) - (switch-to-buffer (persp-scratch-buffer persp-initial-frame-name) t)) + (let* ((scratch-buf (persp-scratch-buffer persp-initial-frame-name)) + (init-buf (cond ((stringp initial-buffer-choice) initial-buffer-choice) + ((functionp initial-buffer-choice) (or (funcall initial-buffer-choice) + scratch-buf)) + (t scratch-buf)))) + (switch-to-buffer init-buf t))) (persp-activate (make-persp :name persp-initial-frame-name :buffers (list (current-buffer)) :window-configuration (current-window-configuration) -- cgit v1.0