feat(emacs): popups
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
;;
|
||||
;; I avoid calling `pdf-tools-install' directly because `pdf-tools' is easy to
|
||||
;; prematurely load in the background (e.g. when exporting an org file or by
|
||||
;; packages like org-pdftools). And I don't want pdf-tools to suddenly block
|
||||
;; packages like org-pdftools), and I don't want pdf-tools to suddenly block
|
||||
;; Emacs and spew out compiler output for a few minutes in those cases. It's
|
||||
;; abysmal UX. The `pdf-view-mode' advice above works around this with a less
|
||||
;; cryptic failure message, at least.
|
||||
@@ -55,9 +55,9 @@
|
||||
(defun syd-pdf--init-ui-h ()
|
||||
;; HACK: Flickering pdfs when evil-mode is enabled.
|
||||
(setq-local evil-normal-state-cursor (list nil))))
|
||||
(set-popup-rules!
|
||||
(syd-push shackle-rules
|
||||
'(("^\\*Outline*" :side right :size 40 :select nil)
|
||||
("^\\*Edit Annotation " :quit nil)
|
||||
("^\\*Edit Annotation " :inhibit-window-quit t)
|
||||
("\\(?:^\\*Contents\\|'s annots\\*$\\)" :ignore t)))
|
||||
;; Silence "File *.pdf is large (X MiB), really open?" prompts for PDFs.
|
||||
(syd-defadvice syd-pdf--suppress-large-file-prompts-a
|
||||
|
||||
@@ -3,26 +3,39 @@
|
||||
(require 'syd/base)
|
||||
(require 'syd/hide-mode-line)
|
||||
|
||||
(use-package popper
|
||||
:hook (on-init-ui-hook)
|
||||
:preface
|
||||
(require 'hide-mode-line)
|
||||
;; `doom-popup' tests (boundp 'hide-mode-line-mode) before it tries enabling
|
||||
;; or disabling the mode. We must define this because `hide-mode-line' does
|
||||
;; not autoload it.
|
||||
(defvar hide-mode-line-mode nil)
|
||||
:init
|
||||
(setq popper-display-control nil
|
||||
popper-reference-buffers
|
||||
(list (lambda (buf)
|
||||
(with-current-buffer buf
|
||||
(bound-and-true-p doom-popup-buffer-mode)))))
|
||||
:config
|
||||
(popper-mode 1))
|
||||
(defvar syd-new-popup-hook nil
|
||||
"Ran upon display of a new popup buffer. The current buffer will be the
|
||||
popup.")
|
||||
|
||||
(use-package doom-popup
|
||||
:straight (:type git
|
||||
:host gitlab
|
||||
:repo "crumbtoo/doom-popup"))
|
||||
(use-package shackle
|
||||
:hook on-init-ui
|
||||
:custom ((shackle-default-size 0.33))
|
||||
:config
|
||||
(syd-push shackle-rules
|
||||
'("*Help*" :select t :size 0.42 :popup t :align bottom)
|
||||
'("*Messages*" :select t :size 0.16 :popup t :align bottom))
|
||||
(defvar-local syd--new-popup-hook-ran nil)
|
||||
(syd-defadvice syd--shackle-run-new-popup-hook-a (buffer _alist)
|
||||
:after #'shackle-display-buffer-action
|
||||
(unless syd--new-popup-hook-ran
|
||||
(with-current-buffer buffer
|
||||
(run-hooks 'syd-new-popup-hook))
|
||||
(setq syd--new-popup-hook-ran t))))
|
||||
|
||||
(use-package popper
|
||||
:hook on-init-ui
|
||||
:init
|
||||
(require 'shackle)
|
||||
(setq popper-display-control nil
|
||||
popper-reference-buffers (list #'shackle-match))
|
||||
:config
|
||||
(syd-add-hook 'syd-escape-hook
|
||||
(defun syd-escape-close-popups-h ()
|
||||
"If the current buffer is a popup, close it. Otherwise, close all popups."
|
||||
(if (popper-popup-p (current-buffer))
|
||||
(popper-close-latest)
|
||||
(while popper-open-popup-alist
|
||||
(popper-close-latest)))))
|
||||
(add-hook 'syd-new-popup-hook #'hide-mode-line-mode))
|
||||
|
||||
(provide 'syd/popups)
|
||||
|
||||
@@ -173,6 +173,10 @@ form."
|
||||
(apply #'file-name-concat
|
||||
user-emacs-directory components))
|
||||
|
||||
(defmacro syd-push (place &rest elts)
|
||||
"Push ELTS onto PLACE, mutating it."
|
||||
`(setq ,place (append (list ,@elts) ,place)))
|
||||
|
||||
;; (syd-defadvice syd-lsp-install-server-a ()
|
||||
;; :override #'lsp-install-server
|
||||
;; (user-error (concat "Ignoring a call to `lsp-install-server'"
|
||||
|
||||
Reference in New Issue
Block a user