Skip to content

feat(lib): factor out window handling hook fn into variable#8127

Draft
dradetsky wants to merge 1 commit into
doomemacs:masterfrom
dradetsky:fix-reload-window-close
Draft

feat(lib): factor out window handling hook fn into variable#8127
dradetsky wants to merge 1 commit into
doomemacs:masterfrom
dradetsky:fix-reload-window-close

Conversation

@dradetsky

@dradetsky dradetsky commented Oct 28, 2024

Copy link
Copy Markdown
Contributor

If I disable the popup module and run doom/reload the default hook (presumably designed to work with popup) will close the window it ran in. As a result, I have to fix my window layout after running a reload.

To solve this we:

  1. Split the code that does this out of the one-big-hook that gets called after doom/reload
  2. Put that code into a variable

Then I can get emacs to do what I want by adding the following to my user config

(defun dmr:handle-compile-buffer (_buf status)
  (when (equal status "finished\n")
    (kill-buffer _buf)))

(setq doom-handle-compile-buffer-fn #'dmr:handle-compile-buffer)

  • I searched the issue tracker and this hasn't been PRed before.
  • My changes are not on the do-not-PR list for this project.
  • My commits conform to Doom's git conventions.
  • I am blindly checking these off.

@dradetsky dradetsky requested a review from a team as a code owner October 28, 2024 23:28
@dradetsky dradetsky force-pushed the fix-reload-window-close branch from 707a751 to e561ea5 Compare October 28, 2024 23:31
@hlissner hlissner added is:feature Adds or requests new features, or extends existing ones was:moved Is, was, or will be addressed elsewhere core:lib Relevant to Doom core's libraries labels Oct 29, 2024
@hlissner hlissner added this to the modules v24.11 milestone Oct 29, 2024
@hlissner hlissner marked this pull request as draft October 29, 2024 00:01
@dradetsky

Copy link
Copy Markdown
Contributor Author

@hlissner I just thought of an easier hack for myself to solve the underlying problem, making this less urgent. I don't really like it, it's obviously suboptimal in many ways, but it solves the problem, so there you go. What I've done is add the following to my config:

(remove-hook 'doom-init-ui-hook #'+popup-mode)

(defun dmr/doom/reload ()
  (interactive)
  (+popup-mode +1)
  (doom/reload)
  (+popup-mode -1))

(map! :leader
      (:prefix "h"
               (:prefix "r"
                :desc "Reload user config" "r" #'dmr/doom/reload)))

This way, on reload we turn on popup mode just long enough to not have the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core:lib Relevant to Doom core's libraries is:feature Adds or requests new features, or extends existing ones was:moved Is, was, or will be addressed elsewhere

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants