ui/popup: refactor org hacks
This removes a few popup advice functions that are no longer necessary and changes how we handle org agenda windows (they're now displayed in the current window, rather than a popup -- see org-agenda-window-setup to change this). Other issues addressed: + Fixes 'Attempt to delete main window of frame' errors when using org-todo from popups (particularly in daemon Emacs). + Removed the custom 'popup-window options for org-agenda-window-setup and org-src-window-setup, and change them to 'current-window and 'other-window, respectively.
This commit is contained in:
parent
887bc05478
commit
6f6e30c428
2 changed files with 14 additions and 43 deletions
|
@ -7,6 +7,8 @@
|
|||
(unless org-agenda-files
|
||||
(setq org-agenda-files (list org-directory)))
|
||||
(setq-default
|
||||
;; Don't monopolize the whole frame just for the agenda
|
||||
org-agenda-window-setup 'current-window
|
||||
;; Hide blocked tasks in the agenda view.
|
||||
org-agenda-dim-blocked-tasks 'invisible
|
||||
org-agenda-inhibit-startup t
|
||||
|
@ -84,8 +86,9 @@
|
|||
(defun +org-init-babel-h ()
|
||||
(setq org-src-preserve-indentation t ; use native major-mode indentation
|
||||
org-src-tab-acts-natively t
|
||||
org-src-window-setup 'current-window
|
||||
org-confirm-babel-evaluate nil) ; you don't need my permission
|
||||
org-confirm-babel-evaluate nil ; you don't need my permission
|
||||
;; Show src buffer in popup, and don't monopolize the frame
|
||||
org-src-window-setup 'other-window)
|
||||
|
||||
;; I prefer C-c C-c over C-c ' (more consistent)
|
||||
(define-key org-src-mode-map (kbd "C-c C-c") #'org-edit-src-exit)
|
||||
|
@ -707,8 +710,8 @@ between the two."
|
|||
'(("^\\*Org Links" :slot -1 :vslot -1 :size 2 :ttl 0)
|
||||
("^\\*\\(?:Agenda Com\\|Calendar\\|Org \\(?:Export Dispatcher\\|Select\\)\\)"
|
||||
:slot -1 :vslot -1 :size #'+popup-shrink-to-fit :ttl 0)
|
||||
("^\\*Org Agenda" :size 0.35 :select t :ttl nil)
|
||||
("^\\*Org Src" :size 0.3 :quit nil :select t :autosave t :ttl nil)
|
||||
("^\\*Org Agenda" :ignore t)
|
||||
("^\\*Org Src" :size 0.4 :quit nil :select t :autosave t :modeline t :ttl nil)
|
||||
("^CAPTURE.*\\.org$" :size 0.2 :quit nil :select t :autosave t))))
|
||||
|
||||
|
||||
|
|
|
@ -242,8 +242,8 @@ the command buffer."
|
|||
org-fast-tag-selection
|
||||
org-fast-todo-selection)
|
||||
(if +popup-mode
|
||||
(cl-letf (((symbol-function 'delete-other-windows)
|
||||
(symbol-function 'ignore)))
|
||||
(cl-letf (((symbol-function #'delete-other-windows)
|
||||
(symbol-function #'ignore)))
|
||||
(apply orig-fn args))
|
||||
(apply orig-fn args)))
|
||||
|
||||
|
@ -254,58 +254,26 @@ Ugh, such an ugly hack."
|
|||
:around '(org-fast-tag-selection
|
||||
org-fast-todo-selection)
|
||||
(if +popup-mode
|
||||
(cl-letf* ((old-fit-buffer-fn (symbol-function 'org-fit-window-to-buffer))
|
||||
((symbol-function 'org-fit-window-to-buffer)
|
||||
(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))
|
||||
(select-window window)
|
||||
(select-window
|
||||
(setq window (display-buffer-at-bottom 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)))
|
||||
|
||||
(defadvice! +popup--org-src-pop-to-buffer-a (orig-fn buffer context)
|
||||
"Hand off the src-block window to the popup system by using `display-buffer'
|
||||
instead of switch-to-buffer-*."
|
||||
:around #'org-src-switch-to-buffer
|
||||
(if (and (eq org-src-window-setup 'popup-window)
|
||||
+popup-mode)
|
||||
(pop-to-buffer buffer)
|
||||
(funcall orig-fn buffer context)))
|
||||
(setq org-src-window-setup 'popup-window)
|
||||
|
||||
;; Ensure todo, agenda, and other minor popups are delegated to the popup system.
|
||||
(defadvice! +popup--org-pop-to-buffer-a (orig-fn buf &optional norecord)
|
||||
"Use `pop-to-buffer' instead of `switch-to-buffer' to open buffer.'"
|
||||
:around #'org-switch-to-buffer-other-window
|
||||
(if +popup-mode
|
||||
(pop-to-buffer buf nil norecord)
|
||||
(funcall orig-fn buf norecord)))
|
||||
|
||||
;; `org-agenda'
|
||||
(setq org-agenda-window-setup 'popup-window
|
||||
org-agenda-restore-windows-after-quit nil)
|
||||
;; Don't monopolize the frame!
|
||||
(defadvice! +popup--org-agenda-suppress-delete-other-windows-a (orig-fn &rest args)
|
||||
:around #'org-agenda-prepare-window
|
||||
(cond ((not +popup-mode)
|
||||
(apply orig-fn args))
|
||||
((eq org-agenda-window-setup 'popup-window)
|
||||
(let ((org-agenda-window-setup 'other-window)
|
||||
org-agenda-restore-windows-after-quit)
|
||||
(cl-letf (((symbol-function 'delete-other-windows)
|
||||
(symbol-function 'ignore)))
|
||||
(apply orig-fn args))))
|
||||
((memq org-agenda-window-setup '(current-window other-window))
|
||||
(with-popup-rules! nil
|
||||
(cl-letf (((symbol-function 'delete-other-windows)
|
||||
(symbol-function 'ignore)))
|
||||
(apply orig-fn args))))
|
||||
((with-popup-rules! nil
|
||||
(apply orig-fn args))))))
|
||||
(funcall orig-fn buf norecord))))
|
||||
|
||||
|
||||
;;;###package persp-mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue