Fix breaking change in window--display-buffer

This change is present in later builds of Emacs 27, where
window--display-buffer no longer has a 5th argument.
This commit is contained in:
Henrik Lissner 2019-02-15 19:53:15 -05:00
parent 0edeafadcf
commit c5cd97d3cc
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -456,7 +456,7 @@ Accepts the same arguments as `display-buffer-in-side-window'. You must set
(slot (or (cdr (assq 'slot alist)) 0)) (slot (or (cdr (assq 'slot alist)) 0))
(vslot (or (cdr (assq 'vslot alist)) 0)) (vslot (or (cdr (assq 'vslot alist)) 0))
(left-or-right (memq side '(left right))) (left-or-right (memq side '(left right)))
(dedicated (or display-buffer-mark-dedicated 'popup))) (display-buffer-mark-dedicated (or display-buffer-mark-dedicated 'popup)))
(cond ((not (memq side '(top bottom left right))) (cond ((not (memq side '(top bottom left right)))
(error "Invalid side %s specified" side)) (error "Invalid side %s specified" side))
@ -544,7 +544,7 @@ Accepts the same arguments as `display-buffer-in-side-window'. You must set
(with-current-buffer buffer (with-current-buffer buffer
(setq window--sides-shown t)) (setq window--sides-shown t))
(window--display-buffer (window--display-buffer
buffer this-window 'reuse alist dedicated)) buffer this-window 'reuse alist))
(and (or (not max-slots) (< slots max-slots)) (and (or (not max-slots) (< slots max-slots))
(or (and next-window (or (and next-window
;; Make new window before `next-window'. ;; Make new window before `next-window'.
@ -564,7 +564,7 @@ Accepts the same arguments as `display-buffer-in-side-window'. You must set
(with-current-buffer buffer (with-current-buffer buffer
(setq window--sides-shown t)) (setq window--sides-shown t))
(window--display-buffer (window--display-buffer
buffer window 'window alist dedicated)) buffer window 'window alist))
(and best-window (and best-window
;; Reuse `best-window'. ;; Reuse `best-window'.
(progn (progn
@ -573,12 +573,22 @@ Accepts the same arguments as `display-buffer-in-side-window'. You must set
(with-current-buffer buffer (with-current-buffer buffer
(setq window--sides-shown t)) (setq window--sides-shown t))
(window--display-buffer (window--display-buffer
buffer best-window 'reuse alist dedicated))))))))) buffer best-window 'reuse alist)))))))))
;; ;;
;; Emacs backwards compatibility ;; Emacs backwards compatibility
(unless EMACS27+
(defun +popup*set-window-dedicated (window)
"Ensure `window--dispaly-buffer' respects `display-buffer-mark-dedicated'.
This was not so until recent Emacs 27 builds, where it causes breaking errors.
This advice ensures backwards compatibility for Emacs <= 26 users."
(when (and (windowp window) display-buffer-mark-dedicated)
(set-window-dedicated-p window display-buffer-mark-dedicated)))
(advice-add #'window--display-buffer :filter-return #'+popup*set-window-dedicated))
(unless EMACS26+ (unless EMACS26+
(defvar window-sides-reversed nil) (defvar window-sides-reversed nil)