mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-29 03:26:13 +01:00
Get rid of pohlady
Signed-off-by: main <magic_rb@redalder.org>
This commit is contained in:
parent
b01377018c
commit
ed0b631f45
|
@ -1,99 +0,0 @@
|
|||
:PROPERTIES:
|
||||
:ID: a637b320-cd55-4d37-a728-50b2c2181b0a
|
||||
:END:
|
||||
#+title: Pohlady
|
||||
#+filetags: emacs-load
|
||||
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(defvar pohlady-window-configurations (make-hash-table)
|
||||
"All saved window confugaritions.")
|
||||
|
||||
(defvar pohlady-display-buffer-alists (make-hash-table))
|
||||
|
||||
(defvar pohlady-views (make-hash-table)
|
||||
"All views known.")
|
||||
|
||||
(defun pohlady--get-current-view ()
|
||||
"Get the current view for this frame."
|
||||
(frame-parameter nil 'pohlady-current-view))
|
||||
|
||||
(defun pohlady--set-current-view (current-view)
|
||||
"Set the CURRENT-VIEW for this frame."
|
||||
(set-frame-parameter nil 'pohlady-current-view current-view))
|
||||
|
||||
(defun pohlady--get-frame-display-buffer-alist ()
|
||||
"Get the frame local `display-buffer-alist'."
|
||||
(let* ((display-buffer-alist- (gethash (selected-frame) pohlady-display-buffer-alists))
|
||||
(current-view (pohlady--get-current-view))
|
||||
(display-buffer-alist-style (plist-get current-view :display-buffer-alist-style)))
|
||||
(if current-view
|
||||
(progn
|
||||
(puthash
|
||||
(selected-frame)
|
||||
(cond
|
||||
((eq display-buffer-alist-style 'before)
|
||||
(append (plist-get current-view :display-buffer-alist) display-buffer-alist))
|
||||
((eq display-buffer-alist-style 'after)
|
||||
(append display-buffer-alist (plist-get current-view :display-buffer-alist)))
|
||||
((eq display-buffer-alist-style 'override)
|
||||
(plist-get current-view :display-buffer-alist))
|
||||
(t display-buffer-alist))
|
||||
pohlady-display-buffer-alists)
|
||||
(gethash (selected-frame) pohlady-display-buffer-alists))
|
||||
display-buffer-alist-)))
|
||||
|
||||
(defun pohlady-switch-view (name)
|
||||
"Switch to a view with NAME.
|
||||
If view not present yet, call function according to
|
||||
:init-function."
|
||||
(interactive "sSelect view: ")
|
||||
(let ((new-view (gethash name pohlady-views))
|
||||
(current-view (pohlady--get-current-view)))
|
||||
(when new-view
|
||||
(when current-view
|
||||
(puthash (plist-get current-view :name) (current-window-configuration) pohlady-window-configurations))
|
||||
(pohlady--set-current-view new-view)
|
||||
(if (gethash name pohlady-window-configurations)
|
||||
(set-window-configuration (gethash name pohlady-window-configurations) t)
|
||||
(funcall (plist-get (pohlady--get-current-view) :init-function))))))
|
||||
|
||||
(define-advice display-buffer
|
||||
(:around (orig-fun &rest args) frame-local-display-buffer-alist)
|
||||
(let ((display-buffer-alist-orig display-buffer-alist)
|
||||
(display-buffer-alist (pohlady--get-frame-display-buffer-alist)))
|
||||
(message "%s" display-buffer-alist)
|
||||
(apply orig-fun args)))
|
||||
|
||||
(define-advice switch-to-buffer
|
||||
(:around (orig-fun &rest args) frame-local-display-buffer-alist)
|
||||
(let ((display-buffer-alist-orig display-buffer-alist)
|
||||
(display-buffer-alist (pohlady--get-frame-display-buffer-alist)))
|
||||
(message "%s" display-buffer-alist)
|
||||
(apply orig-fun args)))
|
||||
|
||||
(add-hook
|
||||
'after-init-hook
|
||||
(puthash
|
||||
"default"
|
||||
`(:name "default"
|
||||
:display-buffer-alist-style before
|
||||
:display-buffer-alist ("\\*Help\\*" (display-buffer-in-side-window)
|
||||
(side . bottom)
|
||||
(slot . 0)
|
||||
(window-height . 33)
|
||||
(window-parameters
|
||||
(no-delete-other-windows . t)))
|
||||
:init-function ,(lambda () (message "Hello")))
|
||||
pohlady-views)
|
||||
(puthash
|
||||
"ement"
|
||||
`(:name "ement"
|
||||
:display-buffer-alist nil
|
||||
:display-beffer-alist-style before
|
||||
:init-function ,(lambda () (ement-list-rooms)))
|
||||
pohlady-views)
|
||||
(pohlady-switch-view "default"))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
| magic_rb/userbind-mode | org-roam-setup | (lambda nil (mu4e t)) | org-persist-load-all | pgtk-use-im-context-handler | tramp-register-archive-file-name-handler | magit-maybe-define-global-key-bindings | magit-auto-revert-mode--init-kludge | magit-startup-asserts | magit-version | (:name default :display-buffer-alist-style before :display-buffer-alist (\*Help\* (display-buffer-in-side-window) (side . bottom) (slot . 0) (window-height . 33) (window-parameters (no-delete-other-windows . t))) :init-function (lambda nil (message Hello))) |
|
Loading…
Reference in a new issue