2018-05-14 01:20:53 +02:00
|
|
|
;;; ui/popup/config.el -*- lexical-binding: t; -*-
|
2018-01-06 01:23:22 -05:00
|
|
|
|
|
|
|
(defconst +popup-window-parameters
|
2018-01-06 04:56:12 -05:00
|
|
|
'(transient quit select modeline popup)
|
2018-01-06 01:23:22 -05:00
|
|
|
"A list of custom parameters to be added to `window-persistent-parameters'.
|
2018-05-14 01:20:53 +02:00
|
|
|
Modifying this has no effect, unless done before ui/popup loads.
|
2018-01-06 01:23:22 -05:00
|
|
|
|
|
|
|
(transient . CDR)
|
2018-01-07 02:33:57 -05:00
|
|
|
CDR can be t, an integer, nil or a function that returns one of these. It
|
|
|
|
represents the number of seconds before the buffer belonging to a closed popup
|
|
|
|
window is killed.
|
2018-01-06 01:23:22 -05:00
|
|
|
|
|
|
|
If t, CDR will default to `+popup-ttl'.
|
|
|
|
If 0, the buffer is immediately killed.
|
|
|
|
If nil, the buffer won't be killed.
|
2018-01-07 02:33:57 -05:00
|
|
|
If a function, it must return one of the other possible values above. It takes
|
|
|
|
the popup buffer as its sole argument.
|
2018-01-06 01:23:22 -05:00
|
|
|
|
2018-01-06 02:42:53 -05:00
|
|
|
(quit . CDR)
|
2018-01-07 02:33:57 -05:00
|
|
|
CDR can be t, 'other, 'current, nil, or a function that returns one of these.
|
|
|
|
This determines the behavior of the ESC/C-g keys in or outside of popup
|
|
|
|
windows.
|
2018-01-06 01:23:22 -05:00
|
|
|
|
2018-01-06 02:42:53 -05:00
|
|
|
If t, close the popup if ESC/C-g is pressed inside or outside of popups.
|
|
|
|
If 'other, close this popup if ESC/C-g is pressed outside of any popup. This
|
2018-01-07 00:08:30 -05:00
|
|
|
is great for popups you just want to peek at and discard, but might also
|
|
|
|
want to poke around in, without the risk of closing it from the inside.
|
2018-01-06 02:42:53 -05:00
|
|
|
If 'current, close the current popup if ESC/C-g is pressed from inside of the
|
|
|
|
popup.
|
|
|
|
If nil, pressing ESC/C-g will never close this buffer.
|
2018-01-07 02:33:57 -05:00
|
|
|
If a function, it is checked each time ESC/C-g is pressed to determine the
|
|
|
|
fate of the popup window. This function takes one argument: the popup
|
|
|
|
window and must return one of the other possible values.
|
2018-01-06 01:23:22 -05:00
|
|
|
|
2018-01-07 02:33:57 -05:00
|
|
|
(select . CDR)
|
|
|
|
CDR can be a boolean or function. The boolean determines whether to focus the
|
|
|
|
popup window after it opens (non-nil) or focus the origin window (nil).
|
|
|
|
|
|
|
|
If a function, it takes two arguments: the popup window and the source window
|
|
|
|
(where you were before the popup was opened). It does nothing else, and
|
|
|
|
ignores its return value.
|
2018-01-06 01:23:22 -05:00
|
|
|
|
|
|
|
(modeline . CDR)
|
|
|
|
CDR can be t (show the default modeline), a symbol representing the name of a
|
2018-01-07 02:33:57 -05:00
|
|
|
modeline defined with `def-modeline!', nil (show no modeline) or a function
|
|
|
|
that returns one of these. The function takes one argument: the popup buffer.
|
2018-01-06 01:23:22 -05:00
|
|
|
|
2018-05-19 12:07:11 +02:00
|
|
|
(autosave . CDR)
|
|
|
|
This parameter determines what to do with modified buffers in closing popup
|
|
|
|
windows. CDR can be a t, 'ignore, a function or nil.
|
|
|
|
|
|
|
|
If t, no prompts. Just save them automatically (if they're file-visiting
|
|
|
|
buffers).
|
|
|
|
If 'ignore, no prompts, no saving. Just silently kill it.
|
|
|
|
If nil (the default), prompt the user what to do if the buffer is
|
|
|
|
file-visiting and modified.
|
|
|
|
If a function, the return value must return one of the other values. It takes
|
|
|
|
two arguments: the popup window and buffer.
|
|
|
|
|
2018-01-06 13:30:59 -05:00
|
|
|
(popup . t)
|
|
|
|
This is for internal use, do not change this. It simply marks a window as a
|
|
|
|
popup window.
|
2018-01-06 01:23:22 -05:00
|
|
|
|
|
|
|
Since I can't find this information anywhere but the Emacs manual, I'll include
|
|
|
|
a brief description of some native window parameters that Emacs uses:
|
|
|
|
|
|
|
|
(delete-window . CDR)
|
|
|
|
(delete-other-window . CDR)
|
|
|
|
(split-window . CDR)
|
|
|
|
(other-window . CDR)
|
|
|
|
This applies to all four of the above: CDR can be t or a function. If t, using
|
|
|
|
those functions on this window will ignore all window parameters.
|
|
|
|
|
|
|
|
If CDR is a function, it will replace the native function when used on this
|
|
|
|
window. e.g. if CDR is #'ignore (delete-window popup) will run (ignore popup)
|
|
|
|
instead of deleting the window!
|
|
|
|
(no-other-window . BOOL)
|
|
|
|
If CDR is non-nil, this window becomes invisible to `other-window' and
|
|
|
|
`pop-to-buffer'. Doom popups sets this. The default is nil.")
|
|
|
|
|
2018-01-09 16:40:44 -05:00
|
|
|
(defvar +popup-display-buffer-actions
|
2018-01-11 01:05:20 -05:00
|
|
|
'(display-buffer-reuse-window +popup-display-buffer)
|
2018-01-09 16:40:44 -05:00
|
|
|
"The functions to use to display the popup buffer.")
|
|
|
|
|
2018-01-06 01:23:22 -05:00
|
|
|
(defvar +popup-default-alist
|
2018-01-07 05:39:28 -05:00
|
|
|
'((window-height . 0.16)
|
2018-01-06 01:23:22 -05:00
|
|
|
(reusable-frames . visible))
|
|
|
|
"The default alist for `display-buffer-alist' rules.")
|
|
|
|
|
|
|
|
(defvar +popup-default-parameters
|
|
|
|
'((transient . t)
|
2018-01-08 17:29:15 -05:00
|
|
|
(quit . t)
|
|
|
|
(select . ignore))
|
2018-01-07 00:08:30 -05:00
|
|
|
"The default window parameters.")
|
2018-01-06 01:23:22 -05:00
|
|
|
|
2018-02-19 20:25:54 -05:00
|
|
|
(defvar +popup-ttl 5
|
2018-01-06 01:23:22 -05:00
|
|
|
"The default time-to-live for transient buffers whose popup buffers have been
|
|
|
|
deleted.")
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Default popup rules & bootstrap
|
|
|
|
;;
|
|
|
|
|
2018-06-15 02:58:12 +02:00
|
|
|
(set-popup-rules!
|
|
|
|
(when (featurep! +all)
|
|
|
|
'(("^\\*" ((slot . 1) (vslot . -1)) ((select . t)))
|
|
|
|
("^ \\*" ((slot . 1) (vslot . -1) (size . +popup-shrink-to-fit)))))
|
|
|
|
(when (featurep! +defaults)
|
|
|
|
'(("^\\*Completions"
|
|
|
|
((slot . -1) (vslot . -2))
|
|
|
|
((transient . 0)))
|
|
|
|
("^\\*Compil\\(?:ation\\|e-Log\\)"
|
|
|
|
((size . 0.3))
|
|
|
|
((transient . 0) (quit . t)))
|
|
|
|
("^\\*\\(?:scratch\\|Messages\\)"
|
|
|
|
nil
|
|
|
|
((autosave . t) (transient)))
|
|
|
|
("^\\*doom \\(?:term\\|eshell\\)"
|
|
|
|
((size . 0.25) (vslot . -10))
|
|
|
|
((select . t) (quit) (transient . 0)))
|
|
|
|
("^\\*doom:"
|
|
|
|
((size . 0.35) (side . bottom))
|
|
|
|
((autosave . t) (select . t) (modeline . t) (quit) (transient . t)))
|
|
|
|
("^\\*\\(?:\\(?:Pp E\\|doom e\\)val\\)"
|
|
|
|
((size . +popup-shrink-to-fit))
|
|
|
|
((transient . 0) (select . ignore)))
|
|
|
|
("^\\*Customize"
|
|
|
|
((slot . 2) (side . right))
|
|
|
|
((modeline . nil) (select . t) (quit . t)))
|
|
|
|
("^ \\*undo-tree\\*"
|
|
|
|
((slot . 2) (side . left) (size . 20))
|
|
|
|
((modeline . nil) (select . t) (quit . t)))
|
|
|
|
;; `help-mode', `helpful-mode'
|
|
|
|
("^\\*[Hh]elp"
|
|
|
|
((slot . 2) (vslot . 2) (size . 0.25))
|
|
|
|
((select . t)))
|
|
|
|
;; `Info-mode'
|
|
|
|
("^\\*info\\*$"
|
|
|
|
((slot . 2) (vslot . 2) (size . 0.45))
|
|
|
|
((select . t))))))
|
2018-02-01 23:17:18 -05:00
|
|
|
|
|
|
|
(add-hook 'doom-init-ui-hook #'+popup-mode)
|
2018-03-18 02:37:10 -04:00
|
|
|
(add-hook! '+popup-buffer-mode-hook
|
|
|
|
#'(+popup|adjust-fringes
|
|
|
|
+popup|set-modeline-on-enable
|
|
|
|
+popup|unset-modeline-on-disable))
|
2018-01-06 01:23:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Hacks
|
|
|
|
;;
|
|
|
|
|
2018-05-27 12:44:22 +02:00
|
|
|
(load! "+hacks")
|