@@ -46,29 +46,53 @@ If major MODE is non-nil, enable it for the popup buffer.
46
46
If ANCILLARY is non-nil, the buffer is added to `cider-ancillary-buffers'
47
47
and automatically removed when killed."
48
48
(thread-first (cider-make-popup-buffer name mode ancillary)
49
+ (buffer-name )
49
50
(cider-popup-buffer-display select)))
50
51
51
- (defun cider-popup-buffer-display (buffer &optional select )
52
- " Display BUFFER.
53
- If SELECT is non-nil, select the BUFFER."
54
- (let ((window (get-buffer-window buffer 'visible )))
55
- (when window
56
- (with-current-buffer buffer
57
- (set-window-point window (point ))))
58
- ; ; If the buffer we are popping up is already displayed in the selected
59
- ; ; window, the below `inhibit-same-window' logic will cause it to be
60
- ; ; displayed twice - so we early out in this case. Note that we must check
61
- ; ; `selected-window' , as async request handlers are executed in the context
62
- ; ; of the current connection buffer (i.e. `current-buffer' is dynamically
63
- ; ; bound to that).
64
- (unless (eq window (selected-window ))
65
- ; ; Non nil `inhibit-same-window' ensures that current window is not covered
66
- ; ; Non nil `inhibit-switch-frame' ensures that the other frame is not selected
67
- ; ; if that's where the buffer is being shown.
68
- (funcall (if select #'pop-to-buffer #'display-buffer )
69
- buffer `(nil . ((inhibit-same-window . , pop-up-windows )
70
- (reusable-frames . visible))))))
71
- buffer)
52
+ (defun cider-popup-buffer-display (buffer-name &optional select )
53
+ " Display the buffer identified by BUFFER-NAME.
54
+ If SELECT is non-nil, select the buffer.
55
+
56
+ You can customize how the window will be chosen/created
57
+ by adding BUFFER-NAME to the `special-display-buffer-names' list."
58
+ (let ((buffer-name (if (bufferp buffer-name) ; ; ensure buffer-name is a string
59
+ (buffer-name buffer-name)
60
+ buffer-name)))
61
+ ; ; if `buffer-name' belongs to `special-display-buffer-names' ,
62
+ ; ; delegate to that mechanism the displaying of the buffer,
63
+ ; ; otherwise the displaying would happen twice (ance through `special-display-buffer-names' ,
64
+ ; ; another time through `cider-popup-buffer-display' ):
65
+ (if (and (boundp 'special-display-buffer-names )
66
+ (seq-find (lambda (entry )
67
+ (equal (car entry) buffer-name))
68
+ special-display-buffer-names))
69
+ (progn
70
+ (display-buffer buffer-name)
71
+ (when select
72
+ (when-let ((window (get-buffer-window buffer-name)))
73
+ (select-window window))))
74
+ (let ((window (get-buffer-window buffer-name 'visible )))
75
+ (when window
76
+ (with-current-buffer buffer-name
77
+ (set-window-point window (point ))))
78
+ ; ; If the buffer we are popping up is already displayed in the selected
79
+ ; ; window, the below `inhibit-same-window' logic will cause it to be
80
+ ; ; displayed twice - so we early out in this case. Note that we must check
81
+ ; ; `selected-window' , as async request handlers are executed in the context
82
+ ; ; of the current connection buffer (i.e. `current-buffer' is dynamically
83
+ ; ; bound to that).
84
+ (unless (eq window (selected-window ))
85
+ ; ; Non nil `inhibit-same-window' ensures that current window is not covered
86
+ ; ; Non nil `inhibit-switch-frame' ensures that the other frame is not selected
87
+ ; ; if that's where the buffer is being shown.
88
+ (funcall (if select #'pop-to-buffer #'display-buffer )
89
+ buffer-name `(nil . ((inhibit-same-window .
90
+ ; ; A non-nil value prevents the same window from being used for display:
91
+ , pop-up-windows )
92
+ (reusable-frames .
93
+ ; ; choose any visible frame
94
+ visible)))))))
95
+ buffer-name))
72
96
73
97
(defun cider-popup-buffer-quit (&optional kill )
74
98
" Quit the current (temp) window.
0 commit comments