aboutsummaryrefslogtreecommitdiff
path: root/perspective.el
diff options
context:
space:
mode:
authorConstantine Vetoshev <gepardcv@gmail.com>2020-08-11 22:48:50 -0700
committerConstantine Vetoshev <gepardcv@gmail.com>2020-08-11 22:48:50 -0700
commitaf03f649d36c116d044658a9152dce1ed4177bd3 (patch)
treee3f20c84a0c02a90363a97a51ed9e66ac5719fa7 /perspective.el
parent13fb1ddcbe0c10f1678604f4b98f32e0ebd0f343 (diff)
Respect initial-buffer-choice when opening a new frame with emacsclient.
Diffstat (limited to 'perspective.el')
-rw-r--r--perspective.el10
1 files changed, 9 insertions, 1 deletions
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)