core-popups: optimize + refactor
This commit is contained in:
parent
a30b0efce5
commit
085fbb3f72
1 changed files with 15 additions and 15 deletions
|
@ -38,7 +38,7 @@ is enabled/disabled.'")
|
||||||
|
|
||||||
(def-setting! :popup (&rest rules)
|
(def-setting! :popup (&rest rules)
|
||||||
"Prepend a new popup rule to `shackle-rules'."
|
"Prepend a new popup rule to `shackle-rules'."
|
||||||
(if (cl-every 'listp rules)
|
(if (cl-every #'listp rules)
|
||||||
`(setq shackle-rules (nconc ',rules shackle-rules))
|
`(setq shackle-rules (nconc ',rules shackle-rules))
|
||||||
`(push ',rules shackle-rules)))
|
`(push ',rules shackle-rules)))
|
||||||
|
|
||||||
|
@ -170,14 +170,14 @@ for :align t on every rule."
|
||||||
|
|
||||||
;; Major mode changes (and other things) may call `kill-all-local-variables',
|
;; Major mode changes (and other things) may call `kill-all-local-variables',
|
||||||
;; turning off things like `doom-popup-mode'. This prevents that.
|
;; turning off things like `doom-popup-mode'. This prevents that.
|
||||||
(put 'doom-popup-mode 'permanent-local t)
|
(put 'doom-popup-mode 'permanent-local t)
|
||||||
(put 'doom-popup-rules 'permanent-local t)
|
(put 'doom-popup-rules 'permanent-local t)
|
||||||
|
|
||||||
;; Don't show modeline in popup windows without a :modeline rule. If
|
(defun doom|hide-modeline-in-popup ()
|
||||||
;; one exists and it's a symbol, use `doom-modeline' to grab the
|
"Don't show modeline in popup windows without a :modeline rule. If one exists
|
||||||
;; format. If non-nil, show the mode-line as normal. If nil (or
|
and it's a symbol, use `doom-modeline' to grab the format. If non-nil, show the
|
||||||
;; omitted, by default), then hide the modeline entirely.
|
mode-line as normal. If nil (or omitted, by default), then hide the modeline
|
||||||
(add-hook! 'doom-popup-mode-hook
|
entirely."
|
||||||
(if doom-popup-mode
|
(if doom-popup-mode
|
||||||
(let ((modeline (plist-get doom-popup-rules :modeline)))
|
(let ((modeline (plist-get doom-popup-rules :modeline)))
|
||||||
(cond ((or (eq modeline 'nil)
|
(cond ((or (eq modeline 'nil)
|
||||||
|
@ -188,9 +188,9 @@ for :align t on every rule."
|
||||||
(setq-local doom--modeline-format (doom-modeline modeline))
|
(setq-local doom--modeline-format (doom-modeline modeline))
|
||||||
(when doom--modeline-format
|
(when doom--modeline-format
|
||||||
(doom-hide-modeline-mode +1)))))
|
(doom-hide-modeline-mode +1)))))
|
||||||
;; show modeline
|
|
||||||
(when doom-hide-modeline-mode
|
(when doom-hide-modeline-mode
|
||||||
(doom-hide-modeline-mode -1))))
|
(doom-hide-modeline-mode -1))))
|
||||||
|
(add-hook 'doom-popup-mode-hook #'doom|hide-modeline-in-popup)
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(defun doom*popup-init (orig-fn &rest args)
|
(defun doom*popup-init (orig-fn &rest args)
|
||||||
|
@ -461,8 +461,9 @@ the command buffer."
|
||||||
(let ((last (current-buffer)))
|
(let ((last (current-buffer)))
|
||||||
(cond ((when-let (dest (doom-buffers-in-mode
|
(cond ((when-let (dest (doom-buffers-in-mode
|
||||||
'magit-mode
|
'magit-mode
|
||||||
(cl-remove-if (lambda (buf) (eq buf last))
|
(cl-loop for buf in (window-prev-buffers)
|
||||||
(mapcar #'car (window-prev-buffers)))
|
unless (eq (car buf) last)
|
||||||
|
collect (car buf))
|
||||||
t))
|
t))
|
||||||
(doom-popup-switch-to-buffer (car dest)))
|
(doom-popup-switch-to-buffer (car dest)))
|
||||||
(kill-buffer last))
|
(kill-buffer last))
|
||||||
|
@ -534,7 +535,7 @@ you came from."
|
||||||
(window (selected-window)))
|
(window (selected-window)))
|
||||||
(apply orig-fn args)
|
(apply orig-fn args)
|
||||||
(when popup-p (doom/popup-close window))))
|
(when popup-p (doom/popup-close window))))
|
||||||
(advice-add 'xref-goto-xref :around 'doom*xref-follow-and-close))
|
(advice-add #'xref-goto-xref :around #'doom*xref-follow-and-close))
|
||||||
|
|
||||||
|
|
||||||
;; Ensure these settings are attached to org-load-hook as late as possible,
|
;; Ensure these settings are attached to org-load-hook as late as possible,
|
||||||
|
@ -594,10 +595,9 @@ you came from."
|
||||||
;; Don't monopolize frame!
|
;; Don't monopolize frame!
|
||||||
(advice-add #'org-agenda :around #'doom*suppress-delete-other-windows)
|
(advice-add #'org-agenda :around #'doom*suppress-delete-other-windows)
|
||||||
|
|
||||||
(after! evil
|
(map! :map org-agenda-mode-map
|
||||||
(map! :map* org-agenda-mode-map
|
:m [escape] 'org-agenda-Quit
|
||||||
:m [escape] 'org-agenda-Quit
|
:m "ESC" 'org-agenda-Quit)
|
||||||
:m "ESC" 'org-agenda-Quit))
|
|
||||||
(let ((map org-agenda-mode-map))
|
(let ((map org-agenda-mode-map))
|
||||||
(define-key map "q" 'org-agenda-Quit)
|
(define-key map "q" 'org-agenda-Quit)
|
||||||
(define-key map "Q" 'org-agenda-Quit)))))
|
(define-key map "Q" 'org-agenda-Quit)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue