Home » Questions » Computers [ Ask a new question ]

Making emacs frames/windows inviolate for emacs auto changes

Making emacs frames/windows inviolate for emacs auto changes

"I was wondering if there is a way to mark certain frames in a split window emacs session as inviolate to changing. I normally have 4 frames for sources files and 2-3 frames for other views such as compilation/grep-find/etc.
I would like to mark the latter frames somehow so that they will never be split or have their contents changed by emacs. This way if I click on a search result I don't have my compilation window splitting and a source file inserted.
I want any source files to go in my source windows and to stay out of my misc-view windows.
Is there a way to do this?"

Asked by: Guest | Views: 266
Total answers/comments: 1
Guest [Entry]

"Yes, there is a way to do this, but I don't think it will be easy. A quick look through frame-related functions and variables confirmed my belief that there's no easy fix here. The problem is that Emacs would not know what to do once these frames are the only remaining frames, and something needed to be done to/with them.

I think it would be possible to code up a package that advised all of the low-level frame manipulation functions such that some frames would remain untouched by any operation, but that would require identifying and interpreting each of those low-level functions. I think a better approach (unless you're an elisp wizard) would be to identify the functions that you use that annoy you in this manner, and see if there's a common function or group of functions that they use to determine which frame to display their output in, and then set out to change that behavior.

I would probably use a frame parameter (frame-parameter and modify-frame-parameters) to store whether or not a given frame was inviolate. This could be set manually by you, or perhaps at the end of the function that populates the frame with whatever data (through the use of a wrapper function or (more likely) defadvice). Then find a function that changes one of them and look at its source. What function(s) did it call to determine which frame to use? Modify and/or advise those functions (or maybe something called by those functions) to not consider frames with this certain parameter set. As a special case, if there are no other frames available, make a new frame and return that.

You could also have several classes of frames (e.g. source frame, compilation/errors frame) and allow some of these to be re-used by certain functions but not others. How complex you make it, really, is up to you and your imagination.

Anyhow, it looks at first blush to be very doable but non-trivial.

Now, having said all of that, there is a package out there that may help you get closer to what you want: One-on-One Emacs. It don't know if it protects frames the way you want to, though. And from the description it seems like it re-defines a lot of core functions, rather than advising them, which could make it extremely version-specific (that's just a feeling I got reading his description; I didn't look at the code to see if that is what actually is happening).

Good luck!"