Improve robustness of popup predicates & checks
This commit is contained in:
parent
30c5f2fa26
commit
9b5a219373
1 changed files with 17 additions and 15 deletions
|
@ -123,22 +123,24 @@ and enables `+popup-buffer-mode'."
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +popup-buffer-p (&optional buffer)
|
(defun +popup-buffer-p (&optional buffer)
|
||||||
"Return non-nil if BUFFER is a popup buffer. Defaults to the current buffer."
|
"Return non-nil if BUFFER is a popup buffer. Defaults to the current buffer."
|
||||||
|
(when +popup-mode
|
||||||
(unless buffer
|
(unless buffer
|
||||||
(setq buffer (current-buffer)))
|
(setq buffer (current-buffer)))
|
||||||
(cl-assert (bufferp buffer) t)
|
(cl-assert (bufferp buffer) t)
|
||||||
(and (buffer-live-p buffer)
|
(and (buffer-live-p buffer)
|
||||||
(buffer-local-value '+popup-buffer-mode buffer)
|
(buffer-local-value '+popup-buffer-mode buffer)
|
||||||
buffer))
|
buffer)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +popup-window-p (&optional window)
|
(defun +popup-window-p (&optional window)
|
||||||
"Return non-nil if WINDOW is a popup window. Defaults to the current window."
|
"Return non-nil if WINDOW is a popup window. Defaults to the current window."
|
||||||
|
(when +popup-mode
|
||||||
(unless window
|
(unless window
|
||||||
(setq window (selected-window)))
|
(setq window (selected-window)))
|
||||||
(cl-assert (windowp window) t)
|
(cl-assert (windowp window) t)
|
||||||
(and (window-live-p window)
|
(and (window-live-p window)
|
||||||
(window-parameter window 'popup)
|
(window-parameter window 'popup)
|
||||||
window))
|
window)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +popup-buffer (buffer &optional alist)
|
(defun +popup-buffer (buffer &optional alist)
|
||||||
|
@ -258,7 +260,7 @@ that window has been changed or closed."
|
||||||
(defun +popup|adjust-fringes ()
|
(defun +popup|adjust-fringes ()
|
||||||
"Hides the fringe in popup windows, restoring them if `+popup-buffer-mode' is
|
"Hides the fringe in popup windows, restoring them if `+popup-buffer-mode' is
|
||||||
disabled."
|
disabled."
|
||||||
(let ((f (if +popup-buffer-mode 0)))
|
(let ((f (if (bound-and-true-p +popup-buffer-mode) 0)))
|
||||||
(set-window-fringes nil f f fringes-outside-margins)))
|
(set-window-fringes nil f f fringes-outside-margins)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
@ -270,7 +272,7 @@ disabled."
|
||||||
+ If nil (or omitted), then hide the modeline entirely (the default).
|
+ If nil (or omitted), then hide the modeline entirely (the default).
|
||||||
+ If a function, it takes the current buffer as its argument and must return one
|
+ If a function, it takes the current buffer as its argument and must return one
|
||||||
of the above values."
|
of the above values."
|
||||||
(when +popup-buffer-mode
|
(when (bound-and-true-p +popup-buffer-mode)
|
||||||
(let ((modeline (+popup-parameter-fn 'modeline nil (current-buffer))))
|
(let ((modeline (+popup-parameter-fn 'modeline nil (current-buffer))))
|
||||||
(cond ((eq modeline 't))
|
(cond ((eq modeline 't))
|
||||||
((or (eq modeline 'nil)
|
((or (eq modeline 'nil)
|
||||||
|
@ -283,7 +285,7 @@ disabled."
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +popup|unset-modeline-on-disable ()
|
(defun +popup|unset-modeline-on-disable ()
|
||||||
"Restore the modeline when `+popup-buffer-mode' is deactivated."
|
"Restore the modeline when `+popup-buffer-mode' is deactivated."
|
||||||
(when (and (not +popup-buffer-mode)
|
(when (and (not (bound-and-true-p +popup-buffer-mode))
|
||||||
(bound-and-true-p hide-mode-line-mode))
|
(bound-and-true-p hide-mode-line-mode))
|
||||||
(hide-mode-line-mode -1)))
|
(hide-mode-line-mode -1)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue