title: How to intercept a file before it opens and decide which frame
body: <p>I am looking for some ideas, please, regarding how to intercept a file before it opens and make a decision which frame to open it in.</p>
  
  <p>I have a modified version of <code>frame-bufs</code> by Alp Aker -- <a href="https://github.com/alpaker/Frame-Bufs" rel="noreferrer">https://github.com/alpaker/Frame-Bufs</a> -- that is working with a current version of Emacs Trunk.  I wrote a function that associates the file being opened with the frame that has focus.  I'd like to take it one step further and set up a list of <code>file types</code> and <code>buffer names</code> that will always be associated with a particular frame.  I was thinking about a function that does something like this:</p>
  
  <pre><code>* If the file being opened is
       (or (eq major-mode 'text-mode) (eq major-mode 'latex-mode) )
            (switch-to-frame "TEXT")
  
  * If the buffer being opened is
       (or (equal (buffer-name) "Folder") (equal (buffer-name) "Summary") )
            (switch-to-frame "WANDERLUST")
  
  * After completing either of the above, open the file / buffer.
  
  * Run the custom frame association function -- (associate-current-buffer)
  </code></pre>
  
  <p>I assume that it is possible to figure out what mode a file is before it is actually opened in a frame.  What would be the best way to do this?</p>