0

I am writing a mode that implements a persistent horizontal window (very similar to the "persistence compile window" in ECB). While I did study the ECB code it is quite old and endeavored to work with even more ancient verions of emacs. I am trying to write code the makes use of the many recent enhancements to emacs' windowing system.

It would appear that display-buffer-base-action is exactly the point in display-buffer's processing sequence to hook in my window management smarts. I am able to classify newly created buffers base on buffer-name (e.g. Completions) and on whether of not they are related to a live process (using comint-check-proc). What I cannot do is classify a newly created buffer base on its ultimate major-mode. This is because when display-buffer is called on a newly created buffer that buffer's major-mode has not yet been set.

Is there any way to "peer into the future" to determine what major-mode will later get established?

  • The following link contains a complex example using a custom function attached to the display-buffer-alist that examines a buffer after its creation with find-file-noselect, and then displays the buffer differently based upon various criteria: stackoverflow.com/questions/18346785/… – lawlist Sep 3 '15 at 2:09
  • If the O.P. is able to provide additional details regarding how and when the major-mode is determined, the forum participants may be able to be of more assistance -- even if we don't use ECB. :) There may not necessarily be a good reason to limit the answer to using the display-buffer-base-action, when an appropriate function (with conditions) attached to the display-buffer-alist would likely suffice -- it can even be let-bound so as to avoid unintended side effects. – lawlist Sep 3 '15 at 2:17
  • Just fix that mode's code instead and you've got one headache less to worry about. – wasamasa Sep 3 '15 at 6:36
  • @lawlist: I took a look at the example. It is no more functional than my current code as it is entirely based on examining the name of the buffer. Nor is display-buffer-alist an obvious solution since it is processed during display-buffer and hence has access to no additional context. – John Yates Sep 3 '15 at 13:56
  • 1
    I do consider this as a bug because the majority of buffers displayed comes with the right mode enabled and I've been able to fix the few ones were this wasn't the case. – wasamasa Sep 3 '15 at 14:03

Your Answer

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

Browse other questions tagged or ask your own question.