Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot use major mode in display-buffer-alist to control prodigy-mode buffer placement #146

Open
lem102 opened this issue Nov 15, 2024 · 1 comment · May be fixed by #149
Open

cannot use major mode in display-buffer-alist to control prodigy-mode buffer placement #146

lem102 opened this issue Nov 15, 2024 · 1 comment · May be fixed by #149

Comments

@lem102
Copy link

lem102 commented Nov 15, 2024

Hello, thanks for this great package.

I have this code so that if a prodigy-mode buffer is displayed, it is displayed in the window currently in use.

(setopt display-buffer-alist '(((major-mode . prodigy-mode) (display-buffer-same-window))))

This works as expected when using the prodigy-mode command with a prodigy buffer already open, however with no prodigy buffer open this display buffer rule is not respected.

I think when we are creating a new prodigy buffer with the below command, we display the new buffer before setting the mode, so the above display buffer rule does not trigger.

(defun prodigy ()
  "Manage external services from within Emacs."
  (interactive)
  (let ((buffer-p (prodigy-buffer))
        (buffer (get-buffer-create prodigy-buffer-name)))
    (pop-to-buffer buffer) ; display-buffer is called here
    (unless buffer-p
      (prodigy-mode) ; the mode is set here
      )
    (prodigy-start-status-check-timer)))

I have this code to work around the issue:

(defun jacob-prodigy ()
  "Manage external services from within Emacs."
  (interactive)
  (with-current-buffer (get-buffer-create prodigy-buffer-name)
    (prodigy-mode)
    (prodigy-start-status-check-timer)
    (pop-to-buffer (current-buffer))))

(advice-add #'prodigy :override #'jacob-prodigy)

Am happy to open a PR to work on this.

@DamienCassou
Copy link
Collaborator

A PR would make sense in my opinion. Thank you!

@lem102 lem102 linked a pull request Nov 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants