ui/popup: fix *Org tags* popups
- So the mode-line doesn't "hide" the last line of the popup - So org doesn't delete all other windows when displaying the *Org tags* popup - Minor corrections to comments in ui/popup/+hacks.el
This commit is contained in:
parent
e8c0ac9f30
commit
14b1e36812
1 changed files with 29 additions and 9 deletions
|
@ -5,8 +5,8 @@
|
||||||
;; down to:
|
;; down to:
|
||||||
;;
|
;;
|
||||||
;; 1. Making plugins that control their own window environment less greedy (e.g.
|
;; 1. Making plugins that control their own window environment less greedy (e.g.
|
||||||
;; org agenda, which tries to reconfigure the entire frame (by deleting all
|
;; org agenda, which tries to reconfigure the entire frame by deleting all
|
||||||
;; other windows) just to pop up one tiny window).
|
;; other windows just to pop up one tiny window).
|
||||||
;; 2. Forcing plugins to use `display-buffer' and `pop-to-buffer' instead of
|
;; 2. Forcing plugins to use `display-buffer' and `pop-to-buffer' instead of
|
||||||
;; `switch-to-buffer' (which is unaffected by `display-buffer-alist', which
|
;; `switch-to-buffer' (which is unaffected by `display-buffer-alist', which
|
||||||
;; this module heavily relies on).
|
;; this module heavily relies on).
|
||||||
|
@ -15,12 +15,13 @@
|
||||||
;; `save-popups!' macro).
|
;; `save-popups!' macro).
|
||||||
;;
|
;;
|
||||||
;; Keep in mind, all this black magic may break in future updates, and will need
|
;; Keep in mind, all this black magic may break in future updates, and will need
|
||||||
;; to be watched carefully for corner cases. Also, once this file is loaded, its
|
;; to be watched carefully for corner cases. Also, once this file is loaded,
|
||||||
;; changes are irreversible without restarting Emacs! I don't like it either,
|
;; many of its changes are irreversible without restarting Emacs! I don't like
|
||||||
;; but I will address this over time.
|
;; it either, but I will address this over time.
|
||||||
;;
|
;;
|
||||||
;; Hacks should be kept in alphabetical order, named after the feature they
|
;; Hacks should be kept in alphabetical order, named after the feature they
|
||||||
;; modify, and should follow a ;; `package-name' header line.
|
;; modify, and should follow a ;;;## package-name header line (if not using
|
||||||
|
;; `after!' or `def-package!').
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;;; Core functions
|
;;; Core functions
|
||||||
|
@ -235,9 +236,9 @@ the command buffer."
|
||||||
;;;###package org
|
;;;###package org
|
||||||
(after! org
|
(after! org
|
||||||
(defvar +popup--disable-internal nil)
|
(defvar +popup--disable-internal nil)
|
||||||
;; Org has a scorched-earth window management system I'm not fond of. i.e. it
|
;; Org has a scorched-earth window management policy I'm not fond of. i.e. it
|
||||||
;; kills all windows and monopolizes the frame. No thanks. We can do better
|
;; kills all other windows just so it can monopolize the frame. No thanks. We
|
||||||
;; ourselves.
|
;; can do better ourselves.
|
||||||
(defun +popup*suppress-delete-other-windows (orig-fn &rest args)
|
(defun +popup*suppress-delete-other-windows (orig-fn &rest args)
|
||||||
(if +popup-mode
|
(if +popup-mode
|
||||||
(cl-letf (((symbol-function 'delete-other-windows)
|
(cl-letf (((symbol-function 'delete-other-windows)
|
||||||
|
@ -248,6 +249,25 @@ the command buffer."
|
||||||
(advice-add #'org-capture-place-template :around #'+popup*suppress-delete-other-windows)
|
(advice-add #'org-capture-place-template :around #'+popup*suppress-delete-other-windows)
|
||||||
(advice-add #'org-export--dispatch-ui :around #'+popup*suppress-delete-other-windows)
|
(advice-add #'org-export--dispatch-ui :around #'+popup*suppress-delete-other-windows)
|
||||||
(advice-add #'org-agenda-get-restriction-and-command :around #'+popup*suppress-delete-other-windows)
|
(advice-add #'org-agenda-get-restriction-and-command :around #'+popup*suppress-delete-other-windows)
|
||||||
|
(advice-add #'org-fast-tag-selection :around #'+popup*suppress-delete-other-windows)
|
||||||
|
|
||||||
|
(defun +popup*fix-tags-window (orig-fn &rest args)
|
||||||
|
"Hides the mode-line in *Org tags* buffer so you can actually see its
|
||||||
|
content and displays it in a side window without deleting all other windows.
|
||||||
|
Ugh, such an ugly hack."
|
||||||
|
(if +popup-mode
|
||||||
|
(cl-letf* ((old-fit-buffer-fn (symbol-function 'org-fit-window-to-buffer))
|
||||||
|
((symbol-function 'org-fit-window-to-buffer)
|
||||||
|
(lambda (&optional window max-height min-height shrink-only)
|
||||||
|
(when-let (buf (window-buffer window))
|
||||||
|
(delete-window window)
|
||||||
|
(setq window (display-buffer-in-side-window buf nil))
|
||||||
|
(with-current-buffer buf
|
||||||
|
(setq mode-line-format nil)))
|
||||||
|
(funcall old-fit-buffer-fn window max-height min-height shrink-only))))
|
||||||
|
(apply orig-fn args))
|
||||||
|
(apply orig-fn args)))
|
||||||
|
(advice-add #'org-fast-tag-selection :around #'+popup*fix-tags-window)
|
||||||
|
|
||||||
(defun +popup*org-src-pop-to-buffer (orig-fn buffer context)
|
(defun +popup*org-src-pop-to-buffer (orig-fn buffer context)
|
||||||
"Hand off the src-block window to the popup system by using `display-buffer'
|
"Hand off the src-block window to the popup system by using `display-buffer'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue