I use to have diferent frames for diferent tasks... I'd like to get new private message windows open in the same frame that the rest of the ERC stuff, not in the current focused frame. I'm searching for a long time, and I can't find any way to get this... Any idea?

  • Could you please describe what you mean by "query message"? It may not be clear to some readers who otherwise might be able to help. Thx.
    – Drew
    Dec 16 '19 at 15:15
  • a private message from one of the channels. The window always is openned in the focused frame... Dec 16 '19 at 15:27
  • Please put any such info in the question itself. Comments can be deleted at any time.
    – Drew
    Dec 16 '19 at 16:04
  • Sorry, my english is not good enough. Dec 16 '19 at 16:08

Does this work?

(defun my-major-mode-frame-p (mode frame)
  "Return non-nil if FRAME displays any buffer in major mode MODE."
  (catch 'window
     (lambda (w)
       (and (window-live-p w)
            (eq mode (buffer-local-value 'major-mode (window-buffer w)))
            (throw 'window w)))
     'nomini frame)))

;; Always display ERC buffers in the same frame.
(let ((ercframep (apply-partially #'my-major-mode-frame-p 'erc-mode)))
  (add-to-list 'display-buffer-alist
               (cons (lambda (buffer alist)
                       (with-current-buffer buffer
                         (derived-mode-p 'erc-mode)))
                     (cons #'display-buffer-use-some-frame
                           `((inhibit-switch-frame . nil)
                             (inhibit-same-window . nil)
                             (frame-predicate . ,ercframep))))))
  • Under testing, but for now, it seems to work perfectly, thanks phisl Dec 17 '19 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.